:root {
  color-scheme: light dark;
  --bg: #F5F5F3; --surface: #FFFFFF; --surface2: #EBEBE7; --text: #16181D; --sub: #5B6170; --muted: #747884;
  --line: #E7E7E3; --field: #D5D6D2; --ink: #16181D; --ink-text: #FFFFFF; --link: #1D4ED8;
  --blue-bg: #E3ECFF; --blue-fg: #1D4ED8; --sel-bg: #16181D; --sel-fg: #FFFFFF; --seg-on: #FFFFFF;
  --warn-bg: #FFF1DC; --warn-fg: #6E4300; --ok-bg: #E6F4EA; --ok-fg: #1E5631; --danger: #B91C1C;
  --on: #16181D; --off: #D5D6D2; --amber: #F59E0B; --scrim: rgba(16, 18, 24, 0.45);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 16px rgba(16, 24, 40, 0.06);
  --tab: rgba(255, 255, 255, 0.92); --nav-on: #ECEDEF; --nav-border: rgba(16, 24, 40, 0.06);
  --nav-shadow: 0 10px 30px rgba(16, 24, 40, 0.12), 0 2px 6px rgba(16, 24, 40, 0.06);
  --recap-tile: rgba(255, 255, 255, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1013; --surface: #1B1C21; --surface2: #26272D; --text: #F3F4F6; --sub: #A6ABB6; --muted: #8A8F9A;
    --line: #2C2D33; --field: #3A3B42; --ink: #F3F4F6; --ink-text: #0F1013; --link: #8AB4FF;
    --blue-bg: #1E2A47; --blue-fg: #8AB4FF; --sel-bg: #F3F4F6; --sel-fg: #0F1013; --seg-on: #3A3B42;
    --warn-bg: #3A2A12; --warn-fg: #F6C77A; --ok-bg: #16301F; --ok-fg: #8FD6A5; --danger: #F87171;
    --on: #5B8CFF; --off: #3A3B42; --scrim: rgba(0, 0, 0, 0.6); --shadow: none;
    --tab: rgba(27, 28, 33, 0.92); --nav-on: #2E2F36; --nav-border: #2C2D33; --nav-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    --recap-tile: rgba(15, 16, 19, 0.08);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
h1, h2, h3, p { margin: 0; }
img { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; border-radius: 10px; }

#app { max-width: 540px; margin: 0 auto; }
.boot { min-height: 100dvh; display: grid; place-items: center; }
.screen { min-height: 100dvh; padding: calc(var(--top) + 20px) 20px calc(118px + var(--bottom)); display: flex; flex-direction: column; gap: 16px; animation: fade 0.18s ease-out; }
.screen.no-nav { padding-bottom: calc(34px + var(--bottom)); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* headers */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 12px; }
.kicker { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--sub); }
.kicker img { width: 27px; height: 22px; }
.title { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.h2 { font-size: 15px; font-weight: 700; }
.muted { color: var(--sub); font-size: 13px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin: -8px -8px 0; }
.textbtn { height: 44px; padding: 0 8px; display: inline-flex; align-items: center; gap: 2px; border: 0; background: none; color: var(--link); font-size: 16px; font-weight: 500; text-decoration: none; }
.textbtn.strong { font-weight: 600; }

/* buttons */
.circle { width: 44px; height: 44px; border-radius: 999px; border: 0; background: var(--surface); box-shadow: var(--shadow); display: inline-flex; align-items: center; justify-content: center; }
.btn { height: 54px; border: 0; border-radius: 999px; background: var(--ink); color: var(--ink-text); font-size: 16px; font-weight: 700; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.small { height: 40px; width: auto; padding: 0 14px; font-size: 13px; }
.btn.ghost { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.btn.danger { background: transparent; color: var(--danger); box-shadow: none; }
.btn:disabled { opacity: 0.55; }
.pill { height: 44px; padding: 0 14px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; text-decoration: none; border: 0; }
.pill.amber { background: var(--warn-bg); color: var(--warn-fg); }
.chip { min-height: 44px; padding: 0 14px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; border: 1px solid var(--field); background: var(--surface); color: var(--text); }
.chip[aria-pressed="true"].solid { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.chip[aria-pressed="true"]:not(.solid) { border: 2px solid var(--text); padding: 0 13px; }
.chip.dashed { border-style: dashed; border-color: var(--sub); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 999px; flex: none; }

/* segmented */
.seg { display: flex; gap: 4px; padding: 3px; background: var(--surface2); border-radius: 12px; }
.seg button { flex: 1; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--sub); font-size: 14px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* cards & lists */
.card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); }
.rows > * + * { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 52px; color: var(--text); text-decoration: none; }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row .t { font-size: 15px; font-weight: 600; }
.row .s { font-size: 13px; color: var(--sub); }
.evcard { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); text-decoration: none; color: var(--text); border: 0; width: 100%; text-align: left; }
.evcard .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.evcard .t { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evcard .s { font-size: 13px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evcard .time { font-size: 13px; font-weight: 600; flex: none; }
.avatar { width: 40px; height: 40px; flex: none; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #FFFFFF; font-weight: 700; font-size: 15px; }
.avatar.both { font-size: 12px; }
.avatar.round { border-radius: 999px; width: 36px; height: 36px; font-size: 14px; }
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; font-size: 13px; font-weight: 600; }
.banner.warn { background: var(--warn-bg); color: var(--warn-fg); }
.banner.ok { background: var(--ok-bg); color: var(--ok-fg); }
.banner.info { background: var(--blue-bg); color: var(--blue-fg); align-items: flex-start; font-weight: 500; line-height: 1.4; }
.empty { padding: 16px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); font-size: 14px; color: var(--sub); text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.section { display: flex; flex-direction: column; gap: 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tag { padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--warn-bg); color: var(--warn-fg); }

/* month */
.cal { background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); padding: 10px 4px 6px; margin: 0 -8px; touch-action: pan-y; }
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow span { text-align: center; font-size: 11px; font-weight: 600; color: var(--sub); padding-bottom: 4px; }
.cal-grid { row-gap: 2px; }
.day { height: 64px; min-width: 0; border: 0; background: transparent; padding: 2px; display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
.day .n { align-self: center; width: 26px; height: 26px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 500; }
.day.out .n { color: var(--muted); }
.day.today .n { background: var(--blue-bg); color: var(--blue-fg); font-weight: 700; }
.day.sel .n { background: var(--sel-bg); color: var(--sel-fg); font-weight: 700; }
.bar { display: block; height: 14px; line-height: 14px; padding: 0 3px; border-radius: 4px; font-size: 10px; font-weight: 600; color: #FFFFFF; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.more { font-size: 10px; font-weight: 600; color: var(--sub); text-align: center; line-height: 12px; }

/* agenda */
.strip { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px; padding: 4px 20px 6px; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip button { flex: none; width: 48px; height: 72px; border: 0; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.strip button[aria-pressed="true"] { background: var(--sel-bg); color: var(--sel-fg); box-shadow: none; }
.strip .w { font-size: 11px; font-weight: 600; opacity: 0.8; }
.strip .n { font-size: 18px; font-weight: 700; }
.dots { display: flex; gap: 3px; height: 5px; }
.dots i { width: 5px; height: 5px; border-radius: 999px; }
.countdown { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 22px; color: #FFFFFF; text-decoration: none; }
.countdown .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.countdown .k { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.9; }
.countdown .t { font-size: 18px; font-weight: 800; }
.countdown .s { font-size: 13px; opacity: 0.92; }
.countdown .num { width: 64px; height: 64px; flex: none; border-radius: 18px; background: rgba(255, 255, 255, 0.18); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.countdown .num b { font-size: 26px; line-height: 1; }
.countdown .num span { font-size: 11px; font-weight: 700; }

/* event detail */
.catpill { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface2); }
.bubble { display: flex; flex-direction: column; gap: 4px; padding: 10px 14px; border-radius: 18px 18px 18px 6px; background: var(--surface); box-shadow: var(--shadow); max-width: 85%; }
.bubble.mine { border-radius: 18px 18px 6px 18px; background: var(--ink); color: var(--ink-text); align-self: flex-end; }
.bubble.mine .muted { color: inherit; opacity: 0.7; }
.reaction { display: flex; gap: 10px; align-items: flex-end; }
.reaction.mine { justify-content: flex-end; }
.status-row { display: flex; gap: 8px; }
.status-row button { flex: 1; height: 48px; border: 0; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; }
.status-row button[aria-pressed="true"].way { background: #15803D; color: #FFFFFF; }
.status-row button[aria-pressed="true"].late { background: #B45309; color: #FFFFFF; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }

/* toggles */
.switch { width: 56px; height: 44px; border: 0; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; flex: none; }
.switch span { width: 50px; height: 30px; border-radius: 999px; display: flex; align-items: center; padding: 3px; background: var(--off); transition: background 0.15s; }
.switch span::after { content: ""; width: 24px; height: 24px; border-radius: 999px; background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.18s cubic-bezier(.3, 1.4, .6, 1); }
.switch[aria-checked="true"] span { background: var(--on); }
.switch[aria-checked="true"] span::after { transform: translateX(20px); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 12px 6px 16px; min-height: 56px; }
.toggle-row .label { display: flex; flex-direction: column; gap: 2px; font-size: 15px; font-weight: 500; }

/* forms */
label.lbl, .lbl { font-size: 13px; font-weight: 600; color: var(--sub); }
.field { display: flex; flex-direction: column; gap: 6px; }
.input { height: 52px; width: 100%; padding: 0 16px; border-radius: 14px; border: 1px solid var(--field); background: var(--surface); font-size: 16px; }
textarea.input { height: auto; min-height: 84px; padding: 12px 16px; resize: vertical; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--sub) 50%), linear-gradient(135deg, var(--sub) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.pickers .prow { height: 56px; padding: 0 12px 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pickers input, .pickers select { height: 38px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--surface2); font-size: 15px; font-weight: 600; max-width: 60%; }
.quick { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.quick input { height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--field); background: var(--bg); font-size: 16px; width: 100%; }
.parsed { display: flex; flex-wrap: wrap; gap: 6px; }
.parsed > span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--surface2); font-size: 12px; font-weight: 600; }
.error { color: var(--danger); font-size: 13px; font-weight: 600; }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.swatches button { width: 44px; height: 44px; border: 0; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; }
.swatches i { width: 30px; height: 30px; border-radius: 999px; }
.swatches button[aria-pressed="true"] i { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }

/* activity */
.recap { padding: 18px; border-radius: 24px; background: var(--ink); color: var(--ink-text); display: flex; flex-direction: column; gap: 12px; }
.recap .k { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.8; }
.recap .tiles { display: flex; gap: 8px; }
.recap .tile { flex: 1; padding: 10px 12px; border-radius: 14px; background: var(--recap-tile); }
.recap .tile b { display: block; font-size: 22px; font-weight: 800; }
.recap .tile span { font-size: 12px; opacity: 0.85; }
.recap .tile.amber { background: var(--amber); color: #16181D; }
.recap .tile.amber span { opacity: 1; font-weight: 600; }
.recap p { font-size: 14px; line-height: 1.45; opacity: 0.92; }
.feed-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; text-decoration: none; color: var(--text); }
.feed-item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 14px; line-height: 1.4; }
.unread-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 999px; background: var(--link); flex: none; }

/* bottom nav */
.navwrap { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center; gap: 12px; max-width: 540px; margin: 0 auto; padding: 8px 16px calc(12px + var(--bottom)); pointer-events: none; }
.navwrap > * { pointer-events: auto; }
.nav { flex: 1; height: 64px; padding: 6px; border-radius: 32px; background: var(--tab); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border: 1px solid var(--nav-border); box-shadow: var(--nav-shadow); display: flex; gap: 4px; }
.nav a { position: relative; flex: 1; border-radius: 26px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; font-size: 11px; font-weight: 600; color: var(--sub); }
.nav a[aria-current="page"] { background: var(--nav-on); color: var(--text); font-weight: 700; }
.nav .badge { position: absolute; top: 4px; left: calc(50% + 4px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #DC2626; color: #FFFFFF; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.fab { width: 64px; height: 64px; flex: none; border-radius: 999px; background: var(--amber); color: #16181D; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4); border: 0; transition: transform 0.12s; }
.fab:active, .btn:active, .chip:active, .evcard:active { transform: scale(0.97); }

/* sheet */
#overlay:empty { display: none; }
.backdrop { position: fixed; inset: 0; z-index: 40; background: var(--scrim); animation: fadein 0.2s ease-out; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; top: calc(var(--top) + 12px); max-width: 540px; margin: 0 auto; background: var(--bg); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up 0.28s cubic-bezier(.2, .9, .3, 1); will-change: transform; }
.sheet.closing { transition: transform 0.22s ease-in; transform: translateY(100%); }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.grab { width: 38px; height: 5px; border-radius: 999px; margin: 8px auto 0; background: var(--field); }
.sheet-head { padding: 4px 8px; display: flex; align-items: center; justify-content: space-between; touch-action: none; }
.sheet-head h1 { font-size: 17px; font-weight: 700; }
.sheet-body { flex: 1; min-height: 0; overflow: auto; padding: 8px 20px 16px; display: flex; flex-direction: column; gap: 18px; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 20px calc(16px + var(--bottom)); }
.dialog { position: fixed; z-index: 51; left: 16px; right: 16px; bottom: calc(16px + var(--bottom)); max-width: 500px; margin: 0 auto; padding: 18px; border-radius: 22px; background: var(--surface); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3); display: flex; flex-direction: column; gap: 10px; animation: up 0.25s cubic-bezier(.2, .9, .3, 1); }
.dialog .backdrop { z-index: -1; }

/* toast */
#toast { position: fixed; z-index: 60; left: 50%; bottom: calc(96px + var(--bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: all 0.2s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast .inner { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 14px; background: var(--ink); color: var(--ink-text); font-size: 14px; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
#toast button { height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--amber); font-weight: 700; }

/* welcome */
.welcome { min-height: 100dvh; padding: calc(var(--top) + 64px) 28px calc(28px + var(--bottom)); display: flex; flex-direction: column; gap: 20px; }
.welcome .hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.welcome .hero img { width: 120px; height: 120px; border-radius: 28px; box-shadow: 0 2px 4px rgba(16, 24, 40, 0.08), 0 14px 32px rgba(16, 24, 40, 0.16); }
.welcome h1 { font-size: 36px; font-weight: 800; letter-spacing: -0.03em; margin-top: 8px; }
.welcome .lead { font-size: 17px; color: var(--sub); }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.who button { height: 88px; border-radius: 20px; border: 2px solid transparent; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 16px; font-weight: 700; }
.who button[aria-pressed="true"] { border-color: var(--text); }
.spacer { flex: 1; }
