:root {
  color-scheme: light;
  --paper: #f7f5f0;
  --surface: #ffffff;
  --ink: #202326;
  --muted: #686b6d;
  --line: #dcd9d2;
  --green: #176b5b;
  --green-dark: #0e4c40;
  --green-soft: #e9f3ef;
  --amber: #9a6219;
  --amber-soft: #fbf1df;
  --red: #9a3f48;
  --blue: #335f91;
  --shadow: 0 12px 32px rgba(30, 36, 34, 0.08);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.72;
  letter-spacing: 0;
}

button, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid rgba(220, 217, 210, 0.9);
  background: rgba(247, 245, 240, 0.94);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  width: min(100%, 760px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar strong { display: block; font-size: 15px; line-height: 1.3; }
.topbar span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}
.icon-button span { margin: 0; color: inherit; font-size: 22px; line-height: 1; }

.app { width: min(100%, 760px); margin: 0 auto; padding: 20px 14px calc(80px + env(safe-area-inset-bottom)); }

.status-band { display: grid; gap: 22px; padding: 8px 4px 20px; }
.eyebrow { display: block; color: var(--green); font-size: 12px; font-weight: 800; }
h1, h2, h3 { letter-spacing: 0; }
h1 { margin: 5px 0 8px; font-size: 30px; line-height: 1.2; }
h2 { margin: 5px 0 8px; font-size: 21px; line-height: 1.35; }
h3 { margin: 0 0 8px; font-size: 17px; line-height: 1.4; }
p { margin: 8px 0; }
.lead { color: var(--muted); font-size: 15px; }

.progress-label { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.progress-track { height: 7px; overflow: hidden; border-radius: 7px; background: #e4e1da; }
.progress-track span { display: block; width: 10%; height: 100%; border-radius: inherit; background: var(--green); transition: width 250ms ease; }

.notice { margin: 0 0 14px; padding: 10px 12px; border: 1px solid #e4c98f; border-radius: 6px; background: var(--amber-soft); color: #6d4615; font-size: 14px; }
.notice.error { border-color: #e3b4ba; background: #fff0f1; color: var(--red); }
.hidden { display: none !important; }

.reading-content, .feedback-panel, .ai-panel, .next-day-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.reading-content { display: grid; gap: 26px; }
.reading-section { border-top: 1px solid var(--line); padding-top: 22px; }
.reading-section:first-child { border-top: 0; padding-top: 0; }
.reading-section ul { margin: 10px 0 0; padding-left: 22px; }
.reading-section li { margin: 8px 0; }

.goal { padding: 14px; border-left: 4px solid var(--green); border-radius: 0 6px 6px 0; background: var(--green-soft); }
.formula { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 13px; }
.formula span { min-width: 0; padding: 9px 4px; border: 1px solid #c8ded6; border-radius: 6px; background: var(--green-soft); color: var(--green-dark); font-size: 13px; font-weight: 800; text-align: center; }

.case-list { display: grid; gap: 12px; }
.case { padding: 15px; border: 1px solid var(--line); border-radius: 7px; background: #fcfbf8; }
.case-row { margin-top: 9px; }
.case-row b { display: block; color: var(--muted); font-size: 12px; }
.case-row.before p { color: var(--red); }
.case-row.after p { color: var(--green-dark); }
.case-row.why { padding-top: 8px; border-top: 1px dashed var(--line); }

.feedback-panel, .ai-panel, .next-day-panel { margin-top: 18px; }
.section-heading { margin-bottom: 18px; }
.section-heading > p { color: var(--muted); font-size: 14px; }
.question { display: block; margin-top: 18px; font-weight: 700; }
.question span { display: block; margin-bottom: 7px; }
textarea { width: 100%; min-height: 112px; resize: vertical; padding: 12px; border: 1px solid #cfcac1; border-radius: 7px; color: var(--ink); background: #fff; line-height: 1.65; outline: none; }
textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.12); }

.action-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; margin-top: 20px; }
.button { min-height: 48px; padding: 10px 14px; border: 1px solid transparent; border-radius: 7px; font-weight: 800; cursor: pointer; }
.button:disabled { opacity: 0.55; cursor: wait; }
.button.primary { color: white; background: var(--green); }
.button.secondary { border-color: var(--line); color: var(--ink); background: #f7f5f0; }
.button.codex { width: 100%; margin-top: 14px; color: white; background: #2f5f8c; }
.save-status { min-height: 20px; color: var(--muted); font-size: 13px; }

.ai-response { white-space: pre-wrap; }
.follow-up { margin-top: 14px; padding: 13px; border: 1px solid #e2c98d; border-radius: 7px; background: var(--amber-soft); color: #654414; }
.deep-dive-field { display: block; margin-top: 18px; font-weight: 700; }
.deep-dive-field span { display: block; margin-bottom: 7px; }

dialog { width: min(calc(100% - 28px), 520px); padding: 0; border: 0; border-radius: 8px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25); }
dialog::backdrop { background: rgba(20, 23, 22, 0.46); }
.dialog-body { position: relative; padding: 24px; }
.dialog-body ol { padding-left: 22px; }
.dialog-body li { margin: 8px 0; }
.dialog-close { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border: 0; background: transparent; color: var(--muted); font-size: 26px; cursor: pointer; }

@media (min-width: 680px) {
  .status-band { grid-template-columns: 1fr 230px; align-items: end; }
  .reading-content, .feedback-panel, .ai-panel, .next-day-panel { padding: 28px; }
  .case-list { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 360px) {
  h1 { font-size: 26px; }
  .formula { grid-template-columns: 1fr 1fr; }
  .action-row { grid-template-columns: 1fr; }
}
