/* 使うのはスマホ。幅320pxで壊れないことを前提に組む（10章） */
:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --ink: #1c1c1a;
  --muted: #6b6b66;
  --line: #dcdcd6;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --warn: #8a4b1f;
  --danger: #8c2f2f;
  --ok: #2f5d50;
  --tentative: #8a6d1f;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --panel: #1f2124;
    --ink: #e9e9e4;
    --muted: #9b9b95;
    --line: #34373c;
    --accent: #6fae9b;
    --accent-ink: #10201b;
    --warn: #d9a06a;
    --danger: #e08a8a;
    --ok: #6fae9b;
    --tentative: #d8c07a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* 9-1：スマホの入力欄は16px未満にしない。
   16px未満だとiOSがフォーカス時にページごと拡大し、送信ボタンが画面の外へ出る。 */
input, select, textarea, button {
  font: inherit;
  font-size: 16px;
  color: inherit;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 12px 120px; }

header.bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}
.bar-inner {
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
}
.bar h1 {
  font-size: 17px; margin: 0;
  flex: 1; min-width: 0;                 /* 9-2 */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar .who { font-size: 13px; color: var(--muted); white-space: nowrap; }

.badge-store {
  display: block; max-width: 720px; margin: 0 auto; padding: 6px 12px;
  font-size: 13px; color: var(--warn);
}

nav.tabs { display: flex; gap: 6px; padding: 10px 0; }
nav.tabs button {
  flex: 1; min-width: 0;
  padding: 10px 6px; border: 1px solid var(--line); background: var(--panel);
  border-radius: var(--radius); cursor: pointer;
}
nav.tabs button[aria-selected="true"] {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}

section.step {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 12px;
}
section.step > h2 { font-size: 14px; margin: 0 0 10px; color: var(--muted); font-weight: 600; }

label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

input[type="text"], input[type="date"], input[type="time"], input[type="password"],
select, textarea {
  width: 100%;
  min-width: 0;                          /* 9-2：これが無いと20文字ぶんまでしか縮まない */
  padding: 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
}
textarea { min-height: 72px; resize: vertical; }

.row { display: flex; gap: 8px; align-items: flex-end; }
.row > * { flex: 1; min-width: 0; }      /* 9-2 */
.row > button { flex: 0 0 auto; }

.subhead { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.subhead:first-of-type { margin-top: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); cursor: pointer;
}
.chip[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}

/* カレンダー：日ごとに縦に並べない（4-1 押さえどころ1） */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cal-head .month { flex: 1; min-width: 0; text-align: center; font-weight: 600; }
.cal-head button {
  padding: 8px 12px; border: 1px solid var(--line); background: var(--bg);
  border-radius: 8px; cursor: pointer;
}

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal .dow.sun { color: var(--danger); }
.cal .dow.sat { color: #4a6f9a; }
.cal button.day {
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px;
  cursor: pointer; padding: 0; line-height: 1.1;
}
.cal button.day .n { font-size: 13px; }
.cal button.day .m { font-size: 14px; font-weight: 700; color: var(--ok); }
.cal button.day.blank { visibility: hidden; }
.cal button.day:disabled { opacity: .4; cursor: default; }
.cal button.day.full .m { color: var(--danger); }
.cal button.day.closed .m { color: var(--muted); font-weight: 400; }
.cal button.day[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 1px; }

.times { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.times button {
  padding: 10px 14px; border: 1px solid var(--line); background: var(--bg);
  border-radius: 8px; cursor: pointer;
}
.times button[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}

details.outside { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
details.outside summary { cursor: pointer; font-size: 14px; color: var(--muted); }

.pick-summary { margin-top: 10px; font-size: 14px; }
.pick-summary strong { font-size: 16px; }

/* 送信バーは画面下に固定。キーボードが出たときの当て直しは app.js 側（9-3） */
.submitbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.submitbar .inner {
  max-width: 720px; margin: 0 auto;
  display: flex; gap: 8px; align-items: center;
}
.submitbar .note {
  flex: 1; min-width: 0; font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
button.primary {
  flex: 0 0 auto;
  padding: 12px 18px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer;
}
button.primary:disabled { opacity: .45; cursor: default; }
button.ghost {
  padding: 8px 12px; border: 1px solid var(--line); background: var(--bg);
  border-radius: 8px; cursor: pointer;
}
button.ghost.danger { color: var(--danger); }

.msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.msg.error { background: rgba(140,47,47,.12); color: var(--danger); }
.msg.ok { background: rgba(47,93,80,.12); color: var(--ok); }
.msg.hide { display: none; }

/* 一覧 */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 8px;
}
.card .when { font-weight: 700; }
.card .sub { font-size: 13px; color: var(--muted); }
.card .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.st { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.st.tentative { color: var(--tentative); border-color: var(--tentative); }
.st.confirmed { color: var(--ok); border-color: var(--ok); }
.st.done { color: var(--muted); }
.st.cancelled { color: var(--danger); border-color: var(--danger); }
.st.external { color: var(--warn); border-color: var(--warn); }
.st.closed { color: var(--danger); border-color: var(--danger); }
.rule-note { color: var(--warn); font-size: 14px; margin-bottom: 6px; }
.day-notice { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.st.note { color: var(--muted); }

/* 確認シート（下から出る） */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
  max-height: 90%; overflow: auto;
}
.sheet .inner { max-width: 720px; margin: 0 auto; }
.sheet h3 { margin: 0 0 8px; font-size: 16px; }
.sheet .acts { display: flex; gap: 8px; margin-top: 12px; }
.sheet .acts > * { flex: 1; min-width: 0; }
.hidden { display: none !important; }
