:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --text: #2b2723;
  --muted: #7a7168;
  --line: #e6dfd5;
  --accent: #c8642c;
  --accent-ink: #ffffff;
  --accent-soft: #fbeee5;
  --good: #3f8f5a;
  --mid: #d39b2a;
  --low: #c9503f;
  --fish: #2f78a8;
  --meat: #b0473b;
  --warn-bg: #fff6dc;
  --error-bg: #fde8e4;
  --info-bg: #e8f3ea;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1916;
    --card: #26231f;
    --text: #efe9e2;
    --muted: #a99f94;
    --line: #3a352f;
    --accent: #e48650;
    --accent-ink: #1b1916;
    --accent-soft: #3a2a20;
    --good: #67b884;
    --mid: #e0b24f;
    --low: #e27665;
    --fish: #6aaedb;
    --meat: #e0786b;
    --warn-bg: #3b331d;
    --error-bg: #42251f;
    --info-bg: #213428;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: .03em;
  line-break: strict;
  overflow-wrap: anywhere;
  padding-bottom: 84px;
}
a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.4; font-feature-settings: "palt"; margin: 0 0 .6em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.02rem; }
h4 { font-size: .95rem; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.center { text-align: center; }

.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.logout { margin: 0; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 16px; margin: 0 0 14px; box-shadow: var(--shadow);
}
.card.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.card > :last-child { margin-bottom: 0; }

.flash { padding: 10px 12px; border-radius: 10px; background: var(--info-bg); margin: 0 0 12px; }
.flash.error { background: var(--error-bg); }
.flash.warn { background: var(--warn-bg); }

.form { display: grid; gap: 14px; margin: 0 0 12px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .95rem; }
.form label small { font-weight: 400; color: var(--muted); }
.form label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin-right: 14px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px; }
legend { font-weight: 600; font-size: .95rem; padding: 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
input.code { font-size: 1.5rem; letter-spacing: .3em; text-align: center; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 10px 18px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.big { width: 100%; padding: 14px 18px; font-size: 1.05rem; }
.btn.small { padding: 5px 12px; font-size: .85rem; }
.btn.danger { color: var(--low); }
.btn:disabled { opacity: .5; }

.seg { display: flex; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.seg label {
  flex: 1 1 140px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; cursor: pointer;
}
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.seg small { color: var(--muted); width: 100%; }

.week-head, .day-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.day-head form { margin: 0; }
.history { width: 100%; min-width: 0; margin: 0; }
.history select { width: 100%; min-width: 0; font-size: .85rem; padding: 8px 10px; text-overflow: ellipsis; }
.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 8px 0 12px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px 12px; display: grid; }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value { font-size: 1.4rem; font-weight: 700; }
.stat-sub { font-size: .8rem; color: var(--muted); }
.stat-inline b { font-size: 1.3rem; }
.over { color: var(--low); }
.note { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: .92rem; }

.dishes { list-style: none; margin: 0 0 8px; padding: 0; }
.dishes li a {
  display: flex; align-items: center; gap: 8px; padding: 10px 4px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text);
}
.dishes li:last-child a { border-bottom: 0; }
.dish-name { flex: 1; }
.role { font-size: .72rem; border-radius: 6px; padding: 1px 6px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.role-主菜 { background: var(--accent-soft); color: var(--accent); }
.pt { font-size: .72rem; border-radius: 6px; padding: 1px 6px; color: #fff; white-space: nowrap; }
.pt-fish { background: var(--fish); }
.pt-meat { background: var(--meat); }
.meal { margin-top: 8px; color: var(--muted); font-size: .85rem; }
.day-nut { font-size: .8rem; color: var(--muted); margin: 6px 0 0; }

.member { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.member h3 small { color: var(--muted); font-weight: 400; }
.bar-row { display: grid; grid-template-columns: 6.5em minmax(0, 1fr) 3.2em; align-items: center; gap: 8px; font-size: .85rem; }
.bar { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.fill { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--good); }
.fill.mid { background: var(--mid); }
.fill.low { background: var(--low); }
.bar-val { text-align: right; }

.search { margin: 4px 0 0; }
.pick { list-style: none; margin: 0; padding: 0; }
.pick li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.pick li:last-child { border-bottom: 0; }
.pick li.off .pick-name { color: var(--muted); text-decoration: line-through; }
.pick-name { flex: 1; display: flex; gap: 8px; align-items: center; }
.pick .grams { width: 5.5em; padding: 6px 8px; text-align: right; }
.pick .price { display: flex; align-items: center; gap: 4px; font-size: .85rem; }
.pick .price input { width: 5em; padding: 6px 8px; text-align: right; }
.pick .ex { font-size: .8rem; display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.sticky-actions {
  position: sticky; bottom: 76px; display: flex; justify-content: center; padding: 8px 0 12px; z-index: 5;
}
.sticky-actions .btn { box-shadow: 0 4px 14px rgba(0, 0, 0, .18); padding: 12px 40px; }

.ings, .shop, .accounts, .logs { list-style: none; margin: 0 0 8px; padding: 0; }
.ings li, .logs li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.logs li { font-size: .85rem; }
.ings li:last-child, .logs li:last-child { border-bottom: 0; }
.howto { padding-left: 1.4em; margin: 0; }
.howto li { margin-bottom: 8px; }
.nut { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; margin: 0 0 8px; }
.nut div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.nut dt { color: var(--muted); }
.nut dd { margin: 0; font-weight: 600; }

.shop li label { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.shop li:last-child label { border-bottom: 0; }
.shop input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.shop-name { flex: 1; }
.shop-qty { font-size: .9rem; color: var(--muted); text-align: right; }
.shop li.done .shop-name { text-decoration: line-through; color: var(--muted); }
.shop li.have .shop-qty { color: var(--good); }

.accounts li { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.accounts .acts { display: flex; gap: 6px; }
.accounts form { margin: 0; }
.member-row { display: grid; grid-template-columns: minmax(0, 1fr) 6em 5.5em auto; gap: 8px; align-items: center; }
.member-row .age { display: flex; align-items: center; gap: 4px; font-weight: 400; }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; }
.subtabs a { text-decoration: none; color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: .88rem; }
.subtabs a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.steps { padding-left: 1.4em; }
.qr { display: flex; justify-content: center; margin: 12px 0; padding: 14px; background: #fff; border-radius: 12px; }
.qr img, .qr canvas { width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 1.05rem; letter-spacing: .08em; background: var(--bg); padding: 8px 10px; border-radius: 8px; word-break: break-all; }
.back { margin: 0 0 10px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tabbar a { display: grid; justify-items: center; font-size: .72rem; color: var(--muted); text-decoration: none; line-height: 1.3; }
.tabbar a span { font-size: 1.3rem; }
.tabbar a.on { color: var(--accent); font-weight: 700; }

.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.overlay[hidden] { display: none; }
.overlay-box { background: var(--card); border-radius: 16px; padding: 24px 22px; text-align: center; max-width: 320px; }
.overlay-title { font-weight: 700; font-size: 1.1rem; margin: 10px 0 4px; }
.overlay-sub { font-size: .88rem; color: var(--muted); margin: 0; }
.spinner { width: 42px; height: 42px; margin: 0 auto; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

@media (max-width: 480px) {
  .member-row { grid-template-columns: minmax(0, 1fr) 5.5em; }
  .member-row .age { grid-column: 1; }
}
