/* ── Design System ── */
:root {
    --bg: #0a0a0f;
    --surface: #111118;
    --surface-hover: #1a1a28;
    --border: #1e1e2e;
    --border-light: #2a2a3a;
    --text: #c8c8d4;
    --text-dim: #6b6b7b;
    --text-bright: #ffffff;
    --gold: #c9a84c;
    --gold-dim: #8b7330;
    --gold-glow: rgba(201, 168, 76, 0.08);
    --blue: #3b6fb6;
    --blue-dim: #2a4d7a;
    --max-w: 800px;
    --radius: 10px;
    --radius-sm: 6px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

/* ── Navigation ── */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    background: rgba(10, 10, 15, 0.85);
    border-bottom: 1px solid var(--border);
}
.nav-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
}
.logo {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-bright);
}
.logo span { color: var(--gold); }
.nav-links { display: flex; gap: 24px; }
.nav-links a {
    font-size: 13px;
    color: var(--text-dim);
    transition: color 0.2s;
}
.nav-links a:hover { color: var(--gold); }
.nav-links a.active { color: var(--text-bright); }

/* ── Main ── */
.main {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 100px 24px 60px;
}

/* ── Sections ── */
.section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--gold-dim);
    margin-bottom: 8px;
}
.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Hero / Today's Brief ── */
.hero {
    text-align: center;
    padding: 40px 0 32px;
}
.hero .date-badge {
    font-size: 11px;
    letter-spacing: 3px;
    color: var(--gold);
    margin-bottom: 16px;
}
.hero h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1.3;
    margin-bottom: 12px;
}
.hero .sub {
    font-size: 15px;
    color: var(--text-dim);
    max-width: 500px;
    margin: 0 auto;
}
.hero .route-info {
    display: inline-block;
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-dim);
    background: var(--surface);
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* ── Brief Card (main idea) ── */
.brief-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
}
.brief-card.glow {
    border-color: var(--gold-dim);
    box-shadow: 0 0 40px var(--gold-glow);
}
.brief-card h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 8px;
}
.brief-card .tagline {
    font-size: 14px;
    color: var(--gold);
    margin-bottom: 20px;
}
.brief-card .section-block {
    margin-bottom: 20px;
}
.brief-card .section-block:last-child {
    margin-bottom: 0;
}
.brief-card .block-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.brief-card .block-content {
    font-size: 14px;
    color: var(--text);
    line-height: 1.8;
}

/* ── Factor tags ── */
.factor-tag {
    display: inline-block;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 4px;
    background: rgba(201, 168, 76, 0.1);
    color: var(--gold);
    border: 1px solid rgba(201, 168, 76, 0.2);
    margin: 2px 4px 2px 0;
}

/* ── Signals / Sources ── */
.signals-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}
.signals-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.signal-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.6;
}
.signal-item:last-child { border-bottom: none; }
.signal-source {
    flex-shrink: 0;
    font-size: 10px;
    background: var(--gold-dim);
    color: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    height: fit-content;
    margin-top: 2px;
}
.signal-text { color: var(--text); }
.signal-link {
    color: var(--blue);
    font-size: 12px;
    word-break: break-all;
}
.signal-link:hover { text-decoration: underline; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 100px 20px;
}
.empty-state .big-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h2 { font-size: 18px; color: var(--text-bright); margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text-dim); }

/* ── Button ── */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    border: none;
    font-family: inherit;
}
.btn-primary {
    background: var(--gold);
    color: #0a0a0f;
}
.btn-primary:hover {
    background: #dab860;
    transform: translateY(-1px);
}
.btn-outline {
    border: 1px solid var(--border);
    color: var(--text);
    background: transparent;
}
.btn-outline:hover {
    border-color: var(--gold);
    color: var(--gold);
}
.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

/* ── Two column info ── */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}
.info-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
}
.info-item .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.info-item .value {
    font-size: 14px;
    color: var(--text-bright);
    font-weight: 600;
}

/* ── History ── */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-size: 14px;
}
.history-item:hover {
    border-color: var(--gold-dim);
    background: var(--surface-hover);
}
.history-date {
    font-size: 13px;
    color: var(--gold);
    min-width: 90px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.history-preview {
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.history-arrow {
    color: var(--text-dim);
    font-size: 14px;
}

/* ── Factor Grid ── */
.factor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.factor-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    transition: all 0.2s;
}
.factor-card:hover {
    border-color: var(--gold-dim);
}
.factor-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.factor-id {
    font-size: 10px;
    color: var(--gold);
    background: rgba(201, 168, 76, 0.1);
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.factor-strength { font-size: 12px; }
.factor-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-bright);
    margin-bottom: 4px;
}
.factor-fatigue {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
}
.fatigue-bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}
.fatigue-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--gold);
}

/* ── Stats ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
}
.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gold);
}
.stat-label {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
    letter-spacing: 0.5px;
}

/* ── Decision Log ── */
.decision-log {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.8;
}
.decision-date { font-weight: 600; color: var(--gold); }
.decision-route { color: var(--text); }
.decision-signals { color: var(--text-dim); font-size: 12px; }
.decision-factors { color: var(--text-dim); font-size: 12px; }

/* ── Scan Results ── */
.scan-list { display: flex; flex-direction: column; gap: 10px; }
.scan-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
}
.scan-header {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.scan-source { font-weight: 600; color: var(--text-bright); font-size: 14px; }
.scan-time { color: var(--text-dim); font-size: 11px; }
.scan-count {
    font-size: 11px;
    color: var(--gold);
    margin-left: auto;
    background: rgba(201, 168, 76, 0.1);
    padding: 2px 8px;
    border-radius: 3px;
}
.scan-results { list-style: none; }
.scan-results li {
    font-size: 12px;
    color: var(--text-dim);
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
}
.scan-results li:last-child { border-bottom: none; }

/* ── Auth / Forms ── */
.auth-box {
    max-width: 380px;
    margin: 60px auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
}
.auth-box h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 8px;
    text-align: center;
}
.auth-sub {
    font-size: 13px;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.6;
}
.auth-box input[type="text"],
.auth-box input[type="email"],
.auth-box input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.auth-box input:focus {
    border-color: var(--gold-dim);
}
.auth-box .btn {
    margin-top: 4px;
}
.auth-success {
    background: rgba(70, 255, 70, 0.1);
    border: 1px solid rgba(70, 255, 70, 0.2);
    color: #66ff66;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    text-align: center;
}
.auth-error {
    background: rgba(255, 70, 70, 0.1);
    border: 1px solid rgba(255, 70, 70, 0.2);
    color: #ff6666;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    text-align: center;
}
.auth-footer {
    text-align: center;
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 20px;
}
.auth-footer a {
    color: var(--gold);
}
.auth-footer a:hover {
    text-decoration: underline;
}
.nav-user {
    font-size: 12px;
    color: var(--gold-dim);
    padding: 0 4px;
}
.nav-logout {
    font-size: 12px !important;
}

/* ── Preview idea list (guest homepage) ── */
.preview-idea {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.preview-idea:last-child {
    border-bottom: none;
}
.preview-idea-num {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}
.preview-idea-body {
    flex: 1;
}
.preview-idea-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 2px;
}
.preview-idea-tagline {
    font-size: 13px;
    color: var(--text-dim);
}

/* ── Scan Center ── */
.scan-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}
.scan-config {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.scan-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.scan-config-header h3 {
    font-size: 16px;
    color: var(--text-bright);
    font-weight: 600;
}
.select-all-label {
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}
.select-all-label input { accent-color: var(--gold); }

.source-group {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.source-group-header {
    background: var(--bg);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.cat-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-bright);
    font-weight: 600;
}
.cat-toggle input { accent-color: var(--gold); }
.source-count {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 400;
    margin-left: auto;
}
.source-items {
    padding: 4px 0;
}
.source-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
}
.source-item:hover { background: var(--surface-hover); }
.source-item input { accent-color: var(--gold); margin-top: 2px; }
.source-name { color: var(--text); white-space: nowrap; }
.source-note { color: var(--text-dim); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scan-btn {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    font-size: 15px;
}

/* Scan results panel */
.scan-results-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-height: 80vh;
    overflow-y: auto;
}
.scan-results-panel h3 {
    font-size: 16px;
    color: var(--text-bright);
    font-weight: 600;
    margin-bottom: 16px;
}
.result-group { margin-bottom: 20px; }
.result-group-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.result-item {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    background: var(--bg);
}
.result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.result-source { font-size: 12px; color: var(--text-bright); font-weight: 600; }
.result-time { font-size: 10px; color: var(--text-dim); margin-left: auto; }
.result-count { font-size: 11px; color: var(--text-dim); }
.result-count.has-new { color: var(--gold); }
.new-badge {
    display: inline-block;
    font-size: 10px;
    background: rgba(201, 168, 76, 0.15);
    color: var(--gold);
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 4px;
}
.result-list { list-style: none; margin-top: 4px; }
.result-list li {
    font-size: 12px;
    color: var(--text-dim);
    padding: 3px 0;
    line-height: 1.5;
}
.result-link { color: var(--blue); }
.result-link:hover { text-decoration: underline; }
.result-snippet { font-size: 11px; color: var(--text-dim); opacity: 0.7; }
.result-more { font-size: 11px; color: var(--gold-dim); margin-top: 4px; }
.result-empty { font-size: 12px; color: var(--text-dim); padding: 8px 0; }
.result-empty-state { text-align: center; padding: 40px 20px; color: var(--text-dim); font-size: 13px; }

/* Scan overlay */
.scan-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.scan-overlay.active { display: flex; }
.scan-overlay-content { text-align: center; }
.scan-overlay-content h2 { color: var(--text-bright); margin-top: 24px; font-size: 20px; }
.scan-status { color: var(--text-dim); margin-top: 8px; font-size: 14px; }
.scan-hint { color: var(--text-dim); font-size: 12px; margin-top: 16px; opacity: 0.6; }
.scan-progress { width: 240px; margin: 20px auto 0; }
.scan-progress-bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    animation: scanProgress 8s ease-in-out infinite;
}
@keyframes scanProgress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 95%; }
}

/* Scan running page */
.scan-run-container {
    text-align: center;
    padding: 60px 24px;
}
.scan-run-messages {
    margin-top: 24px;
    min-height: 100px;
}
.scan-run-messages .msg {
    font-size: 14px;
    color: var(--text);
    margin: 8px 0;
    transition: opacity 0.6s;
}
.scan-progress-bar-wrap {
    width: 300px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 24px auto 0;
    overflow: hidden;
}
.scan-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--gold-dim), var(--gold));
    border-radius: 2px;
}
.scan-run-hint {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-dim);
}

/* Loader */
.scan-loader { position: relative; width: 60px; height: 60px; margin: 0 auto; }
.loader-ring {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}
.loader-ring.inner {
    inset: 8px;
    border-top-color: var(--gold-dim);
    animation-duration: 0.8s;
    animation-direction: reverse;
}
.scan-loader-big { position: relative; width: 80px; height: 80px; margin: 0 auto; }
.loader-ring-big {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}
.loader-ring-big.inner {
    inset: 12px;
    border-top-color: var(--gold-dim);
    animation-duration: 0.8s;
    animation-direction: reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 600px) {
    .main { padding: 80px 16px 40px; }
    .info-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .factor-grid { grid-template-columns: repeat(2, 1fr); }
    .brief-card { padding: 20px; }
    .hero h1 { font-size: 22px; }
    .nav-inner { padding: 12px 16px; }
    .nav-links { gap: 16px; }
    .scan-layout { grid-template-columns: 1fr; }
    .scan-progress-bar-wrap { width: 100%; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
