/* ================================================================
   前台评论表单 · 照 Alpha 原稿：正文在上，昵称/邮箱/网址与「发布评论」同一行
   控件一律 border:0 + 浅灰底；状态只用底色变化，不用 border-color / box-shadow
   ================================================================ */

.talk-form { margin-top: 12px; }

/* 编辑区：表情按钮叠在输入框内部左下角，不再单独占一行 */
.talk-editor { position: relative; }

.talk-form-text {
    display: block;
    width: 100%;
    min-height: 120px;
    padding: 10px 10px 44px;
    border: 0;
    border-radius: 5px;
    background: var(--paper-2);
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink);
    resize: vertical;
    outline: none;
}

/* 聚焦不显示焦点框：鼠标点击与键盘聚焦都不出现 outline */
.talk-form-text:focus,
.talk-form-text:focus-visible {
    outline: none;
}

.talk-form-text::placeholder,
.talk-field::placeholder,
.talk-captcha input::placeholder { color: var(--ink-3); }

/* 四等分一行：昵称 / 邮箱 / 个人主页 / 发布评论 */
.talk-form-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.talk-field,
.talk-form-submit {
    flex: 1 1 0;
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 5px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
}

.talk-field {
    background: var(--paper-2);
    color: var(--ink);
}

.talk-form-submit {
    background: var(--accent);
    color: #fff;
    font-weight: 500;
    letter-spacing: 1px;
    text-align: center;
    cursor: pointer;
    transition: opacity .18s ease;
}

.talk-form-submit:hover { opacity: .9; }
.talk-form-submit:disabled { opacity: .55; cursor: default; }

/* 登录后行内只剩按钮：按内容自适应，不被四等分拉满 */
.talk-form-info > .talk-form-submit:only-child {
    flex: 0 0 auto;
    width: auto;
    min-width: 112px;
    margin-left: auto;
}

.talk-form-msg {
    margin: 8px 0 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--ink-3);
}

.talk-form-msg.is-error { color: #d9534f; }
.talk-form-msg.is-ok { color: var(--accent-ink); }

.talk-form-login {
    margin: 10px 0 0;
    font-size: 12.5px;
    color: var(--ink-3);
}

/* 验证码浮层 · 照 Alpha 的弹窗：点「发布评论」才弹出 */
.talk-captcha-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.talk-captcha-modal[hidden] { display: none; }

.talk-captcha-mask {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.talk-captcha-panel {
    position: relative;
    width: min(320px, 100%);
    padding: 20px;
    border-radius: 12px;
    background: var(--card);
}

.talk-captcha-title {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    text-align: center;
}

.talk-captcha {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.talk-captcha img {
    display: block;
    width: 108px;
    height: 36px;
    border-radius: 5px;
    background: var(--paper-2);
    cursor: pointer;
}

.talk-captcha input {
    width: 112px;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 5px;
    background: var(--paper-2);
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
}

.talk-captcha-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.talk-captcha-cancel,
.talk-captcha-ok {
    height: 32px;
    padding: 0 16px;
    border: 0;
    border-radius: 5px;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.talk-captcha-cancel {
    background: var(--paper-2);
    color: var(--ink-2);
}

.talk-captcha-ok {
    background: var(--accent);
    color: #fff;
    font-weight: 500;
}

@media (max-width: 720px) {
    .talk-form-text { min-height: 100px; }
    .talk-form-info { flex-direction: column; align-items: stretch; gap: 8px; }
    .talk-field,
    .talk-form-submit { flex: 0 0 auto; width: 100%; }
}

/* 表情：按钮叠在输入框内左下角，面板向上浮出（无描边、无投影，只靠底色分层） */
.talk-form-tools {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    z-index: 150;           /* 高于音乐底栏（.kwm-dock z-index:95）；父级带 z-index 会成层叠上下文，容器和面板必须一起抬 */
    display: flex;
    align-items: center;
    padding-left: 8px;
    pointer-events: none;   /* 只让按钮与面板可点，不挡住输入框 */
}

.talk-emoji-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    font-family: inherit;
    line-height: 1;
    color: var(--ink-3);
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .15s ease, color .15s ease;
}

.talk-emoji-btn:hover,
.talk-emoji-btn[aria-expanded='true'] {
    background: color-mix(in srgb, var(--accent) 12%, var(--paper-2));
    color: var(--accent-ink);
}

.talk-emoji-face { font-size: 17px; line-height: 1; }

.talk-emoji-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    z-index: 150;
    width: auto;
    /* 面板固定 4 整行高：38×4 行高 + 4×3 行距 + 8×2 内边距 = 180px；
       面板自身不滚动，超出部分交给内部 .talk-emoji-grid 滚动 */
    --emoji-cell: 38px;
    box-sizing: border-box;
    height: calc(var(--emoji-cell) * 4 + 12px + 16px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 8px;
    border-radius: 10px;
    background: var(--card);
    pointer-events: auto;   /* 父级 .talk-form-tools 为 none，这里必须恢复，否则滚轮/触摸事件进不来 */
}
.talk-emoji-panel[hidden] { display: none; }

.talk-emoji-grid {
    flex: 1 1 auto;
    min-height: 0;              /* 关键：不加这行，flex 子项撑满内容高度，内部滚动不成立 */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    grid-auto-rows: var(--emoji-cell, 38px);   /* 行高固定，不随列宽变化，面板高度才能算准 */
    align-content: start;
    gap: 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--ink) 22%, transparent) transparent;
}

.talk-emoji-grid::-webkit-scrollbar { width: 6px; }
.talk-emoji-grid::-webkit-scrollbar-track { background: transparent; }
.talk-emoji-grid::-webkit-scrollbar-thumb {
    border-radius: 3px;
    background: color-mix(in srgb, var(--ink) 22%, transparent);
}
.talk-emoji-grid:empty::before {
    content: '加载中…';
    grid-column: 1 / -1;
    padding: 8px 2px;
    font-size: 12.5px;
    color: var(--ink-3);
}

.talk-emoji-item {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;             /* 2px 内边距算进 38px 行高，避免格子溢出压住下一行 */
    width: 100%;
    height: var(--emoji-cell, 38px);    /* 固定行高替代 aspect-ratio，避免行高随列宽变化 */
    padding: 2px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
    transition: background-color .15s ease;
}
.talk-emoji-item:hover { background: color-mix(in srgb, var(--ink) 6%, var(--paper-2)); }
.talk-emoji-item img { display: block; width: 100%; height: 100%; object-fit: contain; }
