:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #14213d;
  --muted: #61718a;
  --line: #e2e8f0;
  --line-strong: #c8d3e1;
  --brand: #1e3a5f;
  --brand-soft: #eef4fb;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #e8f0fe;
  --amber: #a16207;
  --amber-soft: #fff4df;
  --danger: #dc2626;
  --radius: 14px;
  --sidebar: 238px;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: var(--sidebar);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 22px 14px 18px;
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 22px; color: var(--ink); }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 19px; letter-spacing: 0.04em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.nav-list { display: grid; gap: 3px; }
.nav-item {
  display: flex; width: 100%; min-height: 40px; align-items: center; gap: 10px;
  border: 0; border-radius: 10px; background: transparent; padding: 9px 10px;
  color: var(--muted); font-size: 13px; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-icon { display: grid; width: 25px; height: 25px; place-items: center; border: 1px solid var(--line); border-radius: 7px; color: var(--accent); font-size: 11px; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 16px 8px 0; color: var(--muted); font-size: 11px; }
.sidebar-foot p { margin: 8px 0 0; }
.ai-status { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.ai-status.is-ready .status-dot { background: var(--accent); }

.main-shell { width: calc(100% - var(--sidebar)); min-height: 100vh; margin-left: var(--sidebar); padding: 28px clamp(20px, 4vw, 56px) 90px; }

.topbar { display: flex; max-width: 1360px; align-items: center; justify-content: space-between; gap: 22px; margin: 0 auto 22px; }
.eyebrow { margin: 0; color: var(--accent-strong); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; font-weight: 700; letter-spacing: 0.14em; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { color: var(--ink); letter-spacing: -0.02em; }
h1 { margin: 7px 0 0; font-size: clamp(26px, 3vw, 38px); font-family: Georgia, "Songti SC", serif; }

.top-actions { display: flex; align-items: center; gap: 9px; }
.auth-button { display: inline-flex; min-height: 38px; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 8px 12px; color: var(--ink); font-size: 12px; }
.auth-button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }

.search-box { display: flex; width: min(400px, 36vw); align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); padding: 0 12px; color: var(--muted); font-size: 11px; }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; padding: 11px 0; color: var(--ink); font-size: 14px; }
.icon-button { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.icon-button:hover { border-color: var(--accent); color: var(--accent); }

.home-hero { display: grid; max-width: 1360px; grid-template-columns: minmax(0, 1.25fr) minmax(310px, 0.75fr); gap: 20px; margin: 0 auto 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(120deg, #eef4fb, #ffffff 48%); padding: clamp(22px, 4vw, 44px); }
.hero-copy h2 { margin: 13px 0 12px; font-size: clamp(30px, 4.6vw, 58px); line-height: 1.06; font-family: Georgia, "Songti SC", serif; }
.hero-copy h2 span { color: var(--accent-strong); }
.hero-copy > p:last-child { max-width: 680px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
.hero-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; align-self: end; }
.metric { min-height: 96px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric span { font-size: 11px; }
.metric strong { display: block; margin: 9px 0 3px; font-family: ui-monospace, Menlo, monospace; font-size: 26px; }
.metric small { font-size: 10px; }

.toolbar, .content-section, .import-section { max-width: 1360px; margin-right: auto; margin-left: auto; }
.toolbar { display: flex; align-items: center; gap: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 0; }
.category-scroll { display: flex; min-width: 0; flex: 1; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.category-scroll::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 7px 12px; color: var(--muted); font-size: 12px; }
.chip:hover, .chip.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.checkbox { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }

.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 26px 0 15px; }
.section-heading h2 { margin: 7px 0 0; font-size: 23px; }
.result-count { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 11px; }

.feed-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; }
.feed-list { display: grid; gap: 10px; }
.feed-card { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 17px; cursor: pointer; transition: border-color 160ms ease, transform 160ms ease; }
.feed-card:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.feed-card.is-unread { border-left: 3px solid var(--accent); }
.feed-card h3 { margin: 8px 0 8px; font-size: 17px; line-height: 1.45; }
.feed-card p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--muted); font-size: 13px; line-height: 1.7; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

.card-topline, .card-footer, .reader-meta, .reader-tags, .reader-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.category-label { border: 1px solid #dbeafe; border-radius: 6px; background: var(--accent-soft); padding: 3px 7px; color: var(--accent-strong); font-size: 10px; }
.access-label { border-radius: 6px; padding: 3px 7px; font-size: 10px; }
.access-label.free { background: #ecfdf5; color: #047857; }
.access-label.member { background: var(--amber-soft); color: #92400e; }
.access-label.groupbuy { background: #fdf2f8; color: #be185d; }
.source-label, .time-label { color: var(--muted); font-size: 10px; }
.tag { border-radius: 999px; background: var(--surface-2); padding: 4px 8px; color: #52657f; font-size: 10px; }
.symbol-label { color: var(--brand); font-size: 10px; font-weight: 600; }
.symbol-tag { border-radius: 7px; background: var(--brand-soft); padding: 4px 7px; color: var(--brand); font-size: 10px; font-weight: 600; }
.card-footer { margin-top: 12px; }

.star-button { align-self: start; border: 1px solid var(--line); border-radius: 9px; background: transparent; padding: 7px 9px; color: var(--muted); }
.star-button.is-starred { border-color: #f3c26b; background: var(--amber-soft); color: var(--amber); }

.insight-rail { display: grid; align-content: start; gap: 10px; }
.rail-card, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px; }
.rail-card h3, .panel h3 { margin: 9px 0; font-size: 16px; }
.rail-card p, .rail-card li, .panel p, .panel small { color: var(--muted); font-size: 12px; line-height: 1.7; }
.rail-card ol { margin: 11px 0; padding-left: 18px; }
.text-button { border: 0; background: none; padding: 0; color: var(--accent); font-size: 12px; }
.category-summary { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.category-summary button { border: 1px solid var(--line); border-radius: 8px; background: transparent; padding: 6px 8px; color: var(--muted); font-size: 10px; }

.empty-state { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 46px 24px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--ink); font-size: 17px; }

.import-grid, .pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.panel { position: relative; padding: 22px; }
.panel-number { color: var(--accent-strong); font-family: ui-monospace, Menlo, monospace; font-size: 11px; }

.pricing-card { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); padding: 24px; }
.pricing-card.featured { border-color: var(--accent); box-shadow: 0 10px 30px rgba(37, 99, 235, 0.1); }
.mt-14 { margin-top: 14px; }
.mb-8 { margin-bottom: 8px; }
.price { margin: 18px 0 4px; font-size: 34px; font-weight: 700; font-family: Georgia, "Songti SC", serif; }
.price small { font-size: 14px; color: var(--muted); }
.feature-list { margin: 18px 0; padding: 0; list-style: none; color: var(--muted); font-size: 13px; }
.feature-list li { padding: 6px 0 6px 20px; position: relative; }
.feature-list li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }

.button, .file-button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px; font-size: 12px; font-weight: 600; cursor: pointer; }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button.secondary, .file-button { background: var(--surface); color: var(--ink); }
.button.secondary:hover, .file-button:hover { border-color: var(--accent); color: var(--accent); }
.button:disabled { opacity: 0.55; cursor: default; }
.panel > .button, .panel > .file-button { margin: 8px 6px 8px 0; }
.panel > small { display: block; margin-top: 10px; }

.stack-form { display: grid; gap: 12px; }
.stack-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.stack-form input, .stack-form textarea, .stack-form select { width: 100%; border: 1px solid var(--line); border-radius: 9px; outline: 0; background: #fff; padding: 10px 11px; color: var(--ink); resize: vertical; }
.stack-form input:focus, .stack-form textarea:focus, .stack-form select:focus { border-color: var(--accent); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-status { min-height: 18px; color: var(--muted); font-size: 12px; }

.reader-dialog, .category-dialog, .auth-dialog { border: 1px solid var(--line-strong); border-radius: 18px; background: var(--surface); padding: 0; color: var(--ink); }
.reader-dialog { width: min(860px, calc(100vw - 36px)); max-height: calc(100vh - 36px); }
.category-dialog, .auth-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.reader-dialog::backdrop, .category-dialog::backdrop, .auth-dialog::backdrop { background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px); }
.reader-shell { max-height: calc(100vh - 38px); overflow-y: auto; }

.reader-head, .category-dialog-head, .auth-dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.96); padding: 15px 20px; backdrop-filter: blur(10px); }
.reader-close { width: 48px; height: 48px; font-size: 24px; }
.reader-mobile-close { display: none; }
.reader-source { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.reader-content { padding: clamp(20px, 5vw, 46px); }
.reader-content h2 { margin: 0 0 13px; font-size: clamp(25px, 4.5vw, 40px); line-height: 1.28; font-family: Georgia, "Songti SC", serif; }
.reader-meta { color: var(--muted); font-size: 11px; }
.reader-tags { margin: 14px 0 22px; }
.reader-body { color: #334155; font-size: 15px; line-height: 1.95; white-space: pre-wrap; }
.reader-images { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-top: 22px; }
.reader-images img { width: 100%; max-height: 420px; border-radius: 10px; object-fit: cover; }
.reader-stats { margin-top: 22px; }
.reader-stats .admin-table th, .reader-stats .admin-table td { background: #fff; }
.reader-actions { margin: 26px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 15px 0; }

.analysis-panel { border: 1px solid #dbeafe; border-radius: 13px; background: #f8fbff; padding: 17px; }
.analysis-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.analysis-head h3 { margin: 6px 0 0; }
.analysis-model { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 10px; }
.analysis-output { margin-top: 15px; color: #334155; font-size: 13px; line-height: 1.9; white-space: pre-wrap; }
.manual-analysis { display: grid; gap: 8px; margin-top: 16px; border-top: 1px solid #dbeafe; padding-top: 14px; }
.manual-analysis label { color: var(--muted); font-size: 11px; line-height: 1.6; }
.manual-analysis textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 10px; color: var(--ink); resize: vertical; }
.manual-analysis .button { justify-self: start; }
.edit-panel { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 18px; }
.edit-panel summary { color: var(--muted); font-size: 12px; cursor: pointer; }
.edit-panel .stack-form { margin-top: 14px; }

.category-note { margin: 15px 20px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.category-groups { display: grid; gap: 20px; max-height: calc(100vh - 140px); overflow-y: auto; padding: 18px 20px 22px; }
.category-group h3 { margin: 0 0 9px; color: var(--muted); font-size: 12px; }
.category-group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 7px; }
.category-group-grid button { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 9px 10px; color: var(--ink); font-size: 11px; text-align: left; }
.category-group-grid button:hover { border-color: var(--accent); color: var(--accent-strong); }
.category-group-grid small { color: var(--muted); }

.auth-dialog-content { padding: 20px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.auth-tabs button { border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); padding: 10px; color: var(--muted); }
.auth-tabs button.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(380px, calc(100vw - 32px)); border: 1px solid var(--line-strong); border-radius: 11px; background: var(--brand); padding: 12px 15px; color: #fff; font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: 180ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

.mobile-nav { display: none; }
[hidden] { display: none !important; }

@media (max-width: 1020px) {
  :root { --sidebar: 198px; }
  .feed-layout { grid-template-columns: minmax(0, 1fr); }
  .insight-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .main-shell { width: 100%; margin-left: 0; padding: 16px 14px 30px; }
  .topbar { display: block; }
  .top-actions { margin-top: 12px; }
  .search-box { width: 100%; }
  .home-hero { grid-template-columns: 1fr; padding: 20px 16px; }
  .hero-copy h2 { font-size: 34px; }
  .hero-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 14px; }
  .metric { min-height: 72px; padding: 10px 8px; }
  .metric strong { font-size: 20px; }
  .toolbar { align-items: flex-start; flex-direction: column; gap: 9px; }
  .category-scroll { width: 100%; }
  .feed-card { grid-template-columns: minmax(0, 1fr) auto; padding: 15px 13px; }
  .feed-card h3 { font-size: 16px; }
  .insight-rail { grid-template-columns: 1fr; }
  .mobile-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); background: rgba(255,255,255,0.97); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); backdrop-filter: blur(12px); }
  .mobile-nav button { display: grid; gap: 2px; place-items: center; border: 0; background: none; padding: 5px; color: var(--muted); font-size: 9px; }
  .mobile-nav button span { display: grid; width: 24px; height: 24px; place-items: center; border: 1px solid var(--line); border-radius: 7px; color: inherit; font-size: 10px; }
  .mobile-nav button.is-active { color: var(--accent-strong); }
  .reader-dialog, .category-dialog, .auth-dialog { width: 100vw; max-width: 100vw; max-height: calc(100vh - 14px); margin: auto 0 0; border-right: 0; border-bottom: 0; border-left: 0; border-radius: 18px 18px 0 0; }
  .reader-shell { max-height: calc(100vh - 16px); }
  .reader-content { padding: 20px 17px 46px; }
  .reader-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reader-mobile-close {
    position: sticky;
    bottom: 0;
    z-index: 3;
    display: block;
    border-top: 1px solid var(--line);
    background: rgba(255,255,255,0.98);
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  }
  .reader-mobile-close .button { width: 100%; min-height: 48px; }
  .category-groups { max-height: calc(100vh - 100px); }
  .form-row { grid-template-columns: 1fr; }
}
