:root {
  --ink: #17372b;
  --forest: #315a40;
  --sage: #7da954;
  --cream: #fff8e9;
  --paper: #f6eedc;
  --paper-deep: #ece3d2;
  --gold: #d3a14b;
  --coral: #dd6c61;
  --line: rgba(49, 90, 64, 0.24);
  --shadow: 0 16px 40px rgba(91, 75, 48, 0.12);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  font-family: "Source Han Sans CN", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background:
    radial-gradient(circle at 14% 8%, rgba(211, 161, 75, .11) 0 2px, transparent 3px),
    radial-gradient(circle at 85% 26%, rgba(125, 169, 84, .10) 0 1px, transparent 2px),
    linear-gradient(135deg, rgba(255,255,255,.20), transparent 42%),
    var(--paper);
  min-width: 320px;
}

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

.app-shell { width: min(100% - 32px, 760px); margin: 0 auto; padding: 28px 0 36px; }
.app-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 4px 2px 24px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-leaf { width: 38px; height: 38px; object-fit: contain; image-rendering: pixelated; }
.eyebrow, .section-code, .live-dot, footer, .header-note { font-family: VT323, "Courier New", monospace; letter-spacing: .06em; }
.eyebrow { margin: 0 0 2px; font-size: 19px; color: var(--forest); }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(24px, 5vw, 32px); line-height: 1.1; letter-spacing: .04em; }
.header-note { color: #69816c; font-size: 15px; padding-top: 8px; text-align: right; }

.intro, .log-form, .preview-section { border-top: 1px solid var(--line); }
.intro { display: flex; gap: 14px; align-items: center; padding: 22px 2px 20px; }
.intro-mark { color: var(--gold); font-size: 22px; }
.intro h2 { font-size: 20px; margin-bottom: 4px; }
.intro p, .form-section-heading p { color: #708174; font-size: 13px; line-height: 1.6; }

.log-form { padding: 24px 0 28px; }
.form-section-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.section-code { display: inline-grid; place-items: center; min-width: 38px; height: 26px; padding: 0 8px; color: var(--cream); background: var(--forest); font-size: 18px; line-height: 1; border-radius: 3px; }
.form-section-heading h2, .preview-heading h2 { font-size: 20px; line-height: 1.25; }
.week-date-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > span, legend { font-size: 14px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; color: var(--ink); background: rgba(255, 250, 239, .76); border: 1px solid rgba(49,90,64,.28); border-radius: 4px; outline: none; transition: border-color .18s, box-shadow .18s, background .18s; }
.field input, .field select { height: 46px; padding: 0 13px; }
.field textarea { padding: 12px 13px; min-height: 88px; resize: vertical; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(125,169,84,.18); background: #fffaf0; }
.week-inputs { display: flex; align-items: center; width: min(100%, 280px); height: 50px; border: 1px solid rgba(49,90,64,.28); background: rgba(255, 250, 239, .76); border-radius: 4px; overflow: hidden; }
.week-inputs input { width: 72px; height: 100%; border: 0; border-radius: 0; background: transparent; text-align: center; font-family: VT323, monospace; font-size: 28px; padding: 0; }
.week-inputs input:focus { box-shadow: none; background: rgba(125,169,84,.10); }
.week-prefix, .week-plus { color: var(--forest); font-family: VT323, monospace; font-size: 28px; padding: 0 13px; }
.week-plus { color: var(--gold); padding: 0 4px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
.field-wide { grid-column: 1 / -1; }
.memory-field { margin-top: 20px; position: relative; }
.field > small { color: #849388; font-size: 12px; text-align: right; margin-top: -4px; }

.preview-section { padding-top: 26px; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.preview-heading > div { display: flex; align-items: center; gap: 12px; }
.live-dot { color: #708174; font-size: 16px; }
.live-dot i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; background: var(--sage); border-radius: 50%; box-shadow: 0 0 0 4px rgba(125,169,84,.16); }
.preview-wrap { width: min(100%, 420px); margin: 0 auto; padding: 9px; background: rgba(255,248,233,.54); border: 1px solid rgba(49,90,64,.22); box-shadow: var(--shadow); }
canvas { display: block; width: 100%; height: auto; background: var(--cream); image-rendering: auto; }
.preview-hint { max-width: 420px; margin: 12px auto 18px; color: #849388; font-size: 12px; text-align: center; line-height: 1.6; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 12px; width: min(100%, 420px); min-height: 52px; margin: 0 auto; color: var(--cream); background: var(--forest); border: 0; border-radius: 4px; box-shadow: 0 8px 18px rgba(49,90,64,.17); cursor: pointer; font-weight: 700; letter-spacing: .04em; transition: transform .18s, background .18s, box-shadow .18s; }
.primary-button span { color: #f1cd7b; font-family: VT323, monospace; font-size: 24px; }
.primary-button:hover { background: #244a33; transform: translateY(-1px); box-shadow: 0 10px 20px rgba(49,90,64,.22); }
.primary-button:active { transform: translateY(0); }
.primary-button:focus-visible { outline: 3px solid rgba(211,161,75,.55); outline-offset: 3px; }
.download-status { min-height: 20px; margin-top: 10px; color: var(--forest); font-size: 13px; text-align: center; }
.download-link { display: block; width: fit-content; margin: 2px auto 0; color: var(--forest); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.download-link[hidden] { display: none; }
footer { padding-top: 28px; color: #738577; font-size: 15px; text-align: center; }

@media (min-width: 640px) {
  .app-shell { padding-top: 44px; }
  .log-form { padding-inline: 24px; }
  .preview-section { padding-inline: 24px; }
}
@media (max-width: 480px) {
  .app-shell { width: min(100% - 24px, 760px); padding-top: 20px; }
  .app-header { gap: 10px; padding-bottom: 20px; }
  .header-note { max-width: 112px; font-size: 12px; line-height: 1.3; }
  .field-grid { gap: 14px 9px; }
  .field input, .field select { padding-inline: 10px; font-size: 14px; }
  .preview-heading { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
