:root {
  --bg: #f5f6fb;
  --panel: #ffffff;
  --ink: #1e2233;
  --ink-soft: #5a6072;
  --line: #e6e8f0;
  --brand: #4f46e5;
  --brand-soft: #eef0ff;
  --done: #16a34a;
  --prog: #2563eb;
  --plan: #9333ea;
  --risk: #dc2626;
  --metric: #b45309;
  --shadow: 0 1px 2px rgba(20, 24, 50, .05), 0 8px 24px rgba(20, 24, 50, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(16px, 5vw, 56px);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { display: inline-flex; }
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: .3px; }
.tagline { margin: 0; font-size: 13px; color: var(--ink-soft); }
.ghost-link {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.ghost-link:hover { color: var(--brand); border-color: var(--brand); }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 24px clamp(16px, 5vw, 56px);
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 15px; margin: 0; }
.hint { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 12px; }

/* Toolbar + buttons */
.toolbar { display: flex; gap: 8px; }
.btn {
  font: inherit;
  font-size: 13px;
  border-radius: 9px;
  padding: 7px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-soft:hover { background: #e2e5ff; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { color: var(--risk); border-color: #f3c6c6; }

/* Input */
textarea {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  font: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  background: #fcfcff;
  outline: none;
}
textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.week-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.week-field input {
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 200px;
  outline: none;
}
.week-field input:focus { border-color: var(--brand); }
.statline { font-size: 12.5px; color: var(--ink-soft); }
.statline b { color: var(--ink); font-weight: 600; }

/* Tabs */
.tabs {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 10px;
}
.tab {
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 7px;
  cursor: pointer;
}
.tab.is-active { background: var(--panel); color: var(--brand); box-shadow: var(--shadow); font-weight: 600; }
.tab-desc { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 12px; min-height: 18px; }

/* Output */
.output {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  background: #fcfcff;
  min-height: 320px;
  font-size: 14px;
}
.output h3 {
  font-size: 14px;
  margin: 18px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--line);
  color: var(--ink);
}
.output h3:first-child { margin-top: 0; }
.output .doc-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; border: none; }
.output .doc-sub { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 14px; }
.output ul { margin: 0; padding-left: 20px; }
.output li { margin: 4px 0; }
.output .empty-hint { color: var(--ink-soft); font-style: normal; }
.output .summary-line {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--brand-soft);
  border-radius: 9px;
  font-size: 13.5px;
  color: #312e81;
}
.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 6px;
  margin-right: 6px;
  vertical-align: 1px;
  font-weight: 600;
}
.tag-metric { background: #fef3c7; color: var(--metric); }
.tag-risk { background: #fee2e2; color: var(--risk); }
.metric-hl { color: var(--metric); font-weight: 600; }

/* Why section */
.why {
  max-width: 1280px;
  margin: 8px auto 0;
  padding: 8px clamp(16px, 5vw, 56px) 32px;
}
.why h2 { font-size: 17px; margin: 0 0 14px; }
.why-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.why-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.why-card h3 { margin: 0 0 6px; font-size: 14px; color: var(--brand); }
.why-card p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.privacy { margin-top: 18px; font-size: 13px; color: var(--ink-soft); }

/* Footer */
.foot {
  text-align: center;
  padding: 24px;
  font-size: 12.5px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  background: var(--panel);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e2233;
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .why-grid { grid-template-columns: 1fr; }
  textarea { min-height: 220px; }
  .output { min-height: 240px; }
}
