:root {
  --bg: #F6F4F1; --surface: #FFFFFF; --surface-2: #EFECE8; --text: #1D1B19; --muted: #7A746D;
  --line: rgba(0,0,0,.08); --accent: #E2725B; --danger: #D64545; --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121110; --surface: #1E1C1A; --surface-2: #2A2724; --text: #F3F0EC; --muted: #9C958D;
    --line: rgba(255,255,255,.08); --shadow: none; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
#app { max-width: 560px; margin: 0 auto; padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 32px); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; font-size: 17px; color: var(--text); background: var(--surface-2); border: 1.5px solid transparent;
  border-radius: 12px; padding: 12px 14px; width: 100%; outline: none; -webkit-appearance: none; }
input:focus { border-color: var(--accent); background: var(--surface); }
.muted { color: var(--muted); }
.center { display: grid; place-items: center; min-height: 60dvh; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 12px; padding: 12px 18px; font-weight: 600; }
.btn.primary { background: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; }
.btn.ghost { background: var(--surface); box-shadow: var(--shadow); }
.btn.small { padding: 10px 14px; }
.btn.wide { width: 100%; margin-top: 16px; }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); color: #fff; }
.link { color: var(--accent); font-weight: 600; padding: 8px; }
.icon-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); box-shadow: var(--shadow); font-size: 20px; line-height: 1; }

/* Auth & onboarding */
.auth { display: flex; flex-direction: column; gap: 16px; padding-top: 6vh; text-align: center; }
.brand img { width: 88px; height: 88px; border-radius: 22px; box-shadow: var(--shadow); }
.brand h1 { margin: 12px 0 4px; font-size: 34px; letter-spacing: -.02em; }
.brand p { margin: 0; }
.form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.form h2 { margin: 0; font-size: 20px; }
.form p { margin: -6px 0 2px; font-size: 15px; }
.hint { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 15px; }

/* Home */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 8px 0 14px; }
.eyebrow { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.top h1 { margin: 2px 0 0; font-size: 28px; line-height: 1.15; letter-spacing: -.02em; }
.people { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); box-shadow: var(--shadow);
  border-radius: 999px; padding: 4px 12px 4px 4px; font-size: 15px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent);
  color: #fff; font-size: 12px; font-weight: 700; }
.invite { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; border: 1.5px dashed var(--accent); box-shadow: none; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { position: relative; aspect-ratio: 1 / 1; border-radius: 22px; padding: 16px; display: flex; flex-direction: column;
  justify-content: flex-end; background: var(--tile); color: #fff; box-shadow: var(--shadow); overflow: hidden; transition: transform .12s; }
.tile::before { content: ''; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(255,255,255,.18), rgba(0,0,0,.08)); }
.tile:active { transform: scale(.97); }
.tile > * { position: relative; }
.tile-ic { position: absolute !important; top: 14px; left: 14px; width: 44px; height: 44px; border-radius: 13px; background: rgba(255,255,255,.22); display: grid; place-items: center; }
.tile-ic .ic { width: 26px; height: 26px; }
.tile-name { font-weight: 700; font-size: 18px; line-height: 1.15; }
.tile-meta { font-size: 13px; opacity: .9; margin-top: 2px; min-height: 1.2em; }
.tile.soon { opacity: .4; filter: saturate(.5); }

/* Module chrome */
.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 4px 0 16px; min-height: 44px; }
.back { color: var(--tile, var(--accent)); font-weight: 600; justify-self: start; padding: 8px 0; white-space: nowrap; }
.bar-title { margin: 0; font-size: 17px; font-weight: 700; text-align: center; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 50vw; }
.bar-actions { justify-self: end; display: flex; gap: 8px; }
.module .btn.primary { background: var(--tile); }
.module input:focus { border-color: var(--tile); }

/* Lists */
.list-cards { display: flex; flex-direction: column; gap: 10px; }
.list-card { display: flex; align-items: center; gap: 14px; background: var(--surface); box-shadow: var(--shadow); border-radius: 16px; padding: 14px 16px; }
.list-card:active { opacity: .7; }
.lc-emoji { font-size: 26px; }
.lc-name { flex: 1; font-weight: 600; }
.lc-count { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; display: grid; place-items: center;
  background: var(--tile); color: #fff; font-size: 14px; font-weight: 700; }
.lc-count.zero { background: var(--surface-2); color: var(--muted); }
.add-row { display: flex; gap: 8px; margin-bottom: 14px; position: sticky; top: calc(var(--safe-top) + 4px); z-index: 2; }
.add-row input { background: var(--surface); box-shadow: var(--shadow); }
.items { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.items:empty { display: none; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); min-height: 52px; }
.item:last-child { border-bottom: 0; }
.item.pending { opacity: .5; }
.check { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); position: relative; }
.item.checked .check { background: var(--tile); border-color: var(--tile); }
.item.checked .check::after { content: ''; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.item .text { flex: 1; word-break: break-word; }
.item.checked .text { color: var(--muted); text-decoration: line-through; }
.by { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--muted);
  font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.items .empty { padding: 18px; color: var(--muted); text-align: center; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 4px 8px; font-size: 13px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.section-head:empty { display: none; }
.section-head .link { color: var(--tile); text-transform: none; letter-spacing: 0; font-size: 15px; padding: 4px; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

/* Settings */
.settings { display: flex; flex-direction: column; gap: 12px; }
.settings .bar { margin-bottom: 4px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.card > .row:last-child { border-bottom: 0; }
.row .label { color: var(--muted); font-size: 15px; }
.code { font: 700 22px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.section-title { margin: 8px 4px 0; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* Overlays */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade .15s; }
.overlay.mid { align-items: flex-start; padding: calc(var(--safe-top) + 10vh) 16px 0; }
.sheet { width: 100%; max-width: 560px; background: var(--bg); border-radius: 22px 22px 0 0; padding: 16px 16px calc(var(--safe-bottom) + 16px);
  display: flex; flex-direction: column; gap: 10px; animation: up .2s ease-out; }
.sheet.modal { border-radius: 22px; padding-bottom: 16px; }
.sheet h3 { margin: 4px 0; font-size: 15px; text-align: center; color: var(--muted); font-weight: 600; }
.sheet p { margin: 0 0 4px; text-align: center; color: var(--muted); font-size: 15px; }
.sheet .btn { width: 100%; background: var(--surface); }
.sheet .btn.primary { background: var(--accent); color: #fff; }
.sheet .btn.danger-fill { background: var(--danger); color: #fff; }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 24px); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 15px; z-index: 60; max-width: 90vw; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }

/* ═══ Shared controls ═══ */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 2px; flex: none; }
.seg-btn { padding: 6px 10px; font-size: 14px; font-weight: 600; border-radius: 8px; color: var(--muted); }
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg.wide { display: flex; }
.seg.wide .seg-btn { flex: 1; padding: 9px 8px; }
.seg-btn.on[style] { background: var(--c); color: #fff; }
.pill { padding: 6px 12px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-size: 14px; font-weight: 600; color: var(--tile, var(--accent)); flex: none; }
.icon-btn.fill { background: var(--tile, var(--accent)); color: #fff; }
.icon-btn.sm { width: 34px; height: 34px; font-size: 18px; }
.small { font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); display: inline-block; flex: none; }
textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1.5px solid transparent; border-radius: 12px;
  padding: 12px 14px; width: 100%; outline: none; resize: vertical; }
select { font: inherit; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 0; color: var(--text); }
.switch { appearance: none; -webkit-appearance: none; width: 51px !important; height: 31px; border-radius: 999px; background: var(--surface-2);
  position: relative; padding: 0; flex: none; transition: background .2s; border: 0 !important; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.switch:checked { background: #34C759; }
.switch:checked::after { transform: translateX(20px); }

/* ═══ Calendar ═══ */
:root { --cal-bg: #FFFFFF; --cal-line: rgba(0,0,0,.065); --cal-today: rgba(0,0,0,.045); }
@media (prefers-color-scheme: dark) { :root { --cal-bg: #171615; --cal-line: rgba(255,255,255,.075); --cal-today: rgba(255,255,255,.06); } }
html:has(.cal-page), body:has(.cal-page) { background: var(--cal-bg); }
#app:has(.cal-page) { padding-bottom: 0; }
.cal-page > .bar { display: none; }
.cal-toolbar { display: flex; align-items: center; gap: 2px; margin: 0 -8px 6px; min-height: 44px; }
.tb-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--text); flex: none; transition: background .15s; }
.tb-btn:active { background: var(--surface-2); }
.tb-btn .ic { width: 23px; height: 23px; }
.cal-title { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; font-size: 23px; font-weight: 800;
  letter-spacing: -.02em; white-space: nowrap; padding-left: 2px; }
.cal-title .caret { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid var(--muted); margin-top: 3px; flex: none; }
.cal-month-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; padding: 0; font-size: 16px; }
.today-btn span { width: 24px; height: 24px; border: 1.8px solid currentColor; border-radius: 7px; display: grid; place-items: center; font-size: 11.5px; font-weight: 800; }
.vseg { position: relative; display: flex; background: var(--surface-2); border-radius: 11px; padding: 2px; flex: none; margin: 0 4px; }
.vseg button { position: relative; z-index: 1; width: 34px; height: 30px; display: grid; place-items: center; color: var(--muted); transition: color .2s; }
.vseg button.on { color: var(--text); }
.vseg button .ic { width: 19px; height: 19px; }
.vseg .ind { position: absolute; top: 2px; left: 2px; width: 34px; height: 30px; border-radius: 9px; background: var(--cal-bg);
  box-shadow: 0 1px 3px rgba(0,0,0,.14); transition: transform .3s cubic-bezier(.22,.9,.24,1); }
.cal-chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 8px; scrollbar-width: none; }
.cal-chips::-webkit-scrollbar { display: none; }
.cal-chip { display: inline-flex; align-items: center; gap: 7px; flex: none; padding: 4px 12px 4px 5px; border-radius: 12px; border: 1.5px solid var(--line);
  font-size: 13.5px; font-weight: 600; max-width: 180px; transition: color .2s, border-color .2s; }
.cal-chip .box { width: 22px; height: 22px; border-radius: 7px; background: var(--c); display: grid; place-items: center; color: #fff; flex: none; border: 1.5px solid var(--c); transition: background .2s; }
.cal-chip .box .ic { width: 14px; height: 14px; }
.cal-chip.off { color: var(--muted); }
.cal-chip.off .box { background: transparent; }
.cal-chip.off .box .ic { opacity: 0; }
.cal-chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-stage { height: calc(100dvh - var(--cal-top, 150px) - env(safe-area-inset-bottom)); position: relative; overflow: hidden; margin: 0 -16px; }

/* Month grid — TimeTree-like */
.cal-month { height: 100%; display: flex; flex-direction: column; will-change: transform; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); height: 27px; align-items: center; text-align: center; font-size: 10.5px;
  font-weight: 600; letter-spacing: .06em; color: var(--muted); flex: none; border-bottom: 1px solid var(--cal-line); }
.cal-dow .sun { color: #E5484D; }
.cal-grid { flex: 1; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.cal-week { position: relative; border-bottom: 1px solid var(--cal-line); }
.cal-days { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 5px; position: relative; transition: background-color .2s; }
.cal-day .num { font-size: 13px; font-weight: 500; line-height: 18px; min-width: 22px; text-align: center; }
.cal-day.sun .num, .cal-day.hol .num { color: #E5484D; }
.cal-day.out .num { opacity: .35; }
.cal-day.today { background: var(--cal-today); }
.cal-day.today .num { font-weight: 800; }
.cal-day.sel { background: color-mix(in srgb, var(--tile) 15%, transparent); }
.cal-day.sel .num { font-weight: 800; color: var(--tile); opacity: 1; }
.cal-day .more { position: absolute; bottom: 2px; left: 0; right: 0; font-size: 10px; font-weight: 700; color: var(--muted); }
.cal-bars { position: absolute; inset: 0 0 auto 0; display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; pointer-events: none; }
.evbar { margin: 0 1.5px; height: 17px; line-height: 17px; font-size: 11px; font-weight: 600; padding: 0 4px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; min-width: 0; text-align: left; }
.evbar.span { text-align: center; }
.evbar.solid { background: var(--c); color: #fff; }
.evbar.tint { background: color-mix(in srgb, var(--c) 16%, transparent); color: color-mix(in srgb, var(--c) 80%, var(--text)); }
.evbar.ext { background: transparent !important; box-shadow: inset 0 0 0 1.3px color-mix(in srgb, var(--c) 75%, transparent); color: color-mix(in srgb, var(--c) 85%, var(--text)) !important; }
.evbar.cl { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.evbar.cr { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.evbar.hol { color: #E5484D; background: none; font-size: 9.5px; padding: 0 2px; text-align: center; text-overflow: ellipsis; }

/* Floating add button */
.cal-fab { position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 20px); width: 54px; height: 54px; border-radius: 50%;
  background: var(--cal-bg); color: var(--text); box-shadow: 0 6px 22px rgba(0,0,0,.16), 0 1px 3px rgba(0,0,0,.12); display: grid; place-items: center;
  z-index: 20; transition: transform .3s cubic-bezier(.22,.9,.24,1), opacity .2s; }
.cal-fab .ic { width: 28px; height: 28px; }
.cal-fab:active { transform: scale(.93); }
.cal-fab.hidden { transform: scale(.5); opacity: 0; pointer-events: none; }
@media (prefers-color-scheme: dark) { .cal-fab { background: #2A2826; } }

/* Day panel */
.day-sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--cal-bg); border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.13); display: flex; flex-direction: column; z-index: 5; will-change: transform; }
.ds-grip-zone { padding: 8px 0 2px; touch-action: none; flex: none; }
.ds-grip { width: 38px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--muted) 40%, transparent); margin: 0 auto; }
.ds-head { display: flex; align-items: center; gap: 8px; padding: 4px 14px 8px 18px; flex: none; touch-action: none; }
.ds-title { flex: 1; text-align: left; display: flex; flex-direction: column; min-width: 0; }
.ds-title strong { font-size: 18px; letter-spacing: -.01em; }
.ds-sub { font-size: 13px; color: var(--tile); font-weight: 600; }
.ds-head .icon-btn { box-shadow: none; background: var(--surface-2); }
.ds-head .icon-btn.fill { background: var(--tile); }
.ds-list { overflow-y: auto; padding: 0 12px 12px; flex: 1; touch-action: pan-y; }
.ag-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 6px; border-bottom: 1px solid var(--cal-line); text-align: left; }
.ag-row:last-child { border-bottom: 0; }
.ag-time { width: 66px; flex: none; font-size: 13px; font-weight: 600; line-height: 1.25; }
.ag-time small { display: block; color: var(--muted); font-weight: 500; }
.ag-bar { width: 4px; align-self: stretch; border-radius: 2px; background: var(--c); flex: none; }
.ag-row.ext .ag-bar { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); }
.ag-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ag-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who { display: inline-flex; gap: 3px; flex: none; }
.who-b { min-width: 24px; height: 22px; padding: 0 6px; border-radius: 999px; color: #fff; font-size: 10.5px; font-weight: 700; display: inline-grid; place-items: center; flex: none; }
.ext-tag { flex: none; max-width: 90px; font-size: 11px; font-weight: 600; color: var(--c); border: 1.3px solid var(--c); border-radius: 999px; padding: 2px 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Week / Day time grids */
.tg { height: 100%; display: flex; flex-direction: column; }
.tg-move { flex: 1; min-height: 0; display: flex; flex-direction: column; will-change: transform; }
.tg-head, .tg-allday { display: flex; border-bottom: 1px solid var(--cal-line); flex: none; }
.tg-gutter { width: 44px; flex: none; font-size: 10px; color: var(--muted); padding-right: 6px; display: flex; align-items: center; justify-content: flex-end; }
.tg-headcols { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); }
.tg-hd, .strip-day { display: flex; flex-direction: column; align-items: center; padding: 3px 0 6px; gap: 3px; }
.sd-dow { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; color: var(--muted); }
.sd-num { font-size: 15px; font-weight: 600; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; transition: background .2s, color .2s; }
.tg-hd.sun .sd-dow, .strip-day.sun .sd-dow { color: #E5484D; }
.tg-hd.today .sd-num { background: var(--tile); color: #fff; }
.tg-strip { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 8px; flex: none; touch-action: pan-y; }
.strip-day.sel .sd-num { background: var(--text); color: var(--cal-bg); }
.strip-day.today:not(.sel) .sd-num { color: var(--tile); font-weight: 800; }
.strip-day.today.sel .sd-num { background: var(--tile); color: #fff; }
.sd-dot { width: 5px; height: 5px; border-radius: 50%; }
.sd-dot.on { background: color-mix(in srgb, var(--muted) 70%, transparent); }
.tg-daytitle { padding: 2px 16px 8px; font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--cal-line); flex: none; }
.tg-hol { color: #E5484D; font-weight: 600; margin-left: 8px; font-size: 13px; }
.tg-adbars { flex: 1; display: grid; row-gap: 2px; padding: 3px 0; min-width: 0; }
.tg-adbars .evbar { height: 18px; line-height: 18px; font-size: 11px; }
.ad-more { font-size: 10.5px; color: var(--muted); font-weight: 700; }
.tg-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative; touch-action: pan-y; }
.tg-body { position: relative; margin-left: 44px; }
.tg-hour { position: absolute; left: -44px; right: 0; border-top: 1px solid var(--cal-line); height: 0; pointer-events: none; }
.tg-hour span { position: absolute; left: 0; width: 38px; top: -7px; text-align: right; font-size: 10px; color: var(--muted); background: var(--cal-bg); padding-right: 2px; }
.tg-cols { position: absolute; inset: 0; display: grid; }
.tg-col { position: relative; border-left: 1px solid var(--cal-line); }
.tg-col.today { background: var(--cal-today); }
.tg-ev { position: absolute; border-radius: 6px; padding: 3px 5px; background: color-mix(in srgb, var(--c) 20%, var(--cal-bg)); border-left: 3px solid var(--c);
  text-align: left; overflow: hidden; display: flex; flex-direction: column; color: color-mix(in srgb, var(--c) 62%, var(--text)); z-index: 1; }
.tg-ev.ext { background: var(--cal-bg); border: 1.3px solid color-mix(in srgb, var(--c) 70%, transparent); border-left-width: 3px; }
.tg-ev-t { font-size: 12px; font-weight: 700; line-height: 1.2; overflow: hidden; }
.tg-ev-s { font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-ev.tiny { padding: 1px 4px; }
.tg-ev.tiny .tg-ev-t { white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.tg-7 .tg-ev { padding: 2px 3px; border-left-width: 2px; }
.tg-7 .tg-ev-t { font-size: 10.5px; word-break: normal; overflow-wrap: normal; hyphens: none; line-height: 1.15; }
.tg-7 .tg-ev-s { font-size: 9.5px; }
.tg-now { position: absolute; left: -1px; right: 0; height: 2px; background: #E5484D; z-index: 2; pointer-events: none; }
.tg-now::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #E5484D; }

/* Panels: event detail / editor / settings */
.sheet.panel { max-height: 92dvh; overflow-y: auto; gap: 12px; padding: 14px 16px calc(env(safe-area-inset-bottom) + 20px); }
.sheet.panel > * { flex-shrink: 0; }
.panel .btn.ghost { background: var(--surface); box-shadow: var(--shadow); }
.ev-hero { background: var(--c); color: #fff; border-radius: 18px; padding: 16px; }
.ev-hero h2 { margin: 2px 0 6px; font-size: 24px; line-height: 1.15; letter-spacing: -.01em; }
.ev-type { font-size: 13px; font-weight: 700; opacity: .92; }
.ev-when { font-size: 15px; opacity: .95; }
.ev-rep { margin-top: 6px; font-size: 13px; font-weight: 600; opacity: .92; }
.ev-rows { padding: 2px 16px; }
.ev-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.ev-row:last-child { border-bottom: 0; }
.ev-row.link span:last-child { color: #3D7BE0; }
.ev-ic { width: 22px; text-align: center; flex: none; }
.ev-notes { white-space: pre-wrap; }
.ev-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-card { padding: 8px 14px 12px; }
.cm { display: flex; gap: 10px; padding: 8px 0; align-items: flex-start; }
.cm-body { flex: 1; font-size: 15px; min-width: 0; word-break: break-word; }
.cm-meta { font-size: 13px; }
.cm-del { color: var(--muted); font-size: 18px; padding: 0 4px; }
.cm-form { display: flex; gap: 8px; margin-top: 6px; }
.cm-form input { flex: 1; min-width: 0; }
.cm-form .btn { flex: none; width: auto !important; }
.cm-empty { padding: 6px 0 8px; font-size: 14px; }
.ev-actions { display: flex; gap: 8px; }
.ev-actions .btn { flex: 1; }
.ed-head { display: flex; justify-content: space-between; align-items: center; min-height: 36px; }
.ed-head .link { padding: 6px 2px; }
.link.strong { font-weight: 800; }
.ed-title { font-size: 22px !important; font-weight: 700; background: var(--surface) !important; box-shadow: var(--shadow); }
.ed-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 4px 4px -4px; display: flex; align-items: center; gap: 6px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--surface);
  box-shadow: var(--shadow); font-size: 14px; font-weight: 600; border: 2px solid transparent; }
.chip-btn.on { border-color: var(--c, var(--text)); }
.chip-btn.add { color: var(--muted); }
.ed-card { padding: 6px 14px; display: flex; flex-direction: column; gap: 6px; }
.ed-card > input, .ed-card > textarea { margin: 4px 0; }
.ed-line { display: flex; align-items: center; gap: 8px; min-height: 46px; }
.ed-card .ed-line + .ed-line { border-top: 1px solid var(--line); }
.ed-line .label { flex: 1; font-size: 16px; }
.ed-line input[type=date], .ed-line input[type=time] { width: auto; flex: none; padding: 8px 10px; }
.ed-line.dt .label { flex: none; width: 48px; font-size: 15px; }
.ed-line.dt input[type=date] { flex: 1.2 1 0; min-width: 0; padding: 8px; }
.ed-line.dt input[type=time] { flex: 1.1 1 0; min-width: 0; padding: 8px; }
.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; padding: 2px; }
.sw { aspect-ratio: 1; border-radius: 50%; border: 3px solid transparent; }
.sw.on { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--bg); }
.types-card { padding: 2px 14px; }
.type-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); text-align: left; }
.type-row span:nth-child(2) { flex: 1; }
.type-row.add { color: var(--accent); font-weight: 600; border-bottom: 0; }
.emoji-in { width: 64px !important; flex: none; text-align: center; font-size: 22px !important; }

/* Line icons */
.ic { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none; }
.ic svg { width: 100%; height: 100%; display: block; }
.ic.inline { width: 1.05em; height: 1.05em; vertical-align: -0.17em; }
.icon-btn .ic { width: 21px; height: 21px; }
.ev-ic .ic { width: 20px; height: 20px; color: var(--muted); }
.lc-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--tile) 14%, transparent); color: var(--tile); }
.lc-count .ic { width: 15px; height: 15px; }
.emoji-in { font-size: 15px !important; width: 110px !important; }

/* Sync & calendar links */
.add-cal { display: flex; gap: 8px; }
.add-cal .btn { flex: 1; font-size: 14px; padding: 11px 8px; }
.btn.disabled { opacity: .45; }
.btn .ic.inline { margin-right: 2px; }
.wide-btn { width: 100%; }
.sync-intro { display: flex; flex-direction: column; gap: 2px; margin: 6px 4px -2px; }
.sync-card { display: flex; flex-direction: column; gap: 10px; }
.sync-card p, .panel .howto p { text-align: left; }
.ed-label.flat { margin: 0 0 -4px; }
.howto { font-size: 14px; }
.howto summary { color: var(--accent); font-weight: 600; padding: 4px 0; cursor: pointer; }
.howto p, .howto ol { margin: 6px 0; }
.howto ol { padding-left: 20px; }
.link-box { font: 12px ui-monospace, Menlo, monospace; background: var(--surface-2); padding: 8px 10px; border-radius: 10px; word-break: break-all; user-select: all; -webkit-user-select: all; }
.danger-link { color: var(--danger); align-self: flex-start; padding: 2px 0; font-size: 14px; }
.err { color: var(--danger); }
.cal-row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cal-row-main small { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-hero.ext { background: var(--cal-bg, var(--surface)); color: var(--text); box-shadow: inset 0 0 0 2px var(--c); }
.ev-hero.ext .ev-type { color: var(--c); }
.center-text { text-align: center; margin: 0; }
