/* TalkTree 面板与页面样式（森林玻璃；token 见 tokens.css） */

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: #0a0e14;
    font-family: var(--tt-font, "DM Sans", "Noto Sans SC", system-ui, sans-serif);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

#app {
    position: fixed;
    inset: 0;
}

#app canvas {
    display: block;
}

/* ===== 加载屏 ===== */
#loading-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: linear-gradient(180deg, #0d1420 0%, #16202e 100%);
    z-index: 100;
    transition: opacity 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

#loading-title {
    font-size: 32px;
    font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--accent);
    text-shadow: 0 2px 24px rgba(111, 191, 74, 0.4);
}

#loading-bar {
    width: 260px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

#loading-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.15s ease;
}

#loading-text {
    font-size: 13px;
    color: var(--text-dim);
    letter-spacing: 1px;
}

/* ===== 右侧面板底栏：统计 + LOD（不再单独占左边） ===== */
#stats-overlay {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    flex-shrink: 0;
    padding: 8px 12px;
    border-top: 1px solid var(--panel-border);
    font-size: 12px;
}

#stats-overlay .stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}

#stats-overlay .stat-value {
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

#stats-overlay .stat-label {
    color: var(--text-dim);
}

#stats-overlay .pulse {
    animation: stat-pulse 0.45s ease;
}

@keyframes stat-pulse {
    0% { color: var(--accent); }
    100% { color: var(--text); }
}

.lod-switcher {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
    padding: 0;
    border: 0;
}

.lod-switcher .lod-button {
    flex: none;
}

.lod-button {
    min-width: 28px;
    height: 22px;
    padding: 0 6px;
    font-size: 10px;
    line-height: 20px;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    cursor: pointer;
}

.lod-button:hover { color: var(--text); }

.lod-button.active {
    color: #fff;
    background: var(--accent-dim);
    border-color: var(--accent);
}

/* eztree.dev 环境音开关（官方 icon_muted / icon_playing） */
.tt-audio-icon {
    position: fixed;
    right: 358px;
    bottom: 20px;
    z-index: 25;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.tt-audio-icon:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.tt-audio-icon img {
    display: block;
    width: 40px;
    height: 40px;
    pointer-events: none;
}

/* ===== 主面板 ===== */
#ui-container,
#ai-container {
    position: fixed;
    top: 14px;
    bottom: 14px;
    width: 330px;
    z-index: 30;
    pointer-events: none;
}

#ui-container { right: 14px; }
#ai-container { left: 14px; }

.custom-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--tt-radius, 16px);
    backdrop-filter: blur(16px);
    overflow: hidden;
    pointer-events: auto;
}

/* ===== 右侧顶栏：账号 + 语言 ===== */
.panel-header-tools {
    justify-content: flex-end;
    gap: 8px;
}

#talktree_auth_chip {
    display: flex;
    align-items: center;
    gap: 4px;
    pointer-events: auto;
}

.tt-chip-link,
.tt-chip-btn {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    height: 30px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
}

.tt-chip-link:hover,
.tt-chip-btn:hover { color: var(--text); }

.tt-chip-link.solid {
    color: #fff;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--panel-border);
    cursor: default;
    user-select: none;
}

.panel-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.panel-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel-title strong {
    font-size: 17px;
    letter-spacing: 1px;
    color: var(--accent);
}

.panel-title small {
    font-size: 11px;
    color: var(--text-dim);
}

.lang-toggle {
    box-sizing: border-box;
    height: 30px;
    padding: 0 8px;
    font-size: 12px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    cursor: pointer;
}

.lang-toggle:hover { background: rgba(255, 255, 255, 0.12); }

.lang-toggle option {
    background: #fff;
    color: #1c2430;
}

.panel-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* ===== Tab ===== */
.tab-nav {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.tab-button {
    flex: 1;
    padding: 8px 0;
    font-size: 12px;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    cursor: pointer;
}

.tab-button.active {
    color: #fff;
    background: var(--accent-dim);
    border-color: var(--accent);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== 贴图 Tab ===== */
.tt-quota-mark {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    line-height: 18px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-dim);
}

.tt-quota-mark.over {
    background: rgba(196, 92, 74, 0.28);
    color: #f0c4bc;
}

.tex-lib-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--text);
}

.tt-member-meters > div.over dd .tt-quota-mark {
    background: rgba(196, 92, 74, 0.28);
    color: #f0c4bc;
}

.tex-kinds,
.tex-filters,
.tex-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.tex-kind,
.tex-filter,
.tex-action {
    flex: 1;
    height: 30px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.tex-kind.active,
.tex-filter.active {
    color: #fff;
    background: var(--accent-dim);
    border-color: var(--accent);
}

.tex-action:hover { color: var(--text); }

.tex-block-label {
    margin-bottom: 8px;
    font-size: 11px;
    color: var(--text-dim);
}

.tex-current-set {
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
}

.tex-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.tex-slots-leaf { grid-template-columns: 1fr; }

.tex-slots-leaf .tex-slot {
    aspect-ratio: auto;
    width: 100%;
    max-height: 240px;
}

.tex-slots-leaf .tex-slot img {
    object-fit: contain;
}

.tex-slot {
    position: relative;
    aspect-ratio: 1;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

.tex-slot img,
.tex-card-thumb img,
.tex-current-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tex-slot-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 11px;
    color: var(--text-dim);
}

.tex-slot-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 3px 4px;
    font-size: 10px;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
}

.tex-current-source {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-dim);
}

.tex-orient {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--panel-border);
}

.tex-orient-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--text-dim);
}

.tex-orient-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tex-orient-row .slider { flex: 1; min-width: 0; }

.tex-orient-btns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.tex-orient-btns .tex-action { flex: none; }

.tex-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tex-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 0 8px;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.tex-card.active { border-color: var(--accent); }

.tex-card-thumb {
    position: relative;
    display: block;
    aspect-ratio: 1.15;
    background: rgba(0, 0, 0, 0.25);
}

.tex-card-thumb-leaf {
    aspect-ratio: auto;
}

.tex-card-thumb-leaf img {
    object-fit: contain;
}

.tex-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    font-size: 10px;
    color: #fff;
}

.tex-dots {
    position: absolute;
    right: 6px;
    bottom: 6px;
    display: flex;
    gap: 3px;
}

.tex-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
}

.tex-dots i.on { background: var(--accent); }

.tex-card-name {
    padding: 0 8px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tex-card-del {
    position: absolute;
    top: 4px;
    right: 6px;
    z-index: 1;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 14px;
}

.tex-empty,
.tex-hint {
    font-size: 11px;
    line-height: 1.55;
    color: var(--text-dim);
}

.tex-empty {
    grid-column: 1 / -1;
    padding: 16px 8px;
    text-align: center;
}

.tex-hint { margin-top: 10px; }

.tex-current-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 8px 0 10px;
    padding: 6px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.tex-current-row:hover { border-color: var(--accent); }

.tex-current-thumb {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.25);
}

.tex-current-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tex-current-meta strong {
    font-size: 12px;
    color: var(--text);
}

.tex-current-meta small {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tex-current-go {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--accent);
}

/* ===== 分区 ===== */
.panel-section {
    margin-bottom: 8px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.section-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.section-header:hover { background: rgba(255, 255, 255, 0.04); }

.section-header .chevron,
.subsection-header .chevron {
    transition: transform 0.2s ease;
    color: var(--text-dim);
}

.panel-section.expanded > .section-header .chevron,
.panel-subsection.expanded > .subsection-header .chevron {
    transform: rotate(90deg);
}

.section-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.25s ease;
}

.panel-section.expanded > .section-content {
    grid-template-rows: 1fr;
}

.section-content-inner {
    overflow: hidden;
    padding: 0 12px;
}

.panel-section.expanded .section-content-inner {
    padding-bottom: 10px;
}

.panel-subsection {
    margin: 6px 0;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
}

.subsection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
}

.subsection-title-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.subsection-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.2s ease;
}

.panel-subsection.expanded > .subsection-content {
    grid-template-rows: 1fr;
}

.subsection-content-inner {
    overflow: hidden;
    padding: 0 8px;
}

.panel-subsection.expanded .subsection-content-inner {
    padding-bottom: 6px;
}

/* ===== 控件行 ===== */
.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 0;
}

.control-label {
    font-size: 12px;
    color: var(--text-dim);
    flex-shrink: 0;
    max-width: 45%;
}

.control-label-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    max-width: 45%;
}

.control-label-wrap .control-label { max-width: none; }

.ctrl-reset {
    flex-shrink: 0;
    padding: 1px 6px;
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    font: inherit;
    font-size: 11px;
    font-weight: 500;
    line-height: 16px;
    cursor: pointer;
}

.ctrl-reset:hover {
    color: var(--text);
    border-color: var(--text-dim);
    background: rgba(255, 255, 255, 0.08);
}

.section-header .ctrl-reset { font-weight: 500; }

.control-row:has(.ctrl-reset) .slider-wrapper,
.control-row:has(.ctrl-reset) .select-wrapper,
.control-row:has(.ctrl-reset) .color-picker-wrapper,
.control-row:has(.ctrl-reset) .toggle-wrapper {
    max-width: 46%;
}

/* 滑杆 */
.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 55%;
}

.slider {
    flex: 1;
    min-width: 0;
    height: 4px;
    appearance: none;
    -webkit-appearance: none;
    background: linear-gradient(to right, var(--accent) var(--fill, 50%), rgba(255, 255, 255, 0.14) var(--fill, 50%));
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent);
}

.slider-value {
    width: 52px;
    padding: 3px 4px;
    font-size: 11px;
    color: var(--text);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.slider-value:focus {
    outline: none;
    border-color: var(--accent);
}

/* 下拉 */
.select-wrapper { max-width: 55%; flex: 1; }

.select {
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    color: var(--text);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}

.select option {
    background: #fff;
    color: #1c2430;
}

/* 开关 */
.toggle {
    position: relative;
    width: 36px;
    height: 20px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: background 0.2s ease;
    padding: 0;
}

.toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s ease;
}

.toggle.active {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle.active .toggle-knob {
    transform: translateX(16px);
}

/* 取色器 */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-preview {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
}

.color-picker {
    width: 40px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

.panel-button-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.panel-button-row .panel-button {
    flex: 1;
    width: auto;
    margin-top: 0;
}

/* 按钮 */
.panel-button {
    width: 100%;
    margin-top: 8px;
    padding: 9px 0;
    font-size: 13px;
    color: #fff;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.panel-button:hover { background: rgba(111, 191, 74, 0.4); }

.panel-button:disabled {
    opacity: 0.55;
    cursor: wait;
}

/* 只读行 */
.display-row .display-value {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

/* ===== About 浮层 ===== */
#about-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    z-index: 90;
}

#about-overlay.active { display: flex; }

.about-card {
    max-width: 380px;
    padding: 24px 28px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    backdrop-filter: blur(14px);
}

.about-card h2 {
    margin: 0 0 10px;
    font-size: 18px;
    color: var(--accent);
}

.about-card p {
    margin: 0 0 16px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-dim);
}

/* ===== 左侧 AI 对话 ===== */
.ai-panel {
    pointer-events: auto;
}

.ai-log {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.ai-empty {
    margin: auto;
    padding: 12px 8px;
    text-align: center;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-dim);
}

.ai-bubble {
    max-width: 92%;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.55;
}

.ai-bubble-user {
    align-self: flex-end;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
}

.ai-bubble-assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
}

.ai-bubble-role {
    margin-bottom: 3px;
    font-size: 11px;
    color: var(--text-dim);
}

.ai-think {
    margin-top: 8px;
    padding: 6px 8px;
    border-left: 2px solid var(--accent);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0 8px 8px 0;
}

.ai-think summary {
    cursor: pointer;
    font-size: 11px;
    color: var(--text-dim);
    user-select: none;
}

.ai-think-body {
    margin: 6px 0 0;
    max-height: 220px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    contain: content;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-dim);
}

.ai-composer {
    flex-shrink: 0;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--panel-border);
}

.ai-field { margin-bottom: 10px; }

.ai-field-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    font-size: 11px;
    color: var(--text-dim);
}

.ai-modes {
    display: flex;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
}

.ai-mode {
    flex: 1;
    height: 28px;
    border: 0;
    border-right: 1px solid var(--panel-border);
    border-radius: 0;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.ai-mode:last-child { border-right: 0; }

.ai-mode.active {
    color: #fff;
    background: var(--accent-dim);
}

.ai-jobs .ai-mode {
    min-height: 40px;
    height: auto;
    padding: 6px 4px;
    line-height: 1.25;
    white-space: normal;
}

.ai-report {
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}

.ai-report-head {
    margin-bottom: 6px;
    font-size: 11px;
    color: var(--text-dim);
}

.ai-report-row {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.45;
}

.ai-report-row strong {
    flex: 0 0 42px;
    font-weight: 600;
    color: var(--text-dim);
}

.ai-report-row span {
    flex: 1;
    color: var(--text);
}

.ai-chips {
    display: flex;
    gap: 6px;
}

.ai-chip {
    flex: 1;
    height: 26px;
    border: 1px dashed var(--panel-border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.ai-chip.active {
    color: #d8edcf;
    background: rgba(111, 191, 74, 0.12);
    border-style: solid;
    border-color: var(--accent);
}

.ai-based-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.ai-based {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
}

.ai-help {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid var(--panel-border);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    line-height: 16px;
    cursor: pointer;
}

.ai-help:hover { color: var(--text); border-color: var(--text-dim); }

.ai-help-tip {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    z-index: 4;
    padding: 8px 10px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: rgba(14, 18, 24, 0.96);
    color: var(--text);
    font-size: 12px;
    line-height: 1.55;
    white-space: pre-wrap;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.ai-help-tip[hidden] { display: none; }

.ctrl-help-tip {
    position: fixed;
    left: 12px;
    top: 12px;
    right: auto;
    bottom: auto;
    z-index: 200;
    max-width: min(280px, calc(100vw - 24px));
    max-height: min(50vh, 320px);
    overflow: auto;
}

.ctrl-help-tip-wide {
    max-width: min(400px, calc(100vw - 24px));
    max-height: min(70vh, 480px);
}

.ai-input-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.ai-input {
    flex: 1;
    min-height: 72px;
    resize: none;
    padding: 8px 10px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
}

.ai-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.ai-send-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 72px;
    flex-shrink: 0;
}

.ai-send,
.ai-tex {
    flex: 1;
    min-height: 32px;
    width: 100%;
    border: 0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.ai-send {
    background: var(--accent);
    color: #102010;
}

.ai-tex {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid var(--panel-border);
}

.ai-send:hover { filter: brightness(1.06); }
.ai-tex:hover { filter: brightness(1.08); }

.ai-stop {
    width: 100%;
    min-height: 32px;
    flex: 1;
    border: 1px solid #c45c4a;
    border-radius: 10px;
    background: rgba(196, 92, 74, 0.2);
    color: #f0c4bc;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.ai-stop:hover { filter: brightness(1.08); }

.ai-hint {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-dim);
}

.ai-header-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ai-hist-open {
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.ai-hist-open:hover { color: var(--text); }

.ai-chat-clear:hover { color: #f0b4b4; }

.ai-shot-strip,
.ai-hist-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    overflow-x: auto;
}

.ai-shot {
    flex: 0 0 auto;
    width: 108px;
    padding: 0;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.ai-shot.active,
.ai-shot.applied { border-color: var(--accent); }

.ai-shot-view {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: #fff;
    cursor: pointer;
}

.ai-shot img,
.ai-shot-empty {
    display: block;
    width: 108px;
    height: 136px;
    object-fit: contain;
    background: #fff;
}

.ai-shot-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    font-size: 11px;
    color: #5a6570;
    text-align: center;
}

.ai-shot-apply {
    display: block;
    width: 100%;
    min-height: 30px;
    padding: 0 6px;
    border: 0;
    border-top: 1px solid rgba(20, 40, 16, 0.18);
    background: #3f8a28;
    color: #fff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.ai-shot-apply:hover:not(:disabled) { filter: brightness(1.08); }

.ai-shot-apply.is-on,
.ai-shot-apply:disabled {
    color: #245018;
    background: #d8edcf;
    cursor: default;
}

.ai-shot-apply-wide {
    width: auto;
    min-width: 112px;
    height: 36px;
    margin-top: 10px;
    border-radius: 8px;
    border: 0;
}

.ai-shot-score {
    display: block;
    padding: 3px 4px;
    font-size: 10px;
    color: var(--text-dim);
    text-align: center;
}

.ai-shot-score.pass { color: #8fd36a; }
.ai-shot-score.fail { color: #e0a060; }

.ai-judge {
    margin-top: 8px;
    padding: 6px 8px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.ai-judge summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--text);
    user-select: none;
}

.ai-judge-lab {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-dim);
}

.ai-judge-points {
    margin: 4px 0 0;
    padding-left: 18px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text);
}

.ai-judge-text {
    margin: 4px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text);
}

.ai-hist {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(4, 10, 6, 0.72);
}

.ai-hist[hidden] { display: none; }

.ai-hist-card {
    width: min(920px, 100%);
    max-height: min(86vh, 780px);
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    backdrop-filter: blur(16px);
    overflow: hidden;
}

.ai-hist-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--panel-border);
}

.ai-hist-head strong {
    color: var(--accent);
    font-size: 15px;
}

.ai-hist-head span {
    margin-left: 8px;
    font-size: 12px;
    color: var(--text-dim);
}

.ai-hist-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-hist-textbtn,
.ai-hist-nav button {
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.ai-hist-nav button:disabled { opacity: 0.4; cursor: default; }

.ai-hist-close {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
}

.ai-hist-body,
.ai-hist-view {
    padding: 14px;
    overflow: auto;
}

.ai-hist-empty {
    padding: 32px 8px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

.ai-hist-group + .ai-hist-group { margin-top: 16px; }

.ai-hist-prompt {
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text);
}

.ai-hist-full {
    display: block;
    width: 100%;
    max-height: 52vh;
    object-fit: contain;
    border-radius: 10px;
    background: #000;
}

.ai-hist-meta {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text);
}

.ai-hist-meta p { margin: 6px 0 0; }

.ai-hist-reason { color: var(--text-dim); }

.ai-hist-nav {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ===== 移动端：底部抽屉 ===== */
@media (max-width: 800px) {
    #ui-container,
    #ai-container {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 70vh;
    }

    #ai-container {
        bottom: auto;
        top: 0;
        max-height: 70vh;
    }

    #ai-container .custom-panel {
        border-radius: 0 0 16px 16px;
    }

    #ai-container .custom-panel.collapsed {
        transform: translateY(calc(-100% + 52px));
    }

    .custom-panel {
        border-radius: 16px 16px 0 0;
        max-height: 70vh;
        transition: transform 0.3s ease;
    }

    .custom-panel.collapsed {
        transform: translateY(calc(100% - 52px));
    }

    .panel-header { cursor: pointer; }

    .tt-audio-icon {
        right: 16px;
        bottom: 68px;
    }
}

/* ===== 工坊内账号弹窗 ===== */
.tt-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(6, 10, 14, 0.62);
    backdrop-filter: blur(8px);
}

.tt-modal-overlay[hidden] { display: none; }

.tt-modal {
    position: relative;
    box-sizing: border-box;
    width: min(480px, 100%);
    max-height: min(86vh, 720px);
    overflow: auto;
    padding: 28px 26px 24px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--tt-radius, 16px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}

.tt-modal *,
.tt-modal *::before,
.tt-modal *::after {
    box-sizing: border-box;
}

.tt-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-dim);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.tt-modal-close:hover { color: var(--text); }

.tt-modal-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.tt-modal-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: #fff;
    font-size: 22px;
    font-weight: 600;
}

.tt-modal-brand strong {
    display: block;
    font-size: 18px;
    letter-spacing: 1px;
    color: var(--accent);
}

.tt-modal-brand small {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: var(--text-dim);
}

.tt-modal-fields {
    margin: 0 0 18px;
    padding: 14px 16px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.tt-modal-fields > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
}

.tt-modal-fields > div + div {
    border-top: 1px solid var(--panel-border);
}

.tt-modal-fields dt {
    font-size: 13px;
    color: var(--text-dim);
}

.tt-modal-fields dd {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.tt-modal-member {
    margin: 0 0 16px;
    padding: 14px 16px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.tt-modal-member h3 {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--text);
}

.tt-member-status {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
}

.tt-member-status small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-dim);
}

.tt-member-meters {
    margin: 0 0 12px;
    padding: 0;
}

.tt-member-meters > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 5px 0;
}

.tt-member-meters > div + div {
    border-top: 1px solid var(--panel-border);
}

.tt-member-meters dt {
    font-size: 12px;
    color: var(--text-dim);
}

.tt-member-meters dd {
    margin: 0;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.tt-member-err {
    margin: 0 0 10px;
    font-size: 12px;
    color: #f0c4bc;
}

.tt-plan-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tt-plan-card {
    padding: 12px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
}

.tt-plan-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.tt-plan-price {
    margin: 6px 0 4px;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

.tt-plan-price span {
    margin-left: 6px;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-dim);
}

.tt-plan-benefit,
.tt-plan-desc {
    margin: 0 0 8px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-dim);
}

.tt-plan-card .tt-modal-btn {
    width: 100%;
    justify-content: center;
}

.tt-modal-library {
    margin-bottom: 20px;
    padding: 16px;
    min-height: 120px;
    border: 1px dashed var(--panel-border);
    border-radius: 12px;
}

.tt-modal-library h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--text);
}

.tt-member-meters > div.over dd .tt-quota-mark {
    background: rgba(196, 92, 74, 0.28);
    color: #f0c4bc;
}

.tt-modal-library p {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-dim);
}

.tt-lib-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tt-lib-item {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.tt-lib-open {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 6px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: inherit;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.tt-lib-open:hover { border-color: var(--accent); }

.tt-lib-open img,
.tt-lib-ph {
    width: 44px;
    height: 56px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 6px;
    background: #fff;
}

.tt-lib-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #5a6570;
}

.tt-lib-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tt-lib-meta strong {
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-lib-meta small {
    font-size: 11px;
    color: var(--text-dim);
}

.tt-lib-del {
    flex-shrink: 0;
    padding: 0 10px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.tt-lib-del:hover { color: #f0c4bc; border-color: #c45c4a; }

.tt-save-status {
    margin: 6px 0 2px;
    font-size: 11px;
    color: var(--text-dim);
}

.tt-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.tt-modal-btn {
    height: 36px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #102010;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.tt-modal-btn.ghost {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border: 1px solid var(--panel-border);
}

.tt-modal-sub {
    margin: 0 0 12px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-dim);
}

.tt-modal-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0;
    min-width: 0;
}

.tt-modal-auth-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
}

.tt-modal-auth-fields.tt-modal-fields > div {
    display: block;
    padding: 0;
    border: 0;
}

.tt-modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    min-width: 0;
    font-size: 12px;
    color: var(--text-dim);
}

.tt-modal-field input {
    display: block;
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

.tt-modal-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim, rgba(111, 191, 74, 0.18));
}

.tt-modal-code {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.tt-modal-code input { flex: 1; min-width: 0; }
.tt-modal-code .tt-modal-btn { flex-shrink: 0; }

.tt-modal-msg {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
}

.tt-modal-auth-actions {
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tt-modal-action-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    margin-left: auto;
}

.tt-modal-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 13px;
    color: var(--text-dim);
}

.tt-modal-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.tt-modal-link:hover { text-decoration: underline; }

.tt-modal-btn:disabled,
.tt-chip-link:disabled {
    opacity: 0.5;
    cursor: default;
}

@media (max-width: 800px) {
    .tt-modal-overlay { align-items: flex-end; padding: 0; }
    .tt-modal {
        width: 100%;
        max-height: 88vh;
        border-radius: 16px 16px 0 0;
    }
}
