:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --text: #16181b;
  --muted: #5c6168;
  --line: #ddd7cd;
  --accent: #c2410c;
  --booked: #15803d;
  --tobook: #b45309;
  --idea: #4f46e5;
  --info: #475569;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1e2125;
    --surface-2: #272b30;
    --text: #f1f2f4;
    --muted: #a3a9b1;
    --line: #33383e;
    --accent: #fb923c;
    --booked: #4ade80;
    --tobook: #fbbf24;
    --idea: #a5b4fc;
    --info: #cbd5e1;
    --danger: #f87171;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
}
.bar-inner { max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 8px; }
.bar h1 { font-size: 19px; margin: 0; flex: 1; letter-spacing: -.01em; }
.pill {
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.off { background: color-mix(in srgb, var(--tobook) 18%, var(--surface)); color: var(--tobook); }
.iconbtn {
  min-width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; padding: 0 10px; text-decoration: none;
}
.iconbtn:disabled { opacity: .35; }

/* calendar */
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 14px 0 4px; }
.cal-head span { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cell {
  aspect-ratio: 1 / 1.25; border-radius: 10px; padding: 5px 2px 4px; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--pc) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--pc) 45%, transparent);
  min-width: 0;
}
.cell.empty { background: transparent; border: 1px dashed var(--line); opacity: .5; }
.cell .num { font-weight: 700; font-size: 15px; line-height: 1; }
.cell .em { font-size: 19px; line-height: 1; }
.cell .pl {
  font-size: 9.5px; line-height: 1.1; font-weight: 600; text-align: center; color: var(--text); letter-spacing: -.02em; max-width: 100%;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: normal; overflow-wrap: normal;
}
.cell.today { outline: 3px solid var(--accent); outline-offset: 1px; }
.cell.past .num, .cell.past .pl { opacity: .55; }
.month { font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 0 0; text-transform: uppercase; letter-spacing: .06em; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 14px 0 4px; font-size: 13px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--pc); margin-right: 5px; vertical-align: -1px; }

.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 22px 0 8px; }
.today-card {
  display: block; text-decoration: none; margin-top: 16px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); border-left: 6px solid var(--pc);
}
.today-card b { display: block; font-size: 17px; }
.today-card small { color: var(--muted); }

/* day page */
.day-head { padding: 16px 0 4px; }
.day-head .date { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--pc-strong, var(--muted)); }
.day-head h2 { margin: 2px 0 4px; font-size: 26px; letter-spacing: -.02em; line-height: 1.15; }
.day-head .stay { color: var(--muted); font-size: 15px; }
.day-head .main { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--pc) 14%, var(--surface)); font-size: 15px; }
.dots { display: flex; gap: 4px; justify-content: center; margin: 10px 0 0; flex-wrap: wrap; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); width: 16px; border-radius: 3px; }
.slider { touch-action: pan-y; }
.slider.anim { transition: transform .22s ease, opacity .22s ease; }

.slot-title { font-size: 15px; font-weight: 700; margin: 16px 0 6px; display: flex; align-items: center; gap: 6px; }
.card {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 12px 12px 14px; margin: 0 0 8px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--sc); }
.card .t { min-width: 52px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; padding-top: 1px; }
.card .t small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.card .body { flex: 1; min-width: 0; }
.card .title { font-weight: 650; font-size: 16px; line-height: 1.3; }
.card .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.badge { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: color-mix(in srgb, var(--sc) 16%, var(--surface)); color: var(--sc); text-transform: uppercase; letter-spacing: .03em; }
.ref { font-size: 12.5px; font-family: ui-monospace, Menlo, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.card.booked { border-color: color-mix(in srgb, var(--booked) 40%, var(--line)); }
.card.pending { opacity: .85; }
.maps {
  display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 650; text-decoration: none;
  padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.st-booked { --sc: var(--booked); }
.st-tobook { --sc: var(--tobook); }
.st-idea { --sc: var(--idea); }
.st-info { --sc: var(--info); }
.empty-note { color: var(--muted); font-size: 14px; padding: 6px 0; }

.fab {
  position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 6;
  height: 54px; padding: 0 20px; border-radius: 27px; border: 0; background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,.2);
}
.daynav { position: fixed; left: max(16px, calc(50% - 264px)); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 6; display: flex; gap: 8px; }
.daynav .iconbtn { height: 54px; min-width: 54px; border-radius: 27px; box-shadow: 0 4px 14px rgba(0,0,0,.12); font-size: 22px; }

/* sheet */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.38); z-index: 20; animation: fade .15s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 600px; margin: 0 auto; animation: up .2s ease; overscroll-behavior: contain;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h3 { margin: 4px 0 6px; font-size: 22px; line-height: 1.2; letter-spacing: -.01em; }
.sheet .row { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.sheet .row .k { width: 78px; flex: none; color: var(--muted); font-size: 13.5px; padding-top: 1px; }
.sheet .row .v { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet .links a { display: block; padding: 3px 0; color: var(--accent); }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btn { flex: 1; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 650; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.big { width: 100%; flex-basis: 100%; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* form */
.form label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.form input, .form select, .form textarea {
  width: 100%; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  padding: 8px 10px; font-size: 16px;
}
.form textarea { min-height: 90px; resize: vertical; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* gate */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate form { width: 100%; max-width: 340px; text-align: center; }
.gate .logo { font-size: 48px; }
.gate h1 { margin: 8px 0 18px; font-size: 24px; }
.gate input { width: 100%; height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; font-size: 18px; text-align: center; }
.gate .err { color: var(--danger); min-height: 22px; margin: 8px 0; font-size: 14px; }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 30; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
