/* 片手でのスマホ操作を前提にする。
   タップ領域は最低 48px、本文は 17px 以上。
   状態の区別は必ず記号か文言を伴わせ、色だけに頼らない。 */

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --line: #ddd8cc;
  --text: #1e1c18;
  --muted: #5f5a50;
  --accent: #7a5c1e;
  --accent-ink: #ffffff;
  --warn-bg: #fdf3e0;
  --warn-line: #d9a441;
  --error: #8f2f22;
  --radius: 14px;
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --surface: #201f26;
    --line: #3a3844;
    --text: #efece6;
    --muted: #a9a49c;
    --accent: #e0bd72;
    --accent-ink: #1b1a15;
    --warn-bg: #322915;
    --warn-line: #a5822f;
    --error: #f0a196;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.7 -apple-system, BlinkMacSystemFont, "Hiragino Sans",
        "Noto Sans JP", "Yu Gothic UI", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen { max-width: 640px; margin: 0 auto; padding: 16px; }
.screen.center { min-height: 90vh; display: flex; align-items: center; justify-content: center; }
[hidden] { display: none !important; }

h1 { font-size: 1.35rem; margin: 0; letter-spacing: .02em; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.note  { color: var(--muted); font-size: .9rem; margin: 0 0 12px; }
.meta  { font-size: .85rem; margin: 4px 0 18px; }
.error { color: var(--error); font-weight: 600; }

/* ---- ログイン ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
}
.narrow { max-width: 380px; }
.card h1 { margin-bottom: 20px; text-align: center; }

label { display: block; font-weight: 600; margin-bottom: 8px; }

input[type="password"], input[type="text"] {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font-size: 17px;                 /* iOS の自動ズームを避けるため 16px 未満にしない */
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 10px;
}
input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

button { font: inherit; cursor: pointer; }

.primary {
  width: 100%;
  min-height: var(--tap);
  margin-top: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.05rem;
}
.primary:disabled { opacity: .6; }

/* ---- アプリバー ---- */

.appbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 2px;
}
.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  font-size: 1.4rem; line-height: 1;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
}
.icon-btn:disabled { opacity: .5; }

/* ---- 数値タイル ---- */

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
}
.tile.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.tile-num { display: block; font-size: 2rem; font-weight: 700; line-height: 1.1; }
.tile-label { display: block; font-size: .82rem; color: var(--muted); margin-top: 6px; }

/* ---- 表 ---- */

.block { margin: 26px 0; }

.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.grid th:first-child, .grid td:first-child { text-align: left; }
.grid thead th { font-size: .82rem; color: var(--muted); font-weight: 600; }
.grid td.zero { color: var(--muted); }

/* ---- 定義リスト ---- */

.stats { margin: 0; }
.stats div {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- レシピの一覧 ---- */

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.list .row1 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.list .rid { font-weight: 700; font-variant-numeric: tabular-nums; }
.list .rname { font-weight: 600; }
.list .pfc {
  margin-top: 8px; font-size: .92rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.list .empty { color: var(--muted); }

/* ---- バッジ ----
   色は補助。必ず記号か文言で読めるようにする。 */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.ok    { border-color: var(--accent); color: var(--accent); }
.badge.warn  { border-color: var(--warn-line); background: var(--warn-bg); }

/* ---- 展開 ---- */

details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
summary {
  min-height: var(--tap);
  display: flex; align-items: center;
  padding: 12px 14px;
  font-weight: 600;
  cursor: pointer;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: "＋"; margin-right: 10px; color: var(--muted); font-weight: 700; }
details[open] summary::before { content: "−"; }
details .body { padding: 0 14px 14px; }
details .body ul { list-style: none; margin: 0; padding: 0; }
details .body li {
  padding: 9px 0; border-top: 1px solid var(--line);
  display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline;
}

/* ---- 下部 ---- */

.foot { margin: 34px 0 20px; text-align: center; }
.link-btn {
  min-height: var(--tap); padding: 0 16px;
  background: none; border: none;
  color: var(--muted); text-decoration: underline;
  font-size: .95rem;
}
