/* うちのクルマ — 玄関のキーフックに掛かった「鍵札」をモチーフにした、静かな道具系UI */
:root {
  --bg: #eceff3;
  --surface: #ffffff;
  --ink: #18212d;
  --ink-2: #4a5566;
  --ink-3: #7b8696;
  --line: #d8dde4;
  --sign: #0b5cad;      /* 駐車場の「P」標識の青 */
  --free: #1e9e62;
  --busy: #d64545;
  --hold: #d99a00;
  --focus: #0b5cad;
  --radius-l: 22px;
  --radius-m: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 0 rgba(24, 33, 45, .06), 0 8px 24px -12px rgba(24, 33, 45, .25);
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171e; --surface: #1b222c; --ink: #e8edf3; --ink-2: #b2bccb; --ink-3: #808b9b; --line: #2c3542;
    --sign: #4c95e6; --free: #35c083; --busy: #f06a6a; --hold: #f0b429; --focus: #6aa8ef;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.7);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.55; font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.muted { color: var(--ink-3); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 骨組み ---------- */
.shell { max-width: 1080px; margin: 0 auto; padding: 12px 16px 96px; }
.top { display: flex; align-items: center; gap: 10px; padding: 6px 2px 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: .01em; min-width: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--sign); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 17px; flex: none; }
.car-switch { background: none; border: 0; padding: 4px 6px; border-radius: 8px; font-weight: 700; display: flex; align-items: center; gap: 4px; min-width: 0; }
.car-switch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .spacer { flex: 1; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; border: 0; flex: none; }
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }

.grid { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; gap: 24px; }
  .col-b { position: sticky; top: 12px; }
}
.panel { background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow); padding: 16px; }
.panel-h { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.panel-h h2 { font-size: 15px; margin: 0; font-weight: 700; }
.panel-h .spacer { flex: 1; }

/* ---------- 鍵札（いちばん目立つ要素） ---------- */
.tag {
  position: relative; display: grid; grid-template-columns: 74px 1fr; min-height: 168px;
  background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow); overflow: hidden;
}
.tag-band { background: var(--state); position: relative; display: flex; justify-content: center; padding-top: 22px; transition: background .4s; }
.tag-band::before { /* 札の穴 */
  content: ""; width: 22px; height: 22px; border-radius: 50%; background: var(--bg);
  box-shadow: inset 0 2px 3px rgba(0,0,0,.25);
}
.tag-band .state-word {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  writing-mode: vertical-rl; color: #fff; font-weight: 800; font-size: 19px; letter-spacing: .18em;
}
.tag-body { padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tag-title { font-size: 26px; font-weight: 800; line-height: 1.25; letter-spacing: .01em; }
.tag-sub { color: var(--ink-2); font-size: 15px; }
.tag-sub strong { color: var(--ink); }
.tag-warn { color: var(--busy); font-weight: 700; font-size: 14px; }
.tag-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 12px; }
.tag[data-state="free"] { --state: var(--free); }
.tag[data-state="in_use"] { --state: var(--busy); }
.tag[data-state="reserved"] { --state: var(--hold); }

/* ---------- ボタン ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 700; font-size: 15px; line-height: 1.2;
  background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  transition: transform .08s, background .15s; white-space: nowrap; flex: none;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink); color: var(--surface); }
.btn.go { background: var(--free); color: #fff; }
.btn.stop { background: var(--busy); color: #fff; }
.btn.blue { background: var(--sign); color: #fff; }
.btn.ghost { background: transparent; color: var(--sign); padding-left: 8px; padding-right: 8px; }
.btn.danger { background: transparent; color: var(--busy); }
.btn.big { padding: 14px 22px; font-size: 17px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- ひとこと入力 ---------- */
.quick { display: flex; gap: 8px; }
.quick input {
  flex: 1; min-width: 0; border: 1.5px solid var(--line); background: var(--bg); border-radius: 14px;
  padding: 12px 14px; font-size: 16px; outline: none;
}
.quick input:focus { border-color: var(--sign); background: var(--surface); }
.preview:empty { display: none; }
.preview { margin-top: 10px; font-size: 14px; color: var(--ink-2); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.preview .what { font-weight: 700; color: var(--ink); }
.preview .warn { color: var(--busy); font-weight: 600; }
.hint-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  border: 1.5px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 12px; font-size: 14px; line-height: 1.2; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- 週の帯 ---------- */
.week-nav { display: flex; align-items: center; gap: 2px; }
.week-nav .range { font-size: 14px; color: var(--ink-2); min-width: 7.5em; text-align: center; }
.week { display: grid; gap: 2px; }
.day-row {
  display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 8px;
  background: none; border: 0; padding: 6px 4px; border-radius: 10px; text-align: left; width: 100%;
}
.day-row:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.day-row[aria-current="true"] { background: color-mix(in srgb, var(--sign) 10%, transparent); }
.day-label { display: flex; align-items: baseline; gap: 4px; line-height: 1; }
.day-label b { font-size: 19px; font-weight: 800; }
.day-label span { font-size: 12px; color: var(--ink-3); }
.day-label.sun span, .day-label.sun b { color: var(--busy); }
.day-label.sat span, .day-label.sat b { color: var(--sign); }
.day-label.today b { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; }
.track { position: relative; height: 26px; border-radius: 7px; background: color-mix(in srgb, var(--ink) 6%, transparent); overflow: hidden; }
.track .tick { position: absolute; top: 0; bottom: 0; width: 1px; background: color-mix(in srgb, var(--ink) 10%, transparent); }
.track .seg { position: absolute; top: 3px; bottom: 3px; border-radius: 5px; background: var(--c); min-width: 4px; }
.track .seg.tent { background: repeating-linear-gradient(135deg, var(--c) 0 5px, color-mix(in srgb, var(--c) 35%, transparent) 5px 10px); }
.track .seg.past { opacity: .35; }
.track .seg.using { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.track .now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); }
.scale { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 0 4px; font-size: 11px; color: var(--ink-3); }
.scale div { position: relative; height: 14px; }
.scale span { position: absolute; transform: translateX(-50%); }

/* ---------- 予定リスト ---------- */
.agenda { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.item {
  display: grid; grid-template-columns: 5px 1fr auto; gap: 12px; align-items: center; width: 100%;
  background: none; border: 0; text-align: left; padding: 10px 8px; border-radius: 12px;
}
.item:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.item .bar { align-self: stretch; border-radius: 3px; background: var(--c); }
.item.tent .bar { background: repeating-linear-gradient(180deg, var(--c) 0 5px, transparent 5px 9px); }
.item .when { font-weight: 700; font-size: 16px; }
.item .who { color: var(--ink-2); font-size: 14px; }
.item.done { opacity: .55; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.tent { background: color-mix(in srgb, var(--hold) 20%, transparent); color: color-mix(in srgb, var(--hold) 70%, var(--ink)); }
.badge.using { background: var(--busy); color: #fff; }
.badge.done { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-2); }
.empty { padding: 18px 8px; color: var(--ink-3); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.feed { list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--ink-2); display: grid; gap: 8px; }
.feed li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.feed time { color: var(--ink-3); font-size: 12px; white-space: nowrap; min-width: 4.5em; padding-top: 2px; }

/* ---------- シート ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease-out; }
.sheet {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; overscroll-behavior: contain;
  border-radius: 24px 24px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); animation: up .24s cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { border-radius: 24px; } }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet-h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.sheet-h h2 { margin: 0; font-size: 19px; flex: 1; }
.field { margin: 14px 0; }
.field > label, .field > .label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input.input { flex: 1; min-width: 0; width: auto; }
.scroll-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.scroll-row::-webkit-scrollbar { display: none; }
.scroll-row .chip { flex: none; }
.input, select.input {
  border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 12px; font-size: 16px; width: 100%; outline: none;
}
.input:focus { border-color: var(--sign); background: var(--surface); }
.time-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.time-row .input { text-align: center; font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 700; padding: 10px 6px; min-width: 0; }
.seg-ctl { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 12px; padding: 3px; }
.seg-ctl button { border: 0; background: transparent; border-radius: 9px; padding: 9px; font-weight: 700; color: var(--ink-2); }
.seg-ctl button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.help { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.notice { border-radius: 12px; padding: 10px 12px; font-size: 14px; background: color-mix(in srgb, var(--busy) 12%, transparent); color: var(--ink); }
.notice.info { background: color-mix(in srgb, var(--sign) 10%, transparent); }
.notice.ok { background: color-mix(in srgb, var(--free) 12%, transparent); }
.sheet-actions { display: flex; gap: 8px; margin-top: 18px; align-items: center; }
.sheet-actions .spacer { flex: 1; }

/* 確認ダイアログ */
.dialog-scrim { z-index: 70; align-items: center; padding: 16px; }
.dialog { background: var(--surface); border-radius: 20px; padding: 20px; width: min(100%, 380px); box-shadow: var(--shadow); animation: up .2s ease-out; }
.dialog p { margin: 0 0 12px; font-weight: 600; }
.dialog .sheet-actions { margin-top: 14px; }

/* 設定 */
.set-group { border-top: 1px solid var(--line); padding: 4px 0; }
.set-group > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 2px; font-weight: 700; cursor: pointer; }
.set-group > summary::-webkit-details-marker { display: none; }
.set-group > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg); transition: transform .2s; }
.set-group[open] > summary::after { transform: rotate(-135deg); }
.set-group .body { padding: 0 2px 14px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; flex: none; transition: background .2s; cursor: pointer; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--free); }
.switch input:checked::after { transform: translateX(18px); }
.copy-box { display: flex; gap: 6px; }
.copy-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--bg); border-radius: 10px; padding: 10px; font-size: 13px; }
.list-plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.list-plain li { display: flex; align-items: center; gap: 10px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; background: var(--c); }
.swatch[aria-pressed="true"] { border-color: var(--surface); box-shadow: 0 0 0 2px var(--ink); }
.code-big { font-size: 34px; font-weight: 800; letter-spacing: .2em; text-align: center; padding: 8px 0; }
pre.example { background: var(--bg); border-radius: 10px; padding: 10px; font-size: 12px; overflow: auto; white-space: pre-wrap; word-break: break-all; }

/* 参加画面 */
.join { max-width: 420px; margin: 0 auto; padding: 12vh 20px 40px; }
.join h1 { font-size: 26px; margin: 18px 0 6px; }
.join p { color: var(--ink-2); margin: 0 0 22px; }
.member-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-bottom: 16px; }
.member-pick button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 700; }

/* トースト */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--surface); border-radius: 14px; padding: 12px 14px 12px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); max-width: calc(100vw - 24px); font-size: 15px; animation: up .22s ease-out;
}
.toast-slot { position: relative; z-index: 60; }
.toast { pointer-events: none; }
.toast button { pointer-events: auto;  background: transparent; border: 0; color: color-mix(in srgb, var(--sign) 50%, #fff); font-weight: 700; padding: 4px 6px; white-space: nowrap; }
.fab { position: fixed; right: 18px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 30; border-radius: 18px; padding: 15px 20px; box-shadow: 0 10px 24px -8px rgba(11,92,173,.6); }
@media (min-width: 900px) { .fab { display: none; } }

@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.toast { animation-name: toastUp; }
@keyframes toastUp { from { transform: translate(-50%, 20px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
