/* ================================================================
 * GTX unified theme
 * One quiet visual system for the terminal, agent, settings and boards.
 * Loaded last so feature styles keep their layout while sharing one finish.
 * ============================================================== */

:root {
    --bg-page:        #f4f7fc;
    --bg-card:        #ffffff;
    --bg-input:       #f5f6f8;
    --bg-hover:       #eef1f6;
    --border:         #e8ebf1;
    --border-strong:  #d8dde7;
    --text-primary:   #151824;
    --text-secondary: #667085;
    --text-muted:     #98a2b3;
    --accent-blue:    #5968ef;
    --accent-green:   #18a66a;
    --accent-red:     #e05260;
    --accent-amber:   #d99022;
    --accent-purple:  #765be9;
    --radius-lg:      14px;
    --radius-md:      10px;
    --radius-sm:      7px;
    --shadow-card:    0 1px 2px rgba(38, 51, 91, 0.022),
                      0 5px 14px rgba(48, 61, 112, 0.036);
    --shadow-press:   0 3px 9px rgba(16, 24, 40, 0.045);
    --focus-ring:     0 0 0 3px rgba(89, 104, 239, 0.12);

    --agent-grad-a:   #5968ef;
    --agent-grad-b:   #765be9;
    --agent-hairline: rgba(21, 24, 36, 0.075);
    --agent-bar-bg:   var(--bg-page);
}

html {
    background: var(--bg-page);
}

body {
    min-width: 320px;
    position: relative;
    overflow-x: hidden;
    background: var(--bg-page);
    letter-spacing: -0.005em;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

.app {
    background: var(--bg-page);
}

/* ---------- Navigation and product identity ---------- */

.nav-bar {
    min-height: 60px;
    padding: 12px 16px;
    border-bottom: none;
    background: rgba(255, 255, 255, 0.34);
    box-shadow: 0 8px 28px rgba(48, 61, 112, 0.025);
    backdrop-filter: blur(18px) saturate(145%);
    -webkit-backdrop-filter: blur(18px) saturate(145%);
}

.nav-back {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.58);
    box-shadow: 0 4px 14px rgba(48, 61, 112, 0.065);
    color: var(--text-secondary);
    font-size: 0;
}

.nav-back::before {
    content: "‹";
    display: block;
    font-family: Arial, sans-serif;
    font-size: 25px;
    font-weight: 300;
    line-height: 1;
    transform: translateY(-1px);
}

.nav-back:active {
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 2px 8px rgba(48, 61, 112, 0.06);
    transform: scale(0.96);
}

.nav-title {
    margin-left: 6px;
    font-size: 15px;
    font-weight: 720;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.home-masthead {
    min-height: 58px;
    padding: 17px 18px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.home-wordmark {
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.055em;
}

.home-product {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    line-height: 12px;
    letter-spacing: 0.12em;
}

.home-product i {
    display: block;
    flex: 0 0 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-red);
    box-shadow: 0 0 0 4px rgba(224, 82, 96, 0.09);
}

.home-product.connected i {
    background: var(--accent-green);
    box-shadow: 0 0 0 4px rgba(24, 166, 106, 0.09);
}

.home-product.connecting {
    color: var(--accent-amber);
}

.home-product.connecting i {
    background: var(--accent-amber);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14);
    animation: connection-breathe 1.6s ease-in-out infinite;
}

@keyframes connection-breathe {
    0%, 100% {
        opacity: 0.55;
        transform: scale(0.78);
        box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.10);
    }
    50% {
        opacity: 1;
        transform: scale(1.28);
        box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.18);
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-product.connecting i {
        animation: none;
    }
}

.home-product span {
    display: block;
    line-height: 12px;
}

/* ---------- Shared surface language ---------- */

.user-card,
.quick-task-card,
.agent-entry-card,
.list-card,
.settings-user,
.settings-card,
.status-card,
.actions-card,
.form-card,
.chart-card,
.app-download-entry,
.cohort-filter-panel,
.cohort-funnel,
.cohort-grp,
.agent-quote-card,
.agent-delegate-card,
.agent-card {
    border: none;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
}

.user-card,
.quick-task-card,
.agent-entry-card,
.settings-user,
.app-download-entry {
    transition: transform 0.16s ease, border-color 0.16s ease,
                background 0.16s ease, box-shadow 0.16s ease;
}

.quick-task-card:active,
.agent-entry-card:active,
.settings-user:active,
.app-download-entry:active {
    transform: scale(0.992);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-press);
}

.user-card {
    margin-top: 4px;
    padding: 14px;
}

.user-status {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.02em;
}

.user-status.connected { color: var(--accent-green); }
.user-status.connecting { color: var(--accent-amber); }
.user-status.disconnected { color: var(--accent-red); }
.user-status.paused { color: var(--text-muted); }

.user-avatar {
    background: linear-gradient(145deg, #6875ef, #7157d9);
    box-shadow: 0 5px 14px rgba(89, 104, 239, 0.16);
}

.toggle-track {
    width: 40px;
    height: 24px;
    border-radius: 12px;
    background: var(--border-strong);
}

.toggle-track.on {
    background: var(--accent-blue);
}

.toggle-thumb {
    width: 20px;
    height: 20px;
    box-shadow: 0 1px 4px rgba(16, 24, 40, 0.18);
}

.toggle-track.on .toggle-thumb {
    left: 18px;
}

.quick-task-card,
.agent-entry-card {
    padding: 13px 14px;
}

.quick-task-label,
.agent-entry-label {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.11em;
}

.quick-task-value,
.agent-entry-value {
    font-size: 14px;
    font-weight: 620;
}

.quick-task-btn {
    min-width: 58px;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    background: var(--accent-blue);
    box-shadow: 0 4px 12px rgba(89, 104, 239, 0.16);
}

.agent-entry-arrow {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--bg-input);
    font-size: 16px;
}

.section-label {
    padding: 2px 20px 8px;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: -0.01em;
}

/* 所有子页面统一留出“导航栏 → 首个内容标题”的垂直节奏。 */
.nav-bar + .section-label {
    padding-top: 14px;
}

#page-search > .search-page-header + .section-label {
    padding-top: 14px;
}

.nav-bar + .settings-user {
    margin-top: 14px;
}

.section-sub {
    font-size: 10px;
    font-weight: 500;
}

.list-row {
    padding: 12px 14px;
    border-bottom-color: var(--border);
}

.row-title {
    font-size: 14px;
    font-weight: 620;
}

.row-meta {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 10px;
}

.candidate-rank,
.oi-rank-badge {
    border: 1px solid rgba(89, 104, 239, 0.1);
    background: rgba(89, 104, 239, 0.07);
    color: var(--accent-blue);
}

.empty-state {
    padding: 34px 20px;
    color: var(--text-muted);
}

/* ---------- Inputs and actions ---------- */

.form-card {
    padding: 15px;
}

.form-label {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
}

.form-input,
.settings-row input[type=number],
.settings-row input[type=text],
.settings-row select {
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    transition: border-color 0.16s ease, background 0.16s ease,
                box-shadow 0.16s ease;
}

.form-input:focus,
.settings-row input:focus,
.settings-row select:focus {
    border-color: rgba(89, 104, 239, 0.42);
    background: var(--bg-card);
    box-shadow: var(--focus-ring);
}

.save-btn,
.cohort-at-btn,
.agent-send-btn {
    background: var(--accent-blue);
    box-shadow: 0 5px 14px rgba(89, 104, 239, 0.16);
}

.save-btn {
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 650;
}

.save-btn.secondary {
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
}

.action-btn {
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 650;
}

.btn-long {
    background: #168a5b;
}

.btn-short {
    background: #d84c5a;
}

.chart-refresh-btn,
.task-detail-close {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
}

/* ---------- Settings ---------- */

.settings-hint {
    padding: 1px 21px 8px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.06em;
}

.nav-bar + .settings-hint {
    padding-top: 14px;
    padding-bottom: 9px;
}

.settings-user {
    padding: 15px;
}

.settings-card {
    margin-bottom: 16px;
}

.settings-row {
    min-height: 54px;
    padding: 13px 14px;
}

.settings-row-title {
    font-size: 14px;
    font-weight: 550;
}

.settings-row-sub {
    font-size: 11px;
}

.status-card {
    padding: 15px 8px;
}

.status-item + .status-item {
    border-left: 1px solid var(--border);
}

.status-item-label {
    font-family: var(--font-mono);
    font-size: 9px;
}

.app-download-entry {
    min-height: 72px;
    background: var(--bg-card);
}

.app-download-logo {
    border-radius: 12px;
    box-shadow: 0 5px 14px rgba(89, 104, 239, 0.16);
}

.app-download-action {
    color: var(--accent-blue);
}

.app-download-action b {
    background: rgba(89, 104, 239, 0.08);
}

/* ---------- Search ---------- */

.search-trigger,
.search-input-wrap {
    border: none;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
}

.search-page-header {
    border-bottom: none;
    background: rgba(255, 255, 255, 0.34);
    backdrop-filter: blur(18px) saturate(145%);
    -webkit-backdrop-filter: blur(18px) saturate(145%);
}

.search-input-wrap:focus-within {
    border-color: rgba(89, 104, 239, 0.38);
    box-shadow: var(--focus-ring);
}

/* ---------- Cohort board: same surface as every other list ---------- */

#page-cohort .nav-bar {
    padding-bottom: 10px;
}

.cohort-search-bar {
    padding-top: 12px;
    background: rgba(247, 248, 252, 0.72);
    backdrop-filter: blur(16px) saturate(135%);
    -webkit-backdrop-filter: blur(16px) saturate(135%);
}

.cohort-filter-panel {
    padding: 3px;
    box-shadow: var(--shadow-card);
}

.cohort-search-box,
.cohort-time-box {
    border-radius: 10px;
}

.cohort-search-box:focus-within,
.cohort-time-box:focus-within {
    background: rgba(89, 104, 239, 0.045);
    box-shadow: inset 0 0 0 1px rgba(89, 104, 239, 0.16);
}

.cohort-field-icon {
    background: transparent;
}

.cohort-time-label {
    background: rgba(89, 104, 239, 0.08);
    color: var(--accent-blue);
}

.cohort-at-btn,
.cohort-at-now {
    border-radius: 8px;
}

.cohort-capsule,
.nexus-capsule {
    border-color: var(--border);
    background: var(--bg-card);
    box-shadow: none;
}

.cohort-funnel,
.cohort-grp {
    border: none;
    border-radius: var(--radius-lg);
}

.cohort-grp-bar {
    border-radius: var(--radius-lg);
}

.cohort-grp.open > .cohort-grp-bar {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.cohort-detail {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.cohort-fn-track {
    background: var(--bg-input);
}

.cohort-fn-track i {
    background: rgba(89, 104, 239, 0.82);
}

/* ---------- Agent and timeline ---------- */

#page-agent .nav-bar {
    border-bottom: none;
}

.agent-feed {
    padding-top: 18px;
}

.agent-msg-content {
    color: var(--text-primary);
}

.agent-msg-content.auto {
    color: var(--text-secondary);
}

.agent-quote-card,
.agent-delegate-card,
.agent-card {
    box-shadow: none;
}

.agent-input-bar {
    border-top-color: var(--border);
    background: rgba(245, 247, 251, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.agent-input-capsule {
    border-color: var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
}

.agent-input-capsule:focus-within {
    border-color: rgba(89, 104, 239, 0.34);
    box-shadow: var(--focus-ring);
}

.agent-msg-user-bubble {
    background: var(--accent-blue);
    box-shadow: 0 3px 12px rgba(89, 104, 239, 0.16);
}

.nexus-mask,
.confirm-mask {
    background: rgba(21, 24, 36, 0.42);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.nexus-sheet,
.confirm-box {
    border: none;
    background: var(--bg-card);
    box-shadow: 0 24px 70px rgba(21, 24, 36, 0.16);
}

.confirm-title {
    color: var(--text-primary);
}

.confirm-msg {
    color: var(--text-secondary);
}

.confirm-btn-cancel {
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
}

.confirm-btn-ok {
    background: var(--accent-red);
}

.toast {
    border-radius: 12px;
    box-shadow: none;
}

.toast.show {
    box-shadow: 0 6px 18px rgba(21, 24, 36, 0.16);
}

/* ---------- Login ---------- */

.login-page {
    background: var(--bg-page);
}

.login-card {
    padding: 34px 25px 26px;
    border: none;
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(21, 24, 36, 0.08);
}

.login-title {
    color: var(--text-primary);
    font-size: 32px;
    font-weight: 820;
    letter-spacing: -0.065em;
}

.login-sub {
    margin-top: 2px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.12em;
}

@media (min-width: 520px) {
    .app {
        box-shadow: 0 0 60px rgba(48, 61, 112, 0.045);
    }
}

@media (prefers-reduced-motion: reduce) {
    .user-card,
    .quick-task-card,
    .agent-entry-card,
    .settings-user,
    .app-download-entry {
        transition: none;
    }
}
