:root {
  --ink: #24261f;
  --muted: #67685e;
  --paper: #f6f3eb;
  --surface: #fffdf8;
  --line: #d8d4c9;
  --accent: #336d4f;
  --accent-ink: #f7fbf5;
  --danger: #b34b3f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.5;
}

.container { width: min(100% - 2rem, 680px); margin: 0 auto; padding: 3.5rem 0 4rem; }
.masthead { margin-bottom: 2.5rem; }
.eyebrow { margin: 0 0 0.4rem; color: var(--accent); font: 700 0.76rem/1.2 system-ui, sans-serif; letter-spacing: 0.12em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.5rem; font-size: clamp(2.15rem, 7vw, 3.35rem); letter-spacing: -0.045em; line-height: 1; }
h2 { margin-bottom: 1.15rem; font-size: 1.18rem; letter-spacing: -0.015em; }
.subtitle { max-width: 36rem; margin-bottom: 0; color: var(--muted); font-size: 1.08rem; }

.card { margin-bottom: 1rem; padding: 1.35rem; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 2px 0 rgb(36 38 31 / 4%); }
label { display: block; margin: 0.85rem 0 0.35rem; color: var(--muted); font: 650 0.8rem/1.2 system-ui, sans-serif; letter-spacing: 0.02em; }
input, select { width: 100%; min-height: 2.7rem; padding: 0.6rem 0.7rem; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 3px; font: inherit; }
input:focus, select:focus, summary:focus-visible, button:focus-visible { outline: 3px solid #9fc2a9; outline-offset: 2px; }

button { min-height: 2.7rem; margin-top: 1.1rem; padding: 0.55rem 0.9rem; color: var(--accent-ink); background: var(--accent); border: 1px solid var(--accent); border-radius: 3px; cursor: pointer; font: 700 0.88rem/1 system-ui, sans-serif; }
button:hover { background: #28593f; }
.hint, .disclaimer { color: var(--muted); font: 0.83rem/1.45 system-ui, sans-serif; }
.hint { margin: 0.55rem 0 0; }
.disclaimer { margin: 1.5rem 0 0; text-align: center; }
.advanced { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 0.95rem; }
.advanced summary { color: var(--muted); cursor: pointer; font: 650 0.84rem/1.2 system-ui, sans-serif; }
.advanced[open] summary { margin-bottom: 0.25rem; }
.advanced input, .advanced select { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.8rem; }

.model-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.75rem; }
.cache-status { color: var(--muted); font: 0.8rem/1.3 system-ui, sans-serif; }
.cache-status.cached { color: var(--accent); }
.download-btn { min-height: auto; margin: 0; padding: 0.43rem 0.62rem; color: var(--accent); background: transparent; border-color: var(--accent); font-size: 0.75rem; }
.download-btn:hover { color: var(--accent-ink); background: var(--accent); }
.download-btn:disabled { opacity: 0.55; cursor: default; }
.progress-bar { height: 1.55rem; margin-top: 0.65rem; overflow: hidden; background: #ebe8df; border: 1px solid var(--line); border-radius: 3px; }
.progress-bar-fill { display: flex; align-items: center; justify-content: center; height: 100%; min-width: 2.2rem; color: var(--accent-ink); background: var(--accent); font: 700 0.7rem/1 system-ui, sans-serif; transition: width 0.15s linear; }
.status { min-height: 1.3em; margin: 0.85rem 0 0; color: var(--muted); font: 0.85rem/1.4 system-ui, sans-serif; }
.status.error { color: var(--danger); }
.hidden { display: none; }

#resultImg { display: block; width: 100%; max-height: 20rem; margin: 0 0 1rem; object-fit: contain; background: #f0eee8; border-radius: 3px; }
#resultBody p { display: flex; justify-content: space-between; gap: 1rem; margin: 0; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
#resultBody p strong { color: var(--muted); font: 650 0.8rem/1.4 system-ui, sans-serif; }
.portion-editor { margin-top: 1.2rem; padding-top: 0.15rem; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.section-heading h2 { margin-bottom: 0.75rem; }
.total { color: var(--accent); font: 700 0.9rem/1 system-ui, sans-serif; white-space: nowrap; }
#entries { padding: 0; margin: 0; list-style: none; }
#entries li { display: flex; justify-content: space-between; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.entry-meta { color: var(--muted); font: 0.78rem/1.4 system-ui, sans-serif; }

@media (max-width: 480px) {
  .container { width: min(100% - 1.25rem, 680px); padding-top: 2rem; }
  .card { padding: 1.05rem; }
  .model-toolbar { align-items: flex-start; flex-direction: column; }
}
