:root {
  --bg: #f6f1e8;
  --surface: #fffdf8;
  --ink: #26221d;
  --muted: #6e665b;
  --line: #e4dccd;
  --accent: #b5482a;
  --accent-ink: #ffffff;
  --accent-press: #973a20;
  --danger: #a3271c;
  --chicken: #a86a0c;
  --pork: #b4476a;
  --beef: #8a3b28;
  --none: #4c7a3a;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius-s: 8px;
  --radius-l: 16px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 120ms;
  --slow: 260ms;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --surface: #26231f;
    --ink: #f2ece2;
    --muted: #b0a696;
    --line: #3a352e;
    --accent: #e0714f;
    --accent-ink: #1b1916;
    --accent-press: #c75d3d;
    --danger: #f07a6c;
    --chicken: #e0a443;
    --pork: #e88aa7;
    --beef: #e0846c;
    --none: #8fc27a;
  }
}

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

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
}

h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }

[hidden] { display: none !important; }

button, a { touch-action: manipulation; }
button {
  font: inherit;
  color: inherit;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

input, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: var(--space-3);
}
textarea { resize: vertical; min-height: 84px; }
input:focus-visible, textarea:focus-visible, button:focus-visible, .segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin: var(--space-4) 0 var(--space-2);
}
.optional { font-weight: 400; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  font-weight: 600;
  white-space: nowrap;
  transition: transform var(--fast) var(--ease-out), background var(--fast);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:active { background: var(--accent-press); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--accent); padding: 0 var(--space-2); }
.btn-danger { color: var(--danger); }

.form-error { color: var(--danger); font-size: 0.9rem; margin: var(--space-3) 0 0; min-height: 1.3em; }

/* Lock screen */
.lock {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-5) var(--space-4);
}
.lock-card { width: 100%; max-width: 360px; }
.lock-card p { color: var(--muted); margin: var(--space-2) 0 0; }
.lock-card .btn { width: 100%; margin-top: var(--space-3); }

/* App */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--space-4) + env(safe-area-inset-top, 0px)) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.hint { margin: var(--space-1) 0 var(--space-4); color: var(--muted); font-size: 0.9rem; }

.filters {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 calc(var(--space-4) * -1);
  padding: 0 var(--space-4) var(--space-2);
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 36px;
  padding: 0 var(--space-3);
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.status {
  margin: var(--space-3) 0 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-s);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.list { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: var(--space-2); }

.item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
}
.item-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 0;
  background: none;
  padding: var(--space-1) 0;
  user-select: text;
  -webkit-user-select: text;
}
.item-name { display: block; font-weight: 650; font-size: 1.05rem; overflow-wrap: anywhere; }
.item-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 2px;
}
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-2); font-size: 0.85rem; color: var(--muted); }
.tag { font-weight: 650; }
.tag::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.tag-chicken { color: var(--chicken); }
.tag-pork { color: var(--pork); }
.tag-beef { color: var(--beef); }
.tag-none { color: var(--none); }
.cooked-btn { flex: none; }

.empty { text-align: center; color: var(--muted); padding: var(--space-6) 0; }
.empty .btn { margin-top: var(--space-2); }

/* Sheet */
.sheet {
  width: min(100%, 560px);
  max-width: 100%;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  border: 0;
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: contain;
}
.sheet[open] { animation: sheet-in var(--slow) var(--ease-out); }
.sheet::backdrop { background: rgb(0 0 0 / 0.4); }
@media (min-width: 600px) {
  .sheet { margin: auto; border-radius: var(--radius-l); }
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.meat { border: 0; margin: 0; padding: 0; min-width: 0; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-1); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--space-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
.segmented input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.date-row { display: flex; gap: var(--space-2); align-items: center; }
.date-row input { flex: 1; min-height: 46px; }
.sheet-actions { display: flex; gap: var(--space-3); margin-top: var(--space-2); }
.sheet-actions .btn-primary { flex: 1; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(calc(100% - var(--space-6)), 480px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  min-height: 52px;
  border-radius: var(--radius-l);
  background: var(--ink);
  color: var(--bg);
  font-size: 0.95rem;
  animation: toast-in var(--slow) var(--ease-out);
}
.toast .btn-quiet { color: var(--accent); }
@media (prefers-color-scheme: light) { .toast .btn-quiet { color: #f0a58c; } }
@keyframes toast-in { from { transform: translate(-50%, 12px); opacity: 0; } }

@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--line); }
  .btn-primary:hover { background: var(--accent-press); }
  .btn-quiet:hover { background: transparent; text-decoration: underline; }
  .chip:hover { color: var(--ink); }
  .item-main:hover .item-name { text-decoration: underline; text-underline-offset: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
