/* 交易命题手册 — 移动端优先，桌面端三栏增强 */

:root {
    --tt-primary: #1a56a7;
    --tt-primary-hover: #4a90e2;
    --tt-primary-light: #e8f0f8;
    --tt-success: #059669;
    --tt-success-light: #ecfdf5;
    --tt-warning: #d97706;
    --tt-warning-light: #fffbeb;
    --tt-danger: #dc2626;
    --tt-danger-light: #fef2f2;
    --tt-text: #0f172a;
    --tt-text-secondary: #64748b;
    --tt-text-muted: #94a3b8;
    --tt-border: #e2e8f0;
    --tt-border-light: #f0f2f5;
    --tt-bg: #f4f6fb;
    --tt-card: #ffffff;
    --tt-shadow: 0 4px 14px rgba(15, 23, 42, 0.045);
    --tt-radius: 12px;
    --tt-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    --tt-safe-bottom: env(safe-area-inset-bottom, 0px);
    --tt-tab-h: 52px;
    --tt-bar-h: 56px;
    --tt-header-h: 48px;
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html, body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--tt-font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--tt-text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body.tt-body {
    background:
        radial-gradient(circle at 10% 0%, rgba(59, 130, 246, 0.08) 0, transparent 45%),
        radial-gradient(circle at 95% 8%, rgba(16, 185, 129, 0.06) 0, transparent 35%),
        var(--tt-bg);
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

.index-header {
    width: 100%;
    background: #fff;
    border-bottom: 1px solid var(--tt-border);
    position: sticky;
    top: 0;
    z-index: 60;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

.index-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px 14px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: var(--tt-header-h);
}

.index-header-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #0f172a;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    min-height: 44px;
}

.index-header-logo { border-radius: 6px; }

.tt-header-nav { display: none; gap: 14px; }
.tt-nav-link {
    color: var(--tt-primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.tt-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tt-intro {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid #dde7f3;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
}

.tt-page-title {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: #0b1220;
}

.tt-page-title i { color: var(--tt-primary); margin-right: 6px; }

.tt-page-sub {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--tt-text-secondary);
    line-height: 1.45;
}

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

.tt-shell-card {
    background: var(--tt-card);
    border: 1px solid var(--tt-border-light);
    border-radius: var(--tt-radius);
    box-shadow: var(--tt-shadow);
    overflow: hidden;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

.tt-inline-loading {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    font-size: 14px;
    font-weight: 600;
    color: var(--tt-text-secondary);
    text-align: center;
}

.tt-inline-loading[hidden] { display: none !important; }

.tt-inline-loading i { color: var(--tt-primary); }

body.tt-action-busy .tt-fab:not(.is-loading) {
    pointer-events: none;
    opacity: 0.55;
}

.tt-mobile-tabs {
    display: flex;
    border-bottom: 1px solid var(--tt-border-light);
    background: #fafbfd;
    flex-shrink: 0;
}

.tt-mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--tt-tab-h);
    padding: 6px 4px;
    border: none;
    background: transparent;
    color: var(--tt-text-muted);
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s, background 0.15s;
}

.tt-mobile-tab i { font-size: 16px; }

.tt-mobile-tab.active {
    color: var(--tt-primary);
    background: var(--tt-primary-light);
    box-shadow: inset 0 -2px 0 var(--tt-primary);
}

.tt-mobile-tab:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.tt-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
}

.tt-panel {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.tt-panel.is-active {
    display: flex;
    flex-direction: column;
}

.tt-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 0 2px;
}

.tt-sidebar-head h2 {
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tt-text-secondary);
}

.tt-thesis-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tt-list-filters {
    display: flex;
    gap: 6px;
    margin: 0 0 8px;
    flex-shrink: 0;
}

.tt-list-filter {
    flex: 1;
    min-height: 30px;
    border: 1px solid var(--tt-border);
    border-radius: 8px;
    background: #fff;
    color: var(--tt-text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.tt-list-filter.active {
    border-color: rgba(26, 86, 167, 0.28);
    background: var(--tt-primary-light);
    color: var(--tt-primary);
}

/* Omnibox 捕获框 */
.tt-capture-box {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 10px 8px;
    background: #fff;
    border: 1px solid var(--tt-border);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    flex-shrink: 0;
}

.tt-capture-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    color: var(--tt-text);
    outline: none;
    max-height: 120px;
}

.tt-capture-input::placeholder { color: var(--tt-text-muted); }

.tt-capture-send {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: var(--tt-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

.tt-capture-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tt-capture-hint {
    margin: 6px 4px 0;
    font-size: 10px;
    color: var(--tt-text-muted);
    line-height: 1.4;
    flex-shrink: 0;
}

.tt-sidebar {
    padding: 10px 10px 80px;
    background: #fafbfd;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.tt-thesis-item--processing {
    border-color: rgba(26, 86, 167, 0.25);
    background: linear-gradient(135deg, #f8fbff 0%, #fff 100%);
}

.tt-thesis-ai-pulse {
    color: var(--tt-primary);
    animation: tt-ai-pulse 1.2s ease-in-out infinite;
    margin-right: 4px;
}

@keyframes tt-ai-pulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

.tt-struct-card[hidden] { display: none !important; }

.tt-thesis-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid var(--tt-border-light);
    background: #fff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.tt-thesis-item.active {
    background: var(--tt-primary-light);
    border-color: rgba(26, 86, 167, 0.3);
}

.tt-thesis-item-body { flex: 1; min-width: 0; }
.tt-thesis-item-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.35;
    word-break: break-word;
}
.tt-thesis-item-meta {
    font-size: 11px;
    color: var(--tt-text-muted);
    margin-top: 4px;
}

.tt-thesis-del {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: var(--tt-danger-light);
    color: var(--tt-danger);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.tt-main {
    padding: 12px 12px 100px;
}

.tt-welcome {
    text-align: center;
    padding: 48px 16px;
    color: var(--tt-text-secondary);
}

.tt-back-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 0 !important;
    min-width: 40px;
}

.tt-back-btn--solo {
    margin-bottom: 8px;
}

.tt-struct-card {
    position: relative;
    background: linear-gradient(135deg, #f8fbff 0%, #fff 100%);
    border: 1px solid #dde7f3;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.tt-struct-card-title {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--tt-primary);
}

.tt-struct-card-title i { margin-right: 6px; opacity: 0.85; }

.tt-struct-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.tt-struct-field--full { grid-column: 1 / -1; }

.tt-input-text,
.tt-input-area {
    width: 100%;
    background: #fff;
    border: 1px solid var(--tt-border);
    border-radius: 8px;
    color: var(--tt-text);
    padding: 8px 10px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
}

.tt-input-text:focus,
.tt-input-area:focus {
    border-color: var(--tt-primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 167, 0.12);
}

.tt-input-area { resize: vertical; min-height: 52px; }

.tt-select-sm {
    width: auto;
    min-width: 72px;
    flex-shrink: 0;
}

.tt-btn-sm {
    padding: 6px 10px !important;
    font-size: 12px !important;
    min-height: 36px;
}

.tt-entity-picker { display: flex; flex-direction: column; gap: 8px; }

.tt-entity-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 4px;
}

.tt-entity-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--tt-primary-light);
    color: var(--tt-primary);
    border: 1px solid rgba(26, 86, 167, 0.2);
}

.tt-entity-tag.stock { background: #ecfdf5; color: #047857; border-color: rgba(5, 150, 105, 0.25); }
.tt-entity-tag.index { background: #fffbeb; color: #b45309; border-color: rgba(217, 119, 6, 0.25); }

.tt-entity-tag-remove {
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    padding: 0 2px;
    font-size: 14px;
    line-height: 1;
}

.tt-entity-add-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: stretch;
}

.tt-entity-search-wrap {
    flex: 1;
    min-width: 120px;
    position: relative;
}

.tt-entity-suggest {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 30;
    background: #fff;
    border: 1px solid var(--tt-border);
    border-radius: 8px;
    box-shadow: var(--tt-shadow);
    max-height: 180px;
    overflow-y: auto;
}

.tt-entity-suggest-item {
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid var(--tt-border-light);
}

.tt-entity-suggest-item:last-child { border-bottom: none; }
.tt-entity-suggest-item:hover,
.tt-entity-suggest-item.active { background: var(--tt-primary-light); }

.tt-entity-suggest-item .code {
    font-weight: 700;
    color: var(--tt-primary);
    margin-right: 6px;
}

.tt-thesis-item-title-row {
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.tt-schedule-panel { margin-top: 16px; }

.tt-schedule-card {
    background: #f8fafc;
    border: 1px solid var(--tt-border-light);
    border-radius: 10px;
    padding: 12px;
}

.tt-schedule-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.tt-schedule-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--tt-primary);
}

.tt-schedule-row--sub { font-weight: 500; font-size: 13px; min-height: 40px; }

.tt-schedule-fields { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--tt-border-light); }
.tt-schedule-fields[hidden] { display: none; }

.tt-select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--tt-border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    margin-bottom: 8px;
}

.tt-schedule-meta {
    font-size: 12px;
    color: var(--tt-text-muted);
    margin: 8px 0 10px;
}

.tt-glass {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.tt-glass-inner {
    background: #f8fafc;
    border: 1px solid var(--tt-border-light);
    border-radius: 10px;
    padding: 12px;
}
.tt-muted { color: var(--tt-text-muted); font-size: 13px; margin: 0; }

.tt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.tt-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tt-btn-primary { background: var(--tt-primary); color: #fff; }
.tt-btn-accent { background: var(--tt-success); color: #fff; }
.tt-btn-ghost { background: #fff; color: var(--tt-text-secondary); border-color: var(--tt-border); }
.tt-btn-danger { background: var(--tt-danger-light); color: var(--tt-danger); border-color: rgba(220, 38, 38, 0.25); }
.tt-btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--tt-primary-light);
    color: var(--tt-primary);
    border: 1px solid rgba(26, 86, 167, 0.2);
}
.tt-btn-block { width: 100%; }

.tt-fab {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(var(--tt-safe-bottom) + 16px);
    z-index: 54;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--tt-primary);
    color: #fff;
    font-size: 20px;
    box-shadow: 0 4px 16px rgba(26, 86, 167, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.tt-fab[hidden] { display: none !important; }

body.tt-has-selection .tt-fab { display: none; }
body.tt-has-selection .tt-fab[hidden] { display: none !important; }

.tt-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

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

.tt-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
}

.tt-modal-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 20px 16px calc(16px + var(--tt-safe-bottom));
    border-radius: 16px 16px 0 0;
    border: 1px solid var(--tt-border);
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.12);
    background: #fff;
}

.tt-modal-card.is-busy { overflow: hidden; }

.tt-modal-loading {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: inherit;
}

.tt-modal-loading[hidden] { display: none !important; }

.tt-modal-loading-inner {
    text-align: center;
    padding: 24px 20px;
}

.tt-modal-spinner {
    font-size: 28px;
    color: var(--tt-primary);
    margin-bottom: 12px;
}

.tt-modal-loading-text {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--tt-text);
}

.tt-modal-loading-sub {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--tt-text-muted);
}

.tt-modal.is-busy .tt-modal-backdrop {
    pointer-events: none;
}

.tt-btn.is-loading {
    pointer-events: none;
    opacity: 0.85;
}

.tt-modal-card h3 { margin: 0 0 14px; font-size: 17px; }

.tt-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--tt-text-secondary);
    margin: 12px 0 6px;
    text-transform: uppercase;
}

.tt-input-num {
    width: 120px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--tt-border);
    border-radius: 8px;
    font-size: 16px;
}

.tt-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}
.tt-modal-actions .tt-btn { flex: 1; }

.tt-empty-hint {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 13px;
    color: var(--tt-text-muted);
    padding: 14px 10px;
    border: 1px dashed var(--tt-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.68);
}

.tt-empty-hint strong {
    color: var(--tt-text-secondary);
    font-size: 13px;
}

.tt-empty-hint span {
    font-size: 12px;
    line-height: 1.45;
}

.tt-toast {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(var(--tt-safe-bottom) + 12px);
    z-index: 300;
    padding: 12px 16px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--tt-border);
    box-shadow: var(--tt-shadow);
    font-size: 14px;
    text-align: center;
    opacity: 0;
    transform: translateY(12px);
    transition: transform 0.25s, opacity 0.25s;
    pointer-events: none;
}
.tt-toast.show { opacity: 1; transform: translateY(0); }
.tt-toast.ok { border-color: rgba(5, 150, 105, 0.35); color: var(--tt-success); }
.tt-toast.err { border-color: rgba(220, 38, 38, 0.35); color: var(--tt-danger); }

body.tt-has-selection .tt-toast {
    bottom: calc(var(--tt-bar-h) + var(--tt-safe-bottom) + 12px);
}

body:not(.tt-has-selection) .tt-panel--storyline:not(.has-thread) {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 移动端：全屏阅读模式，选中灵感后隐藏 Tab 与列表 */
@media (max-width: 1023px) {
    body.tt-mobile-thread .tt-mobile-tabs {
        display: none;
    }

    body.tt-mobile-thread .tt-panel--list {
        display: none !important;
    }

    body.tt-mobile-thread .tt-panel--storyline.has-thread.is-active {
        display: grid !important;
        grid-template-rows: minmax(0, 1fr) auto;
        flex: 1 1 0;
        min-height: 0;
        height: 100%;
        overflow: hidden;
    }

    .tt-panel--storyline.has-thread:not(.is-active) {
        display: none !important;
    }

    .tt-panel--storyline.has-thread.is-active {
        display: grid !important;
        grid-template-rows: minmax(0, 1fr) auto;
    }

    .tt-thread-head {
        position: sticky;
        top: 0;
        z-index: 5;
        box-shadow: 0 1px 0 var(--tt-border-light);
    }

    .tt-back-btn {
        display: inline-flex !important;
    }
}

@media (min-width: 1024px) {
    body.tt-body {
        padding-bottom: 0;
        height: 100dvh;
        max-height: 100dvh;
    }

    body:not(.tt-has-selection) .tt-shell {
        grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    }

    .tt-header-nav--desktop { display: flex; }
    .tt-page { padding: 12px 20px max(12px, env(safe-area-inset-bottom)); }

    .tt-mobile-tabs { display: none; }
    .tt-fab { display: none !important; }
    .tt-back-btn { display: none !important; }

    .tt-shell {
        display: grid;
        grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
        min-height: 0;
        height: 100%;
    }

    .tt-panel--list { grid-column: 1; }

    .tt-panel--storyline {
        grid-column: 2;
        display: flex !important;
        flex-direction: column;
        min-height: 0;
        height: 100%;
        max-height: 100%;
        overflow: hidden;
        border-left: 1px solid var(--tt-border-light);
    }

    .tt-panel {
        min-height: 0;
    }

    .tt-panel--list {
        display: flex !important;
        flex-direction: column;
        overflow: hidden;
    }

    .tt-sidebar {
        padding: 14px 12px;
        border-right: 1px solid var(--tt-border-light);
    }

    .tt-thesis-item { border-color: transparent; background: transparent; }
    .tt-thesis-item:hover { background: #fff; border-color: var(--tt-border); }

    .tt-thesis-del {
        width: 32px;
        height: 32px;
        opacity: 0;
        background: transparent;
    }
    .tt-thesis-item:hover .tt-thesis-del,
    .tt-thesis-item.active .tt-thesis-del {
        opacity: 1;
        background: var(--tt-danger-light);
    }

    .tt-struct-grid {
        grid-template-columns: 1fr 160px;
    }

    .tt-struct-field--full { grid-column: 1 / -1; }

    .tt-modal {
        align-items: center;
        padding: 20px;
    }

    .tt-modal-card {
        max-width: 480px;
        border-radius: var(--tt-radius);
        max-height: none;
    }

    .tt-toast {
        left: 50%;
        right: auto;
        bottom: 24px;
        transform: translateX(-50%) translateY(60px);
        width: auto;
        max-width: 90%;
    }
    .tt-toast.show { transform: translateX(-50%) translateY(0); }

    body.tt-has-selection .tt-toast { bottom: 24px; }
}

/* ── Storyline timeline UX ── */
.tt-panel--storyline.is-active {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

.tt-panel--storyline {
    min-height: 0;
    overflow: hidden;
}

.tt-panel--storyline:not(.has-thread) .tt-thread-view {
    display: none !important;
}

.tt-panel--storyline.has-thread .tt-welcome--storyline {
    display: none !important;
}

.tt-panel--storyline.has-thread {
    grid-template-rows: minmax(0, 1fr) auto;
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

@media (min-width: 1024px) {
    .tt-panel--storyline.has-thread {
        display: grid !important;
    }
}

.tt-panel--storyline.has-thread .tt-thread-view {
    grid-row: 1;
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.tt-panel--storyline.has-thread .tt-compose-dock {
    grid-row: 2;
    min-height: 0;
    max-height: min(40vh, 320px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.tt-compose-dock[hidden] {
    display: none !important;
}

.tt-compose-dock {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid var(--tt-border-light);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tt-welcome--storyline {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    width: 100%;
}

.tt-welcome--storyline[hidden] {
    display: none !important;
}

.tt-welcome-card {
    text-align: center;
    max-width: 300px;
    padding: 20px 18px;
    border-radius: 14px;
    border: 1px dashed var(--tt-border);
    background: linear-gradient(135deg, #f8fbff 0%, #fff 100%);
    color: var(--tt-text-secondary);
}

.tt-welcome-icon {
    font-size: 28px;
    color: var(--tt-primary);
    opacity: 0.85;
    margin-bottom: 10px;
}

.tt-welcome-title {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 700;
    color: var(--tt-text);
}

.tt-welcome-desc {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--tt-text-secondary);
}

.tt-thread-view {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tt-thread-view[hidden] { display: none !important; }

.tt-thread-top {
    flex: 0 0 auto;
    background: var(--tt-card);
    border-bottom: 1px solid var(--tt-border-light);
    max-height: min(25vh, 180px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.tt-thread-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--tt-border-light);
    background: var(--tt-card);
    flex: 0 0 auto;
}

.tt-thread-head-text {
    flex: 1;
    min-width: 0;
}

.tt-thread-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
    word-break: break-word;
}

.tt-thread-signal {
    font-size: 12px;
    color: var(--tt-text-secondary);
}

.tt-thread-del {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 0 !important;
}

.tt-dashboard {
    padding: 8px 14px 10px;
    background: linear-gradient(180deg, #f8fbff 0%, #fafbfd 100%);
}

.tt-dashboard-summary {
    border: 1px solid var(--tt-border-light);
    border-radius: 10px;
    background: #fff;
    padding: 9px 10px;
    margin-bottom: 8px;
}

.tt-dashboard-summary.ok {
    border-color: rgba(5, 150, 105, 0.22);
    background: linear-gradient(180deg, #ffffff 0%, var(--tt-success-light) 100%);
}

.tt-dashboard-summary.warn,
.tt-dashboard-summary.processing {
    border-color: rgba(217, 119, 6, 0.28);
    background: linear-gradient(180deg, #ffffff 0%, var(--tt-warning-light) 100%);
}

.tt-dashboard-summary.danger {
    border-color: rgba(220, 38, 38, 0.26);
    background: linear-gradient(180deg, #ffffff 0%, var(--tt-danger-light) 100%);
}

.tt-dash-summary-main {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.tt-dash-summary-emoji {
    flex-shrink: 0;
    line-height: 1.4;
}

.tt-dash-summary-text {
    min-width: 0;
    flex: 1;
}

.tt-dash-summary-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--tt-text);
    line-height: 1.35;
}

.tt-dash-summary-reason {
    margin-top: 2px;
    font-size: 12px;
    color: var(--tt-text-secondary);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tt-dash-summary-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 7px;
}

.tt-dash-summary-meta span {
    font-size: 10px;
    font-weight: 700;
    color: var(--tt-text-secondary);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(226, 232, 240, 0.86);
    border-radius: 999px;
    padding: 1px 6px;
}

.tt-dashboard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.tt-dashboard-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--tt-text-secondary);
}

.tt-dashboard-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 28px;
    border: 1px solid var(--tt-border);
    border-radius: 8px;
    background: #fff;
    color: var(--tt-primary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
    cursor: pointer;
}

.tt-dashboard-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tt-dashboard-cards {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tt-dashboard-cards::-webkit-scrollbar { display: none; }

.tt-dashboard-cards .tt-muted {
    font-size: 12px;
    white-space: nowrap;
}

.tt-dash-card {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--tt-border-light);
    background: #fff;
    min-width: 88px;
    flex-shrink: 0;
}

.tt-dash-card.ok { border-color: rgba(5, 150, 105, 0.35); background: var(--tt-success-light); }
.tt-dash-card.warn { border-color: rgba(217, 119, 6, 0.35); background: var(--tt-warning-light); }
.tt-dash-card.bad { border-color: rgba(220, 38, 38, 0.35); background: var(--tt-danger-light); }

.tt-dash-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--tt-text);
}

.tt-dash-code {
    font-size: 11px;
    color: var(--tt-text-muted);
    margin-top: 2px;
}

.tt-dash-status {
    display: inline-block;
    margin-top: 4px;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--tt-text-secondary);
}

.tt-dash-card.ok .tt-dash-status { background: var(--tt-success-light); color: var(--tt-success); }
.tt-dash-card.warn .tt-dash-status { background: var(--tt-warning-light); color: var(--tt-warning); }
.tt-dash-card.bad .tt-dash-status { background: var(--tt-danger-light); color: var(--tt-danger); }

.tt-storyline-feed {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    overflow-anchor: none;
    background: var(--tt-bg);
    scroll-padding-top: 12px;
    scroll-padding-bottom: 24px;
}

.tt-storyline-feed.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

.tt-bubble {
    max-width: 92%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    flex-shrink: 0;
}

.tt-bubble--user {
    align-self: flex-end;
    background: var(--tt-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.tt-bubble--ai {
    align-self: flex-start;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    background: #fff;
    border: 1px solid var(--tt-border-light);
    border-bottom-left-radius: 4px;
    color: var(--tt-text);
}

.tt-bubble-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--tt-primary-light);
    color: var(--tt-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.tt-bubble-label {
    font-size: 10px;
    font-weight: 700;
    opacity: 0.85;
    margin-bottom: 4px;
}

.tt-bubble-text { white-space: pre-wrap; word-break: break-word; }

.tt-bubble-time {
    font-size: 11px;
    opacity: 0.75;
    margin-top: 6px;
}

.tt-feed-log {
    align-self: center;
    font-size: 12px;
    color: var(--tt-text-muted);
    padding: 4px 12px;
    flex-shrink: 0;
}

.tt-feed-alert {
    align-self: stretch;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #fbbf24;
    background: #fffbeb;
    color: #92400e;
    flex-shrink: 0;
}

.tt-feed-alert.alert-warn {
    border-color: #fbbf24;
    background: #fffbeb;
    color: #92400e;
}

.tt-feed-alert.alert-danger {
    border-color: #f87171;
    background: #fef2f2;
    color: #991b1b;
}

.tt-feed-alert-text { white-space: pre-wrap; word-break: break-word; }

.tt-thread-compose {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
}

.tt-thread-input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    border: 1px solid var(--tt-border);
    border-radius: 10px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    background: #fafbfd;
    max-height: 120px;
}

.tt-thread-input:focus {
    border-color: var(--tt-primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 167, 0.12);
}

.tt-thread-hint {
    margin: 0;
    padding: 0 14px 8px;
    font-size: 10px;
    color: var(--tt-text-muted);
    background: #fff;
}

.tt-compose-dock .tt-advanced-panel {
    padding: 0 14px 10px;
    background: #fff;
    max-height: none;
    overflow: visible;
}

.tt-advanced-panel summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--tt-text-secondary);
    padding: 10px 0;
}

.tt-track-dot {
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1.35;
}

.tt-list-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.tt-list-tag {
    font-size: 10px;
    font-weight: 600;
    color: var(--tt-primary);
    background: var(--tt-primary-light);
    padding: 1px 6px;
    border-radius: 4px;
}

.tt-schedule-panel--inline {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--tt-border);
}

.tt-schedule-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--tt-text-secondary);
    cursor: pointer;
}

.tt-schedule-meta {
    margin: 6px 0 0;
    font-size: 11px;
    color: var(--tt-text-muted);
}

.tt-struct-card--inline {
    margin-top: 8px;
}

.tt-list-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--tt-text-muted);
    margin-left: 6px;
}

.tt-list-skeleton {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tt-thesis-item--skeleton {
    pointer-events: none;
    border-color: var(--tt-border-light);
    background: linear-gradient(90deg, #f1f5f9 0%, #fafbfd 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    animation: tt-skeleton-shimmer 1.2s ease-in-out infinite;
    min-height: 56px;
}

@keyframes tt-skeleton-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
