:root {
  --bg: #f4f1ec;
  --card: #ffffff;
  --ink: #2c2622;
  --muted: #8a8178;
  --accent: #7b5e3b;
  --accent-ink: #fff;
  --line: #e4ddd2;
  --warn: #b5562f;
  --ok: #4a7a4a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.env-banner {
  position: sticky; top: 0; z-index: 50;
  text-align: center; font-weight: 700; padding: 8px;
  background: var(--warn); color: #fff; letter-spacing: 0.05em;
}
.env-banner.prod { background: var(--ok); }
.hidden { display: none !important; }

/* レイアウト幅: iPhone縦=全幅 / iPadは横向きの広さを活かす */
#app { max-width: 1180px; margin: 0 auto; padding: 16px; }
@media (max-width: 600px) { #app { padding: 12px; } }
@media (min-width: 1024px) { #app { padding: 24px 28px; } }

header.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px; margin-bottom: 8px;
}
header.top h1 { font-size: 20px; margin: 0; }
.sub { color: var(--muted); font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; margin-bottom: 14px;
}

button {
  font: inherit; cursor: pointer; border: none; border-radius: 10px;
  padding: 12px 16px; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; min-height: 44px;
}
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.small { padding: 8px 12px; min-height: 36px; font-size: 14px; }
button:disabled { opacity: 0.5; cursor: default; }

input, select, textarea {
  font: inherit; width: 100%; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; margin-top: 4px;
}
label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
label span { color: var(--ink); font-weight: 600; }

.grid-tables {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
/* ボタン群（管理者メニュー等）: 横向きで広がり、縦で折り返す */
.grid-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px;
}
/* iPad横向きで主要画面を2カラムに（縦・iPhoneは1カラム） */
.cols-2 { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
@media (min-width: 960px) { .cols-2 { grid-template-columns: 1fr 1fr; } }
.cols-2 > * { margin-bottom: 0; }
.table-tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; text-align: center; cursor: pointer;
}
.table-tile .code { font-size: 26px; font-weight: 800; }
.table-tile .occ { color: var(--muted); margin-top: 6px; }
.table-tile.occupied { border-color: var(--accent); }
.table-tile.over .occ { color: var(--warn); font-weight: 700; }

.member {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px; border-bottom: 1px solid var(--line);
}
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; }
.badge.line { background: #e7f0e7; color: var(--ok); }
.badge.guest { background: #f0e9df; color: var(--muted); }

/* チャットスレッド（Phase 5） */
.thread { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-width: 680px; }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 14px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.bubble.in { align-self: flex-start; background: #f0e9df; color: var(--ink, #2b2b2b); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.note { font-size: 13px; color: var(--muted); margin-top: 6px; }
.error { color: var(--warn); margin-top: 8px; font-size: 14px; }
.ok-msg { color: var(--ok); margin-top: 8px; font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; cursor: pointer; user-select: none;
}
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal { background: #fff; border-radius: 14px; padding: 20px; max-width: 420px; width: 100%; }
.modal h2 { margin-top: 0; }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; background: none; padding: 0; min-height: auto; font-weight: 500; }
