/* ===========================================================
   5% 主线 · 注意力自检系统
   浅色 / 克制 / 编辑式排版
   =========================================================== */

:root {
  --bg:        #F6F5F1;
  --bg-soft:   #EFEDE6;
  --surface:   #FFFFFF;
  --ink:       #14171C;
  --ink-2:     #3D444E;
  --muted:     #7A828E;
  --line:      #E5E1D8;
  --line-soft: #F0EDE5;

  --main:        #0F5C4A;
  --main-soft:   #E6F0EC;
  --main-line:   #1B7A63;

  --noise:       #C0562F;
  --noise-soft:  #FBEBE3;

  --gold:        #A9812F;
  --gold-soft:   #F7F0DF;

  --r-sm: 8px;
  --r:    14px;
  --r-lg: 20px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC",
                "SimSun", Georgia, serif;

  --shadow: 0 1px 2px rgba(20, 23, 28, .04), 0 8px 24px rgba(20, 23, 28, .04);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 650; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
.serif { font-family: var(--font-serif); font-weight: 600; }
.muted { color: var(--muted); }
.hint  { color: var(--muted); font-size: 12.5px; }

.app { max-width: 1120px; margin: 0 auto; padding: 0 20px 64px; }

/* ---------------- Topbar ---------------- */

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 14px 0;
  margin-bottom: 26px;
  background: linear-gradient(180deg, var(--bg) 72%, rgba(246,245,241,0));
  backdrop-filter: blur(6px);
}

.brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }

.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--main); color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 17px; font-weight: 700;
  letter-spacing: -.5px;
}
.brand-mark span { font-size: 11px; opacity: .75; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; }
.brand-text span { font-size: 11.5px; color: var(--muted); }

.tabs {
  display: flex; gap: 2px; margin-left: auto;
  background: var(--bg-soft);
  padding: 4px; border-radius: 12px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 7px 14px; border-radius: 9px;
  font-size: 13.5px; color: var(--ink-2); white-space: nowrap;
  transition: background .16s, color .16s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(20,23,28,.06); }

.tools { display: flex; gap: 6px; flex-shrink: 0; }

.ghost {
  border: 1px solid var(--line); background: var(--surface);
  padding: 6px 12px; border-radius: 9px; cursor: pointer;
  font-size: 12.5px; color: var(--ink-2);
  transition: border-color .16s, color .16s, background .16s;
}
.ghost:hover { border-color: #CFC9BB; color: var(--ink); }
.ghost.is-danger:hover { border-color: #E6B7A5; color: var(--noise); background: var(--noise-soft); }

/* ---------------- Views ---------------- */

.view { display: none; animation: fade .28s ease; }
.view.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-head { margin-bottom: 20px; }
.section-head h2 { font-family: var(--font-serif); font-size: 25px; }
.section-head p { color: var(--ink-2); margin-top: 6px; max-width: 720px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h3 { font-size: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > .card { margin-bottom: 0; }

/* ---------------- Hero ---------------- */

.hero { padding: 32px; background: linear-gradient(135deg, #FFFFFF 0%, #F4F8F5 100%); }
.eyebrow {
  font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--main); font-weight: 600; margin-bottom: 12px;
}
.hero h1 { font-size: 34px; letter-spacing: -.4px; }
.lede { color: var(--ink-2); margin-top: 14px; max-width: 660px; }
.hero-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line); background: var(--surface);
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  font-size: 14px; transition: all .16s;
}
.btn:hover { border-color: #CFC9BB; transform: translateY(-1px); }
.btn.is-primary { background: var(--main); border-color: var(--main); color: #fff; font-weight: 600; }
.btn.is-primary:hover { background: #0C4E3E; }
.btn.is-quiet { color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------------- Stats ---------------- */

.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 18px;
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .k { font-size: 12px; color: var(--muted); display: block; }
.stat .v {
  font-family: var(--font-serif); font-size: 30px; font-weight: 700;
  line-height: 1.2; margin-top: 4px; display: block; letter-spacing: -.5px;
}
.stat .v small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat .s { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }
.stat.is-main .v { color: var(--main); }
.stat.is-noise .v { color: var(--noise); }
.stat.is-gold .v { color: var(--gold); }

/* ---------------- Verdict ---------------- */

.verdict { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.verdict-badge {
  flex-shrink: 0; padding: 8px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 650; white-space: nowrap;
}
.verdict-text { flex: 1; min-width: 260px; }
.verdict-text h4 { font-size: 17px; font-family: var(--font-serif); }
.verdict-text p { color: var(--ink-2); margin-top: 6px; }
.verdict-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Rules ---------------- */

.rules { margin: 0; padding-left: 20px; }
.rules li { margin-bottom: 14px; }
.rules li:last-child { margin-bottom: 0; }
.rules strong { font-size: 15px; }
.rules p { color: var(--ink-2); margin-top: 2px; }
.rules::marker { color: var(--muted); }

/* ---------------- Quiz ---------------- */

.quiz-bar { padding: 12px 18px; margin-bottom: 14px; position: sticky; top: 66px; z-index: 30; }
.quiz-bar-inner { display: flex; align-items: center; gap: 14px; }
.quiz-bar-inner span { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.progress { flex: 1; height: 6px; background: var(--bg-soft); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--main); border-radius: 99px; transition: width .3s ease; }

.dim-block { margin-bottom: 18px; }
.dim-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 0 4px 10px;
}
.dim-head h3 { font-size: 15.5px; }
.dim-head .dim-desc { font-size: 12.5px; color: var(--muted); }

.q-item {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 15px 18px; margin-bottom: 10px;
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
}
.q-item.is-answered { border-color: #D9E5E0; background: #FCFDFC; }
.q-text { flex: 1; min-width: 240px; font-size: 14.5px; }
.q-text .q-no { color: var(--muted); font-size: 12px; margin-right: 6px; }

.scale { display: flex; gap: 5px; flex-wrap: wrap; }
.scale button {
  border: 1px solid var(--line); background: var(--surface);
  padding: 6px 11px; border-radius: 8px; cursor: pointer;
  font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
  transition: all .14s;
}
.scale button:hover { border-color: var(--main-line); color: var(--main); }
.scale button.is-on { background: var(--main); border-color: var(--main); color: #fff; font-weight: 600; }
.scale button.is-on.is-neg { background: var(--noise); border-color: var(--noise); }

.audit-actions { display: flex; gap: 10px; margin: 6px 0 18px; flex-wrap: wrap; }

/* ---------------- Result ---------------- */

.result { border-color: #D9E5E0; }
.result-top { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.result-score { text-align: center; min-width: 150px; }
.result-score .n { font-family: var(--font-serif); font-size: 62px; font-weight: 700; line-height: 1; letter-spacing: -2px; }
.result-score .n small { font-size: 20px; color: var(--muted); font-weight: 500; }
.result-score .l { font-size: 12.5px; color: var(--muted); margin-top: 6px; display: block; }
.result-radar { flex: 1; min-width: 280px; display: grid; place-items: center; }

.dim-list { margin-top: 18px; border-top: 1px solid var(--line-soft); padding-top: 16px; }
.dim-row { display: flex; gap: 14px; padding: 11px 0; border-bottom: 1px dashed var(--line-soft); align-items: flex-start; }
.dim-row:last-child { border-bottom: 0; }
.dim-row .nm { width: 84px; flex-shrink: 0; font-size: 13.5px; font-weight: 600; padding-top: 1px; }
.dim-row .mid { flex: 1; min-width: 160px; }
.dim-row .bar { height: 7px; background: var(--bg-soft); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.dim-row .bar i { display: block; height: 100%; border-radius: 99px; transition: width .5s ease; }
.dim-row .adv { font-size: 12.5px; color: var(--ink-2); }
.dim-row .sc { width: 40px; text-align: right; font-family: var(--font-serif); font-size: 17px; font-weight: 700; flex-shrink: 0; }

.todo { margin-top: 18px; background: var(--main-soft); border-radius: var(--r); padding: 16px 18px; }
.todo h4 { font-size: 14px; color: var(--main); margin-bottom: 8px; }
.todo ul { margin: 0; padding-left: 18px; }
.todo li { font-size: 13.5px; color: var(--ink-2); margin-bottom: 5px; }

/* ---------------- Forms ---------------- */

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.field .desc { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }

input[type="text"], textarea, select {
  width: 100%; border: 1px solid var(--line); background: #FCFBF8;
  border-radius: 10px; padding: 10px 12px; font-size: 14px;
  outline: none; transition: border-color .16s, background .16s;
}
input[type="text"]:focus, textarea:focus, select:focus {
  border-color: var(--main-line); background: #fff;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.65; }

.notdo-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.notdo-row .idx {
  width: 24px; height: 24px; border-radius: 7px; background: var(--noise-soft);
  color: var(--noise); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.btn-x {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; flex-shrink: 0;
  display: grid; place-items: center;
}
.btn-x:hover { color: var(--noise); border-color: #E6B7A5; }

.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ---------------- Tribe ---------------- */

.tribe-row {
  display: grid; grid-template-columns: 1fr 210px; gap: 16px;
  padding: 14px 0; border-bottom: 1px dashed var(--line-soft); align-items: center;
}
.tribe-row:last-of-type { border-bottom: 0; }
.tribe-row input[type="text"] { margin-bottom: 6px; }
.energy-label { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; }
input[type="range"] { width: 100%; accent-color: var(--main); }

.tribe-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 4px; }

/* ---------------- Daily ---------------- */

.slider-row { margin-bottom: 16px; }
.slider-row .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.slider-row .top b { font-family: var(--font-serif); font-size: 19px; }
.slider-row .top b small { font-size: 12px; color: var(--muted); font-weight: 400; }
.slider-row input[type="range"] { width: 100%; }
.slider-row.is-noise input[type="range"] { accent-color: var(--noise); }

.check-list { margin: 4px 0 18px; }
.check-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 0;
  border-bottom: 1px dashed var(--line-soft); cursor: pointer;
}
.check-item:last-child { border-bottom: 0; }
.check-item input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--main); flex-shrink: 0; cursor: pointer; }
.check-item span { font-size: 14px; }
.check-item.is-done span { color: var(--muted); text-decoration: line-through; }

.streak { display: flex; align-items: baseline; gap: 8px; }
.streak .n { font-family: var(--font-serif); font-size: 44px; font-weight: 700; line-height: 1; color: var(--gold); }

.cal { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; margin-top: 10px; }
.cal i { display: block; aspect-ratio: 1; border-radius: 5px; background: var(--bg-soft); }
.cal i.l1 { background: #CFE3DB; }
.cal i.l2 { background: #8FC3B2; }
.cal i.l3 { background: var(--main); }
.cal i.miss { background: #F1E3DB; }

.log-list { margin-top: 6px; }
.log-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line-soft); font-size: 13.5px; }
.log-row:last-child { border-bottom: 0; }
.log-row .d { width: 62px; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.log-row .m { flex: 1; color: var(--ink-2); }
.log-row .h { flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* ---------------- Compound ---------------- */

.cp-grid { display: grid; grid-template-columns: 260px 1fr; gap: 26px; align-items: start; }
.cp-inputs .field { margin-bottom: 15px; }
.cp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 22px; }
.cp-note { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 16px; }

.ratio-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--gold-soft); color: var(--gold);
  padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}

/* ---------------- Charts ---------------- */

.chart { width: 100%; overflow: visible; }
.chart text { font-family: var(--font-sans); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; }

.stack { display: flex; height: 30px; border-radius: 8px; overflow: hidden; margin: 12px 0 8px; background: var(--bg-soft); }
.stack i { display: block; height: 100%; transition: width .35s ease; }
.stack-key { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ink-2); }
.stack-key span { display: inline-flex; align-items: center; gap: 5px; }
.stack-key i { width: 9px; height: 9px; border-radius: 2px; }

.empty { color: var(--muted); font-size: 13.5px; padding: 22px 0; text-align: center; }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 200;
  max-width: 86vw; text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Footer ---------------- */

.footer {
  border-top: 1px solid var(--line); margin-top: 30px; padding-top: 18px;
  font-size: 12.5px; color: var(--ink-2);
}
.footer p + p { margin-top: 4px; }

/* ---------------- 云同步 ---------------- */

.dot {
  display: inline-block; width: 7px; height: 7px;
  border-radius: 99px; margin-right: 6px; vertical-align: 1px;
}
.sync-chip {
  display: inline-flex; align-items: center; white-space: nowrap;
}
.sync-chip[data-st="syncing"] .dot { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.sync-msg {
  border-radius: var(--r); padding: 11px 14px; font-size: 13.5px; line-height: 1.6;
  background: var(--bg-soft); color: var(--ink-2);
  border-left: 3px solid var(--muted);
}
.sync-msg.is-ok      { background: var(--main-soft);  border-left-color: var(--main);  color: #14564B; }
.sync-msg.is-warn    { background: var(--gold-soft);  border-left-color: var(--gold);  color: #7A5F1E; }
.sync-msg.is-error   { background: var(--noise-soft); border-left-color: var(--noise); color: #8E3F1C; }
.sync-msg.is-syncing { border-left-color: var(--gold); }

.sync-meta { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.sync-note {
  margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line-soft);
  font-size: 12.5px; color: var(--muted); line-height: 1.65;
}

/* ---------------- 云同步弹窗 ---------------- */

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: flex-start; justify-content: center;
  padding: 80px 16px 16px;
}
.modal.is-open { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(15, 22, 36, .18);
  cursor: pointer;
}
.modal-panel {
  position: relative; width: min(560px, 100%);
  max-height: calc(100vh - 96px); overflow-y: auto;
  margin: 0; box-shadow: 0 20px 60px rgba(15, 22, 36, .18);
}
.modal-panel .card-head {
  position: sticky; top: 0; z-index: 1;
  background: var(--card); border-bottom: 1px solid var(--line-soft);
  margin: -20px -20px 16px; padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.modal-panel .card-head h3 { margin: 0; }
.card-head-right { display: flex; align-items: center; gap: 12px; }
.card-head-split { gap: 16px; }

@media (max-width: 560px) {
  .modal { padding: 0; align-items: flex-end; }
  .modal-panel {
    width: 100%; max-height: 90vh; border-radius: 16px 16px 0 0;
  }
  .modal-panel .card-head { margin: -16px -16px 14px; padding: 14px 16px; }
}

/* ---------------- Responsive ---------------- */

@media (max-width: 940px) {
  .topbar { flex-wrap: wrap; gap: 12px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .tools { margin-left: auto; }
  .grid-2, .cp-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .tribe-row { grid-template-columns: 1fr; gap: 8px; }
}

@media (max-width: 640px) {
  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 26px; }
  .app { padding: 0 14px 48px; }
  .card { padding: 18px 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .v { font-size: 25px; }
  .result-score .n { font-size: 48px; }
  .cp-stats, .tribe-summary { grid-template-columns: 1fr; }
  .q-item { padding: 13px 14px; }
  .scale button { padding: 5px 9px; font-size: 12px; }
  .cal { grid-template-columns: repeat(7, 1fr); }
  .topbar .tools .ghost { padding: 6px 9px; }
}

/* ---------------- Print ---------------- */

@media print {
  body { background: #fff; }
  .topbar, .tools, .footer, .hero-actions, .audit-actions,
  .form-actions, .btn, .ghost, .toast, .quiz-bar, .modal, #syncCard { display: none !important; }
  .view { display: block !important; page-break-before: always; }
  .view:first-child { page-break-before: avoid; }
  .card { box-shadow: none; border-color: #DDD; page-break-inside: avoid; }
  .app { max-width: none; padding: 0; }
}
