:root {
  color-scheme: light;
  --desk: #dbd9bd;
  --paper: #f9f3df;
  --sheet: #fffaeb;
  --ink: #2a3021;
  --muted: #5c5b44;
  --line: #d6cdb0;
  --olive: #40542f;
  --olive-hover: #314423;
  --honey: #f6e5a4;
  --tape: #eebf73;
  --rust: #a6422f;
  --notebook-width: 446px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang HK", "Noto Sans CJK TC", "Microsoft JhengHei", sans-serif;
  font-family: var(--font);
  color: var(--ink);
  background: var(--desk);
}

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

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #eae7d3, transparent 90%);
}

body:has(dialog[open]) { overflow: hidden; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--olive);
  outline-offset: 3px;
}
h1, h2, h3, p { margin: 0; }
.emoji { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.notebook {
  width: min(100%, var(--notebook-width));
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.notebook main { flex: 1; display: grid; }
.record-view { display: flex; min-height: 100%; flex-direction: column; padding-inline: 29px; }
.home-header { text-align: center; padding-top: max(31px, env(safe-area-inset-top)); }
.home-header h1 { font-size: 27px; letter-spacing: .065em; font-weight: 750; }
.home-content {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(30px, 6vh, 47px);
  flex: 1;
  padding-block: 39px 57px;
}

.hero-paper {
  isolation: isolate;
  position: relative;
  display: grid;
  place-items: center;
  width: min(100% - 28px, 298px);
  height: clamp(211px, 37vh, 292px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    repeating-linear-gradient(0deg, transparent 0 29px, #d8ceb38c 29px 30px) center / calc(100% - 36px) calc(100% - 60px) no-repeat,
    var(--sheet);
  box-shadow: 6px 6px 0 #e9d7a8;
  transform: rotate(-1.4deg);
}

.tape {
  position: absolute;
  z-index: 1;
  top: -11px;
  left: 50%;
  width: 85px;
  height: 25px;
  background: repeating-linear-gradient(45deg, #ffffff00 0 6px, #ffffff17 6px 7px), var(--tape);
  opacity: .83;
  transform: translateX(-50%) rotate(-4deg);
  clip-path: polygon(0 0, 100% 5%, 96% 25%, 100% 47%, 95% 71%, 100% 100%, 0 96%, 4% 74%, 0 50%, 5% 24%);
}

.hero-emoji { font-size: clamp(92px, 15vh, 129px); filter: drop-shadow(0 5px 3px #3d27161a); transform: rotate(1.4deg); }
.hero-leaf { position: absolute; right: 14%; bottom: 15%; font-size: 29px; transform: rotate(13deg); }

.primary, .secondary {
  min-height: 50px;
  padding: 10px 19px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 720;
  font-size: 17px;
  line-height: 1.35;
}

.primary { color: #fffdfa; background: var(--olive); box-shadow: 0 2px 0 #26371c; }
.primary:hover { background: var(--olive-hover); }
.primary:active { transform: translateY(1px); box-shadow: 0 1px 0 #26371c; }
.secondary { border-color: var(--line); background: var(--sheet); }
.secondary:hover { background: #f4ead1; }
.hero-button { width: 100%; max-width: 332px; min-height: 54px; font-size: 20px; }

.tabs {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 9px 19px max(12px, env(safe-area-inset-bottom));
  z-index: 1;
}

.tabs a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 45px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 16px;
}
.tabs a[aria-current] { color: var(--ink); font-weight: 720; background: var(--honey); }

.history-view { padding: max(27px, env(safe-area-inset-top)) 21px 25px; }
.history-header h1 { display: flex; align-items: center; gap: 10px; font-size: clamp(21px, 5.5vw, 26px); }
.history-header .emoji { font-size: 23px; }
.calendar { margin-top: 24px; border: 1px solid var(--line); border-radius: 12px; padding: 5px 10px 12px; background: var(--sheet); }
.month-toolbar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; border-bottom: 1px solid var(--line); }
.month-toolbar h2 { font-size: 17px; text-align: center; }
.icon-button { border: 0; background: transparent; min-width: 44px; min-height: 44px; font-size: 25px; border-radius: 8px; }
.icon-button:hover { background: #f0e5c6; }
.weekdays, .calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.weekdays { font-size: 13px; color: var(--muted); margin-block: 10px 3px; }
.weekdays span { padding: 3px 0; }
.calendar-day {
  border: 0;
  background: transparent;
  min-width: 0;
  min-height: 43px;
  border-radius: 7px;
  padding: 4px 1px 1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  line-height: 1.15;
}
.calendar-day:hover { background: #f4ebd0; }
.calendar-day[aria-current] { box-shadow: inset 0 0 0 1px #b3bb9c; font-weight: 750; }
.calendar-day[aria-pressed="true"] { color: #fffdfa; background: var(--olive); font-weight: 750; }
.day-count { display: inline-grid; place-items: center; height: 13px; min-width: 9px; font-size: 10px; color: var(--rust); }
.day-count.marked:empty::before { content: ""; width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
.calendar-day[aria-pressed="true"] .day-count { color: var(--honey); }
.weekly-summary {
  margin: 17px 0 26px;
  min-height: 44px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
  background: var(--honey);
  border-radius: 9px;
  font-weight: 670;
  line-height: 1.5;
}
.entries-header { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; min-height: 37px; }
.entries-header h2 { font-size: 19px; }
.text-button { border: 0; background: transparent; color: var(--olive); text-decoration: underline; text-underline-offset: .22em; font-weight: 650; padding: 10px 2px; }
.entry-card { border-bottom: 1px solid var(--line); }
.entry-summary {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 49px;
  list-style: none;
  cursor: pointer;
}
.entry-summary::-webkit-details-marker { display: none; }
.entry-summary::after { content: "＋"; color: var(--muted); }
.entry-card[open] .entry-summary::after { content: "−"; }
.entry-type { color: var(--muted); text-align: right; overflow-wrap: anywhere; font-size: 14px; }
.entry-summary time { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 670; font-size: 15px; }
.storage-note, .entry-blank { color: var(--muted); font-size: 14px; line-height: 1.5; padding-block: 12px; }
.storage-note { font-size: 13px; margin-top: 15px; }

.record-dialog, .feedback-dialog {
  color: var(--ink);
  outline: none;
  border: 1px solid var(--line);
  padding: 0;
  background: var(--sheet);
}
.record-dialog::backdrop, .feedback-dialog::backdrop { background: #24221987; }
.record-dialog {
  position: fixed;
  inset: auto 0 0;
  margin: 0 auto;
  width: min(100%, var(--notebook-width));
  max-width: 100%;
  max-height: calc(100% - 22px);
  max-height: calc(100dvh - 22px);
  border-radius: 24px 24px 0 0;
  overflow: hidden;
}
.sheet, #record-form { display: flex; flex-direction: column; min-height: 0; }
.sheet { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); }
.sheet-header { position: relative; min-height: 74px; padding: 38px 25px 6px; }
.handle { position: absolute; top: 13px; left: 50%; transform: translateX(-50%); width: 51px; height: 5px; border-radius: 4px; background: #c8bfa2; }
.progress { display: inline-block; padding: 4px 9px; border-radius: 6px; font-size: 14px; font-weight: 670; background: var(--honey); }
.close-button { position: absolute; top: 29px; right: 16px; font-size: 25px; }
.sheet-content { padding: 7px 24px 13px; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.sheet-content h2 { font-size: clamp(23px, 6vw, 30px); letter-spacing: -.025em; margin-bottom: 22px; line-height: 1.3; }
.sheet-content h2:focus, .history-header h1:focus { outline: none; }
.sheet-actions { display: flex; gap: 9px; padding: 12px 24px max(17px, env(safe-area-inset-bottom)); background: var(--sheet); border-top: 1px solid var(--line); }
.sheet-actions .primary { flex: 1; }
.sheet-actions .secondary { flex: 0 1 34%; }

.datetime-field {
  border: 1px solid var(--line);
  background: #f7ebbf;
  border-radius: 9px;
  min-height: 58px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  margin-block: 0 12px;
}
.datetime-caption { display: flex; align-items: center; gap: 7px; font-weight: 650; white-space: nowrap; font-size: 16px; }
.datetime-field input { display: block; min-width: 0; max-width: 70%; padding: 6px; border: 0; font-size: 16px; background: transparent; border-radius: 4px; }
.quick-button { width: 100%; margin-top: 4px; min-height: 44px; }

.choice-group { display: grid; gap: 7px; border: 0; padding: 0; margin: 0 0 11px; min-width: 0; }
.choice-group.compact { display: flex; flex-wrap: wrap; gap: 7px; }
.group-label, .note-label { font-size: 16px; font-weight: 690; margin-bottom: 9px; padding: 0; }
.choice {
  position: relative;
  min-height: 44px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffcf2;
  display: flex;
  align-items: center;
  gap: 9px;
  line-height: 1.35;
  cursor: pointer;
}
.choice input { margin: 0; flex: 0 0 16px; width: 16px; height: 16px; accent-color: var(--olive); }
.choice:has(input:checked) { background: #f6e7a7; border-color: #a29864; }
.choice:hover { border-color: #858c68; }
.choice input:focus-visible { outline-offset: 1px; }
.follow-up { margin-top: 16px; padding: 12px 10px 2px 32px; border-left: 3px solid var(--tape); background: #f8f0d6; position: relative; border-radius: 0 7px 7px 0; }
.follow-icon { position: absolute; top: 11px; left: 8px; font-size: 16px; }
.symptom-card { margin: 13px 0; padding: 12px 10px 2px; border: 1px solid var(--line); border-radius: 9px; background: #f7efd5; }
.symptom-card h3 { margin-bottom: 12px; font-size: 17px; color: var(--olive); }
.note-label { display: block; margin-top: 14px; }
.note-label textarea { width: 100%; resize: vertical; display: block; padding: 10px; margin-top: 7px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; font-weight: 400; background: #fffcf2; }
.form-error { color: #9d2f2a; font-size: 15px; padding-block: 8px 4px; line-height: 1.45; }

.shape-icon { display: grid; place-items: center; width: 29px; height: 24px; flex: 0 0 29px; }
.shape-icon i { display: block; width: 23px; height: 8px; border-radius: 80% 40%; background: #a26437; transform: rotate(-13deg); }
.shape-1 i { width: 6px; height: 6px; box-shadow: -7px -3px #885733, 6px -4px #a66b40, 5px 4px #a66b40, -5px 6px #925833; }
.shape-2 i { width: 9px; box-shadow: -7px 1px #9a6039, 7px -1px #8e5430; }
.shape-3 i { background: repeating-linear-gradient(96deg, #ab6d43 0 5px, #794c30 5px 6px, #ab6d43 6px 8px); }
.shape-4 i { background: #b3794e; }
.shape-5 i { width: 8px; height: 7px; box-shadow: -7px 2px #a97046, 6px -2px #bd8756; }
.shape-6 i { height: 10px; border-radius: 46% 40% 45% 55%; background: #bd8753; }
.shape-7 i { height: 6px; width: 26px; background: #c99152; }

.detail-list { margin: 0 0 9px; border: 1px solid var(--line); border-radius: 9px; background: #fffcf2; padding-inline: 11px; }
.detail-row { display: grid; grid-template-columns: 5em minmax(0, 1fr); gap: 8px; padding-block: 10px; font-size: 15px; line-height: 1.5; }
.detail-row + .detail-row { border-top: 1px solid var(--line); }
.detail-row dt { font-weight: 680; }
.detail-row dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

.feedback-dialog { width: min(345px, calc(100vw - 44px)); max-width: none; border-radius: 13px; overflow: visible; box-shadow: 0 12px 30px #221c1940; }
.feedback-paper { position: relative; padding: 29px 21px 21px; display: grid; gap: 16px; text-align: center; }
.feedback-paper .tape { background-color: var(--honey); }
.feedback-emoji { display: grid; place-items: center; justify-self: center; width: 96px; height: 96px; border-radius: 50%; background: var(--honey); font-size: 50px; }
.feedback-line { font-size: 24px; line-height: 1.46; font-weight: 740; overflow-wrap: anywhere; }

@media (min-width: 520px) {
  body { padding-block: 22px; }
  .notebook { min-height: calc(100dvh - 44px); border-radius: 25px; overflow: clip; border: 1px solid #c9c4a7; box-shadow: 0 13px 30px #58513b24, 6px 5px 0 #c6c3a7; }
  .record-dialog { inset-block-end: 22px; border-radius: 23px; }
  .sheet { max-height: calc(100dvh - 48px); }
}

@media (max-width: 340px) {
  .record-view, .history-view { padding-inline: 15px; }
  .sheet-content, .sheet-actions { padding-inline: 17px; }
  .sheet-header { padding-left: 17px; }
}

@media (prefers-reduced-motion: no-preference) {
  .record-dialog[open] { animation: slide-in .16s ease-out both; }
  .feedback-dialog[open] { animation: lift-in .16s ease-out both; }
  @keyframes slide-in { from { opacity: .5; transform: translateY(13px); } }
  @keyframes lift-in { from { opacity: .55; transform: translateY(5px) scale(.98); } }
}
