:root {
  --bg: #f4f5f3; --card: #fff; --text: #1a1f1b; --muted: #454d47; --line: #c4c9c3;
  --accent: #14532d; --on-accent: #fff; --accent-soft: #dcefe2;
  --warn-bg: #fff4d6; --warn-text: #6b4a00; --danger: #b3261e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121512; --card: #1c211d; --text: #eceeea; --muted: #a2aba4; --line: #333a34;
    --accent: #6fcf97; --on-accent: #08240f; --accent-soft: #1f3a29;
    --warn-bg: #3a2f10; --warn-text: #f4d58a; --danger: #ff8a80;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
.offline { margin: 0; padding: 8px 16px; font-weight: 600; text-align: center; background: var(--warn-bg); color: var(--warn-text); }
.pending { padding: 10px 14px; margin: 10px 0; border: 1px dashed var(--line); border-radius: 10px; }
.pending ul { margin: 6px 0 0; padding-left: 18px; }
.sr-only { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); border: 0; }
.pc-only { display: none; }
body.demo .top { background: #9a2a00; color: #fff; }
body.demo #title::after { content: " · TEST"; }
.text-size { display: inline-flex; gap: 6px; }
.text-size button { min-height: 44px; min-width: 52px; padding: 0 8px; font-weight: 600; }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: .85rem; margin: 20px 0 8px; color: var(--muted); font-weight: 600; }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  position: sticky; top: 0; z-index: 2; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
main { padding: 12px 16px calc(150px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 3; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  min-height: 56px; padding: 0 2px; border: 0; background: none; color: var(--muted); font: inherit; font-size: .9rem;
}
.tabs button[aria-current] { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }

button, .button {
  font: inherit; min-height: 48px; padding: 0 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; }

.week { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; text-align: center; gap: 8px; }
.week strong { display: block; }
.week small { color: var(--muted); }

.card {
  display: block; width: 100%; text-align: left; height: auto; padding: 12px 14px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
}
.card .row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card small { color: var(--muted); display: block; }
.card strong { overflow-wrap: anywhere; }
.badge {
  display: inline-block; font-size: .75rem; padding: 1px 7px; border-radius: 99px; margin-left: 4px;
  background: var(--accent-soft); color: var(--text); white-space: nowrap;
}
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumbs:not(:empty) { margin-bottom: 12px; }
.thumb { position: relative; display: block; }
.thumb img { display: block; width: 100%; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb button {
  position: absolute; top: 4px; right: 4px; min-height: 36px; width: 36px; padding: 0;
  border-radius: 50%; background: var(--text); color: var(--bg); border: 0; font-size: 20px; line-height: 1;
}
.chips { margin-bottom: 12px; }
.recovery {
  font: 700 1.05rem/1.5 ui-monospace, monospace; text-align: center; overflow-wrap: anywhere;
  padding: 12px; margin: 0 0 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.thumb img:not([src]) { background: var(--line); color: var(--muted); font-size: .8rem; }
.receipt-large { display: block; width: 100%; max-height: 42dvh; object-fit: contain; margin-bottom: 12px; border-radius: 8px; }
.finish { display: grid; gap: 8px; }
.finish button { min-height: 64px; font-size: 1.15rem; font-weight: 600; text-align: left; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }

.fab {
  position: fixed; z-index: 2; left: 16px; right: 16px; margin: 0 auto; max-width: 608px;
  bottom: calc(68px + env(safe-area-inset-bottom));
}

.warn {
  background: var(--warn-bg); color: var(--warn-text); border-radius: 10px;
  padding: 10px 14px; margin: 0 0 12px;
}
.warn ul { margin: 6px 0 0; padding-left: 18px; }
.warn li { margin-bottom: 6px; }

label { display: block; margin-bottom: 12px; font-size: .9rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1rem; min-height: 48px; }
label.check input { width: 24px; height: 24px; min-height: 0; margin: 0; flex: none; }
input, select, textarea {
  display: block; width: 100%; min-height: 48px; margin-top: 4px; padding: 10px 12px;
  font: inherit; font-size: 16px; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px;
}
textarea { min-height: 96px; resize: vertical; }
textarea.email { min-height: 280px; font-size: 14px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair > * { min-width: 0; }
.actions { display: grid; gap: 8px; margin-top: 12px; }
.hint { font-size: .9rem; color: var(--muted); margin: -4px 0 12px; }
.hint.alert { color: var(--warn-text); background: var(--warn-bg); padding: 8px 10px; border-radius: 8px; margin-top: 0; }
.error { color: var(--danger); min-height: 1.4em; }
details { margin-bottom: 12px; }
summary { min-height: 40px; color: var(--muted); }

dialog {
  width: 100%; max-width: 640px; margin: 0 auto; padding: 16px;
  max-height: calc(100dvh / var(--zoom, 1)); height: calc(100dvh / var(--zoom, 1));
  border: 0; background: var(--bg); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog h2 { font-size: 1.15rem; color: var(--text); margin: 0 0 14px; }
@media (min-width: 700px) {
  .tabs { grid-template-columns: repeat(5, 1fr); }
  .pc-only { display: block; }
  .text-size { display: none; }
  body { font-size: 20px; }
  input, select, textarea, button, .button { font-size: 20px; }
  label { font-size: 18px; }
  h1 { font-size: 1.6rem; }
  main { max-width: 860px; }
  .fab { max-width: 828px; }
  .tabs { max-width: 860px; margin: 0 auto; }
  textarea.email { font-size: 18px; }
}
@media (min-width: 700px) { dialog { height: auto; margin-top: 5vh; max-height: 90vh; border-radius: 14px; } }

.login { max-width: 360px; margin: 18vh auto 0; padding: 0 16px; }
.login h1 { margin-bottom: 20px; }
.login button { width: 100%; }

.toast {
  position: fixed; z-index: 10; left: 16px; right: 16px; bottom: calc(130px + env(safe-area-inset-bottom));
  margin: 0 auto; max-width: 420px; padding: 12px 16px; border-radius: 10px; text-align: center;
  background: var(--text); color: var(--bg);
}
