:root {
  /* palette: dark grey 33,31,31 + blue 97,192,239, with matching tints */
  --grey: #211f1f; --blue: #61c0ef; --blue-soft: #d9eefa; --amber: #d9a441; --coral: #d9644f; --green: #4f9d7a;
  --bg: #f5f4f3; --card: #ffffff; --ink: #211f1f; --muted: #7d7878; --line: #e5e2e0;
  --accent: var(--blue); --accent-ink: #211f1f;
  --meeting: var(--blue); --meeting-ink: #211f1f; --event: var(--grey); --event-ink: #ffffff;
  --other: #ecebea; --other-ink: #6b6666; --cancel: #c9c5c4; --warn: var(--coral); --ok: var(--green);
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  --hour: 56px; --gutter: 46px; --tab-h: 60px;
  --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #211f1f; --card: #2a2828; --ink: #f2f0ef; --muted: #a39e9e; --line: #3a3737; --other: #343131; --other-ink: #9a9595; --cancel: #5a5656;
    --event: #f2f0ef; --event-ink: #211f1f; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 15px/1.35 var(--sans); overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
#app { height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* login */
#login { align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 420px; text-align: center; }
.login-box h1 { margin: 0 0 4px; font-size: 32px; font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }
.login-box p { font-family: var(--serif); font-size: 17px; }
.name-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.name-grid button { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 10px; font-family: var(--serif); font-weight: 600; font-size: 17px; }
.name-grid button:active { background: var(--accent); color: var(--accent-ink); }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--safe-top) + 8px) 12px 8px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-family: var(--serif); font-weight: 600; font-size: 18px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-family: var(--serif); font-weight: 600; font-size: 14px; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.on { background: var(--grey); color: #fff; border-color: var(--grey); }
@media (prefers-color-scheme: dark) { .chip.on { background: var(--blue); color: var(--grey); border-color: var(--blue); } }

/* day strip */
.day-strip { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--card); border-bottom: 1px solid var(--line); }
.day-strip button { padding: 8px 0 10px; text-align: center; font-family: var(--serif); font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.day-strip button b { display: block; margin: 3px auto 0; width: 30px; height: 30px; line-height: 30px; border-radius: 50%; font-size: 17px; color: var(--ink); }
.day-strip button.sel b { background: var(--accent); color: var(--accent-ink); }
.day-strip button.today b { box-shadow: inset 0 0 0 2px var(--accent); }
.day-strip button i { display: block; height: 4px; margin: 3px auto 0; width: 4px; border-radius: 50%; background: transparent; }
.day-strip button.has i { background: var(--muted); }

/* views */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.grid-wrap { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; position: relative; }
.tabbar { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom); height: calc(var(--tab-h) + var(--safe-bottom)); }
.tabbar button { font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--muted); }
.tabbar button.active { color: var(--accent); }

/* now card */
.now-card { margin: 10px 12px 0; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 14px; font-size: 14px; }
.now-card { position: relative; }
.now-card .dismiss { position: absolute; top: 8px; right: 10px; width: 26px; height: 26px; border-radius: 50%; background: var(--bg); color: var(--muted); font-size: 13px; line-height: 26px; text-align: center; }
.now-card.mini { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px; border-left-width: 4px; }
.now-card.mini .h { margin: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-card.mini .expand { color: var(--muted); padding-left: 10px; }
.now-card .t { font-family: var(--serif); font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-card .h { font-weight: 700; margin: 2px 0 4px; }
.now-card .travel { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; }
.now-card .travel span { white-space: nowrap; }
.now-card .buf { margin-top: 6px; font-weight: 600; }
.now-card .buf.late { color: var(--warn); }
.now-card .buf.ok { color: var(--ok); }

/* stacked receptions (4+ overlapping): one block with a tile grid */
.ev.stack { background: var(--card); color: var(--ink); border: 1px dashed var(--muted); border-left: 3px solid var(--grey); box-shadow: none; padding: 4px 6px; }
.ev.stack.other { border-left-color: var(--line); color: var(--other-ink); }
.ev.stack b { font-family: var(--serif); font-weight: 600; margin-bottom: 3px; }
.ev.stack .tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 3px; }
.ev.stack .tiles span { background: var(--grey); color: #fff; border-radius: 5px; padding: 3px 6px; font-size: 11px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.stack .tiles small { display: block; font-size: 9.5px; opacity: .75; }
.ev.stack.other .tiles span { background: var(--other); color: var(--other-ink); }
.ev.stack .dots { display: flex; flex-wrap: wrap; gap: 2px; } .ev.stack .dots i { width: 6px; height: 6px; border-radius: 2px; background: var(--grey); } .ev.stack.other .dots i { background: var(--other-ink); opacity: .5; }
@media (prefers-color-scheme: dark) { .ev.stack .tiles span { background: #f2f0ef; color: var(--grey); } .ev.stack .dots i { background: #f2f0ef; } .ev.stack { border-left-color: #f2f0ef; } }
.week .ev.stack { padding: 2px 3px; } .week .ev.stack b { font-size: 10px; }

/* travel modes */
.mode { display: inline-flex; align-items: center; gap: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px 3px 7px; margin: 0 4px 2px 0; font-size: 13px; font-weight: 600; }
.mode:active { background: var(--blue-soft); }
.mode.sm { padding: 1px 6px 1px 4px; font-size: 10.5px; margin-right: 3px; gap: 2px; }
.leg-strip .est { display: none; }
.est { font-size: 11px; margin-left: 2px; }
.leg-strip { position: absolute; left: 2px; right: 2px; height: 20px; z-index: 2; display: flex; align-items: center; gap: 6px; padding: 0 4px; overflow: hidden; white-space: nowrap;
  background: color-mix(in srgb, var(--card) 85%, transparent); border-top: 1px dashed var(--muted); font-size: 11px; color: var(--muted); }
.leg-strip .from { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.leg-strip .modes { flex: 0 0 auto; display: flex; align-items: center; }
.leg-strip .mode.sm { background: var(--card); }
.steps { padding-left: 20px; } .steps li { margin: 4px 0; }

/* time grid */
.tgrid { position: relative; display: grid; grid-template-columns: var(--gutter) 1fr; padding-top: 10px; padding-bottom: 24px; }
.tgrid.cols-7 { grid-template-columns: var(--gutter) repeat(7, 1fr); min-width: 100%; }
.hours { position: relative; }
.hours div { height: var(--hour); font-size: 10px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.col { position: relative; border-left: 1px solid var(--line); background:
  repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour)); }
.col.today { background-color: color-mix(in srgb, var(--blue) 8%, transparent); }
.ev { position: absolute; left: 2px; right: 2px; border-radius: 6px; padding: 3px 6px; overflow: hidden; font-size: 12px; line-height: 1.2;
  color: var(--event-ink); background: var(--event); border-left: 3px solid rgba(0,0,0,.25); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.ev.meeting { background: var(--meeting); color: var(--meeting-ink); border-left-color: rgba(0,0,0,.2); }
.ev.other { background: var(--other); color: var(--other-ink); border-left-color: var(--line); box-shadow: none; }
.ev.maybe { background: repeating-linear-gradient(45deg, var(--event) 0 6px, color-mix(in srgb, var(--event) 75%, var(--card)) 6px 12px); }
.ev.meeting.maybe { background: repeating-linear-gradient(45deg, var(--meeting) 0 6px, color-mix(in srgb, var(--meeting) 60%, var(--card)) 6px 12px); }
.ev.cancelled { background: var(--cancel); color: var(--ink); text-decoration: line-through; opacity: .6; }
.ev b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev small { display: block; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.short { padding-top: 1px; line-height: 1.1; } .ev.short b { display: inline; } .ev.short small { display: inline; margin-left: 4px; }
.ev.tiny small { display: none; }
.ev .ic { position: absolute; top: 2px; right: 4px; font-size: 11px; }
.week .ev { font-size: 9px; padding: 2px 3px; border-radius: 4px; left: 1px; right: 1px; }
.week .ev small, .week .ev .ic { display: none; }
.week .hours div { font-size: 9px; }
.week .tgrid { --gutter: 28px; }
.whead { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: 28px repeat(7, 1fr); background: var(--card); border-bottom: 1px solid var(--line); }
.whead div { text-align: center; font-family: var(--serif); font-size: 11px; padding: 6px 0; color: var(--muted); }
.whead div b { display: block; font-size: 13px; color: var(--ink); }
.whead div.today b { color: var(--blue); }
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--warn); z-index: 2; pointer-events: none; }
.nowline::before { content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* map */
#map { flex: 1; min-height: 0; }
.leaflet-tile-pane { filter: grayscale(1) contrast(.92) brightness(1.04); }
@media (prefers-color-scheme: dark) { .leaflet-tile-pane { filter: grayscale(1) invert(1) brightness(.78) contrast(.9); } }
.map-card { background: var(--card); border-top: 1px solid var(--line); padding: 10px 14px 20px; font-size: 13px; height: 36%; flex: 0 0 36%; overflow: auto; }
.map-card .row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.map-card .row:last-child { border-bottom: 0; }
.map-card .n { flex: 0 0 22px; height: 22px; border-radius: 50%; background: var(--blue); color: var(--grey); font-size: 11px; font-weight: 700; text-align: center; line-height: 22px; }
.map-card .n.hotel { background: var(--grey); color: #fff; }
.map-card .row > div:last-child b { font-weight: 600; }
.map-card .leg { color: var(--muted); font-size: 12px; }
.leaflet-container { font: 11px/1.3 -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); }
.leaflet-control-attribution { font-size: 9px; opacity: .8; }
.leaflet-popup-content { font-size: 13px; }
.pin { width: 24px; height: 24px; border-radius: 50%; background: var(--blue); color: var(--grey); font-weight: 700; font-size: 11px; text-align: center; line-height: 24px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin.hotel { background: var(--grey); color: #fff; } .pin.venue { background: var(--amber); color: var(--grey); font-size: 9px; } .pin.me { background: var(--coral); color: #fff; } .pin.dim { background: #d8d4d3; color: #6f6a6a; border-color: #f5f4f3; }

/* sheet */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--card); border-radius: 18px 18px 0 0;
  padding: 10px 18px calc(var(--safe-bottom) + 18px); max-height: 88vh; overflow: auto; box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
.sheet .handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.sheet .close { position: absolute; top: 10px; right: 14px; width: 30px; height: 30px; border-radius: 50%; background: var(--bg); color: var(--muted); font-size: 16px; line-height: 30px; text-align: center; }
.sheet h2 { margin: 0 0 6px; font-family: var(--serif); font-weight: 600; font-size: 20px; line-height: 1.25; }
.sheet .meta { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.sheet .tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-right: 6px; background: var(--bg); border: 1px solid var(--line); }
.sheet .tag.qr { background: color-mix(in srgb, var(--amber) 25%, var(--card)); color: #7a5a14; border-color: var(--amber); }
.sheet .tag.badge { background: var(--blue-soft); color: #1d5f80; border-color: var(--blue); }
.sheet .tag.cancel { background: color-mix(in srgb, var(--coral) 20%, var(--card)); color: var(--coral); }
.sheet .tag.meeting { background: var(--blue-soft); color: #1d5f80; border-color: var(--blue); }
.sheet .tag.event { background: var(--grey); color: #fff; border-color: var(--grey); }
@media (prefers-color-scheme: dark) { .sheet .tag.qr { color: var(--amber); } .sheet .tag.badge, .sheet .tag.meeting { background: transparent; color: var(--blue); } .sheet .tag.event { background: #f2f0ef; color: var(--grey); border-color: #f2f0ef; } }
.sheet .sec { margin-top: 14px; }
.sheet .sec h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 14px; color: var(--muted); }
.sheet .people { display: flex; flex-wrap: wrap; gap: 6px; }
.sheet .people span { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.sheet .people span.me { background: var(--blue); color: var(--grey); border-color: var(--blue); }
.sheet .people span.maybe { opacity: .6; border-style: dashed; }
.sheet .btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-family: var(--serif); font-weight: 600; font-size: 15px; text-decoration: none; color: inherit; }
.btn.primary { background: var(--grey); color: #fff; border-color: var(--grey); }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--blue); color: var(--grey); border-color: var(--blue); } }
.qr-box { text-align: center; padding: 14px; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.qr-box img, .qr-box canvas, .qr-box table { max-width: 100%; height: auto; margin: 0 auto; }
.qr-box img { max-height: 60vh; }
.qr-box .who { color: #334155; font-size: 13px; margin-top: 8px; }
.qr-input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: inherit; font: inherit; }
.travel-line { font-size: 13px; color: var(--muted); margin-top: 6px; }
.brief { background: var(--bg); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.brief p { margin: 6px 0; } .brief ul { margin: 2px 0 6px; padding-left: 18px; } .brief li { margin: 2px 0; }
.brief .src { font-size: 12px; } .brief .src a { color: var(--muted); }
.sheet .status { font-size: 13px; color: var(--muted); }

@media (min-width: 700px) {
  #app { max-width: 720px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .sheet { max-width: 720px; margin: 0 auto; }
  .week .ev { font-size: 11px; }
}

/* ---- feature screens (Team, More pages) ---- */
.page { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 10px 12px 48px; }
.ph { font-family: var(--serif); font-weight: 600; font-size: 22px; margin: 6px 0 8px; }
.page .meta { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; font-size: 14px; }
.card h3 { font-family: var(--serif); font-weight: 600; font-size: 15px; margin: 0 0 6px; }
.card.warn { border-left: 4px solid var(--amber); }
.card.list { padding: 4px 14px; }
.card .row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.card .row:last-child { border-bottom: 0; }
.card .row > div:nth-child(2) { flex: 1; min-width: 0; }
.card .row .n { flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--blue); color: var(--grey); font-size: 12px; font-weight: 700; text-align: center; line-height: 34px; }
.card .row .n.ic { background: var(--bg); color: var(--ink); font-size: 16px; }
.card .row .n.busy { background: var(--grey); color: #fff; } .card .row .n.free { background: var(--green); color: #fff; }
.card .leg { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card .leg b.busy { color: var(--ink); } .card .leg b.free { color: var(--green); }
.card .chev { color: var(--muted); font-size: 20px; align-self: center; }
.menu { cursor: pointer; }
.back { font-family: var(--serif); font-size: 16px; color: var(--blue); margin: 2px 0 6px; display: block; }
.small { font-size: 12px; }
.ev-card { border-left: 4px solid var(--other); } .ev-card.mine { border-left-color: var(--blue); }
.ev-card .tm { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.ev-card .going { color: var(--ink); }
.btn.sm { padding: 5px 9px; font-size: 13px; }
.note { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; } .note:last-child { border-bottom: 0; }
.note-form summary { list-style: none; display: inline-block; margin: 8px 0; cursor: pointer; } .note-form summary::-webkit-details-marker { display: none; }
.note-form .qr-input { margin-top: 6px; } .note-form textarea { resize: vertical; }
.taxi { font-family: var(--serif); font-size: 18px; line-height: 1.3; padding: 8px 0; }
.switch { display: flex; align-items: center; gap: 8px; font-weight: 600; } .switch input { width: 20px; height: 20px; accent-color: var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; } .chips .mode.on { background: var(--grey); color: #fff; border-color: var(--grey); }
.ev.iba { background: color-mix(in srgb, var(--amber) 22%, var(--card)); color: var(--ink); border-left-color: var(--amber); box-shadow: none; font-size: 10px; padding: 2px 4px; }
.ev.iba b { white-space: normal; line-height: 1.15; max-height: 100%; } .ev.iba small, .ev.iba .ic { display: none; }
.leg-strip { right: 2px; }
.tabbar { grid-template-columns: repeat(5, 1fr); } .tabbar button { font-size: 14px; }
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-bottom) + 14px); transform: translateX(-50%) translateY(20px); background: var(--grey); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 13px; opacity: 0; transition: .25s; z-index: 30; pointer-events: none; }
#toast.on { opacity: 1; transform: translateX(-50%); }
@media (prefers-color-scheme: dark) { #toast { background: var(--blue); color: var(--grey); } .chips .mode.on { background: var(--blue); color: var(--grey); border-color: var(--blue); } }
