/* MAD Calendar. Tokens follow the MAD Biz App (mad-app/public/index.html + mad-ui.css):
   MAD red brand, Inter body, Poppins display, light first with a dark theme. ASCII only. */
:root {
  --mmm-brand: #dc2626; --mmm-brand-dark: #b91c1c; --mmm-brand-soft: rgba(220,38,38,0.10);
  --font-display: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, Menlo, Consolas, monospace;
  --bg: #F7F6F4; --bg-elev-1: #FFF; --bg-elev-2: #FFF; --bg-elev-3: #F1EFEC; --fg: #0A0A0A;
  --fg-muted: rgba(10,10,10,0.62); --fg-dim: rgba(10,10,10,0.45);
  --rule: rgba(10,10,10,0.08); --rule-strong: rgba(10,10,10,0.16);
  --hover: rgba(10,10,10,0.05); --active: rgba(220,38,38,0.10);
  --shadow-md: 0 8px 24px -8px rgba(0,0,0,0.10); --shadow-lg: 0 20px 50px -20px rgba(0,0,0,0.25);
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px; --radius-xl: 22px;
  --ws-accent: var(--mmm-brand); --ws-accent-strong: #9E0C24; --ws-focus: var(--ws-accent-strong);
  --top-h: 60px; --side-w: 264px; --hour-h: 48px; --gutter: 56px;
  --now: #E5173A;
  --dur-1: 120ms; --dur-2: 200ms; --ease-out: cubic-bezier(.2,.8,.2,1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0A0A0A; --bg-elev-1: #111; --bg-elev-2: #161616; --bg-elev-3: #1c1c1c;
  --fg: #F5F4F2; --fg-muted: rgba(245,244,242,0.62); --fg-dim: rgba(245,244,242,0.42);
  --rule: rgba(255,255,255,0.08); --rule-strong: rgba(255,255,255,0.14);
  --hover: rgba(255,255,255,0.06); --active: rgba(220,38,38,0.18);
  --shadow-md: 0 8px 24px -8px rgba(0,0,0,0.6); --shadow-lg: 0 20px 50px -20px rgba(0,0,0,0.75);
  --ws-accent-strong: #FF5468; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0A0A; --bg-elev-1: #111; --bg-elev-2: #161616; --bg-elev-3: #1c1c1c;
    --fg: #F5F4F2; --fg-muted: rgba(245,244,242,0.62); --fg-dim: rgba(245,244,242,0.42);
    --rule: rgba(255,255,255,0.08); --rule-strong: rgba(255,255,255,0.14);
    --hover: rgba(255,255,255,0.06); --active: rgba(220,38,38,0.18);
    --shadow-md: 0 8px 24px -8px rgba(0,0,0,0.6); --shadow-lg: 0 20px 50px -20px rgba(0,0,0,0.75);
    --ws-accent-strong: #FF5468; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 400 14px/1.45 var(--font-body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ws-accent-strong); }
:focus-visible { outline: 2px solid var(--ws-focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons + inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--rule-strong); background: var(--bg-elev-1); cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap; transition: background var(--dur-1); }
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--mmm-brand); border-color: var(--mmm-brand); color: #fff; }
.btn-primary:hover { background: var(--mmm-brand-dark); border-color: var(--mmm-brand-dark); }
.btn-danger { color: #fff; background: #b91c1c; border-color: #b91c1c; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--hover); }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 999px; border: 0; background: transparent; cursor: pointer; color: var(--fg-muted); }
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn svg, .btn svg { width: 18px; height: 18px; }
input[type=text], input[type=email], input[type=url], input[type=number], input[type=date], input[type=time], input[type=search], select, textarea {
  min-height: 38px; padding: 7px 10px; border: 1px solid var(--rule-strong); border-radius: var(--radius-md); background: var(--bg-elev-1); width: 100%; }
textarea { min-height: 76px; resize: vertical; }
label.field { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--fg-muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--fg-muted); }
.dim { color: var(--fg-dim); }
.mono { font-family: var(--font-mono); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: var(--bg-elev-3); font-size: 12px; font-weight: 600; }

/* Shell */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0,1fr); grid-template-rows: var(--top-h) minmax(0,1fr); height: 100vh; height: 100dvh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--rule); background: var(--bg-elev-1); position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding-right: 8px; text-decoration: none; color: var(--fg); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, #9E0C24, #dc2626 55%, #F0572B); color: #fff; box-shadow: 0 6px 18px -6px rgba(200,16,46,0.45); flex: 0 0 auto; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font: 700 16px/1 var(--font-display); letter-spacing: -0.01em; white-space: nowrap; }
.brand-name small { display: block; font: 600 9px/1 var(--font-body); letter-spacing: .18em; text-transform: uppercase; color: var(--fg-muted); margin-top: 3px; }
.nav-title { font: 600 20px/1.1 var(--font-display); letter-spacing: -0.01em; margin: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 0 auto; }
.toggle svg { width: 16px; height: 16px; color: var(--fg-muted); }
.today-btn { font-weight: 700; }
.spacer { flex: 1 1 auto; }
.quick { position: relative; flex: 0 1 380px; min-width: 160px; }
.quick input { border-radius: 999px; padding-left: 34px; background: var(--bg-elev-3); border-color: transparent; }
.quick input:focus { background: var(--bg-elev-1); border-color: var(--rule-strong); }
.quick .q-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--fg-dim); width: 16px; height: 16px; pointer-events: none; }
.quick-preview { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--bg-elev-1); border: 1px solid var(--rule-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 10px 12px; font-size: 13px; z-index: 30; }
.quick-preview strong { font-weight: 700; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--bg-elev-3); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--fg-muted); min-height: 30px; }
.seg button[aria-pressed="true"] { background: var(--bg-elev-1); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--mmm-brand); color: #fff; display: grid; place-items: center; font-weight: 700; border: 0; cursor: pointer; }

.sidebar { border-right: 1px solid var(--rule); background: var(--bg-elev-1); overflow-y: auto; padding: 14px 12px 24px; display: flex; flex-direction: column; gap: 18px; }
.create-btn { justify-content: flex-start; min-height: 44px; padding: 0 18px 0 14px; font-size: 14px; box-shadow: var(--shadow-md); align-self: flex-start; }
.side-h { font: 700 11px/1.2 var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--fg-muted); margin: 0 0 6px 6px; display: flex; align-items: center; justify-content: space-between; }
.cal-list { list-style: none; margin: 0; padding: 0; }
.cal-list li { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; }
.cal-list li:hover { background: var(--hover); }
.cal-list label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.cal-list .cal-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swatch { width: 16px; height: 16px; border-radius: 5px; border: 2px solid var(--c); background: var(--c); flex: 0 0 auto; display: grid; place-items: center; }
input.cal-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; }
input.cal-toggle:not(:checked) + .swatch { background: transparent; }
input.cal-toggle:focus-visible + .swatch { outline: 2px solid var(--ws-focus); outline-offset: 2px; }
.cal-list .tag { font-size: 10px; font-weight: 700; color: var(--fg-dim); text-transform: uppercase; }
.side-links { display: grid; gap: 2px; margin-top: auto; }
.side-links button, .side-links a { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; background: none; border: 0; text-align: left; cursor: pointer; color: var(--fg); text-decoration: none; font-weight: 500; }
.side-links button:hover, .side-links a:hover { background: var(--hover); }
.side-links svg { width: 18px; height: 18px; color: var(--fg-muted); }

/* Mini month */
.mini { user-select: none; }
.mini-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 4px 6px; font-weight: 700; font-size: 13px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; }
.mini-grid .dow { color: var(--fg-dim); font-weight: 600; padding: 4px 0; }
.mini-grid button { border: 0; background: none; width: 30px; height: 30px; margin: 1px auto; border-radius: 50%; cursor: pointer; font-size: 12px; }
.mini-grid button:hover { background: var(--hover); }
.mini-grid button.out { color: var(--fg-dim); }
.mini-grid button.in-range { background: var(--active); }
.mini-grid button.today { background: var(--mmm-brand); color: #fff; font-weight: 700; }

.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg-elev-1); }

/* Time grid (day / week) */
.tg { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.tg-head { display: grid; grid-template-columns: var(--gutter) repeat(var(--days), minmax(0,1fr)); border-bottom: 1px solid var(--rule); padding-right: var(--sbw, 0px); }
.tg-dayhead { text-align: center; padding: 8px 0 6px; cursor: pointer; }
.tg-dayhead .dow { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); }
.tg-dayhead .num { font: 500 24px/1.1 var(--font-display); width: 42px; height: 42px; display: grid; place-items: center; margin: 2px auto 0; border-radius: 50%; }
.tg-dayhead:hover .num { background: var(--hover); }
.tg-dayhead.today .dow { color: var(--mmm-brand); }
.tg-dayhead.today .num { background: var(--mmm-brand); color: #fff; }
.tg-tzlabel { font-size: 10px; color: var(--fg-dim); align-self: end; padding: 0 4px 6px; text-align: right; }
.tg-allday { display: grid; grid-template-columns: var(--gutter) repeat(var(--days), minmax(0,1fr)); border-bottom: 1px solid var(--rule-strong); min-height: 28px; padding-right: var(--sbw, 0px); position: relative; }
.tg-allday .ad-label { font-size: 10px; color: var(--fg-dim); text-align: right; padding: 6px 6px 0 0; }
.tg-allday .ad-cell { border-left: 1px solid var(--rule); padding: 2px 2px 3px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tg-body { flex: 1; overflow-y: auto; position: relative; overscroll-behavior: contain; }
.tg-grid { display: grid; grid-template-columns: var(--gutter) repeat(var(--days), minmax(0,1fr)); position: relative; height: calc(var(--hour-h) * 24); }
.tg-hours { position: relative; }
.tg-hours span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 10px; color: var(--fg-dim); white-space: nowrap; }
.tg-col { position: relative; border-left: 1px solid var(--rule); background-image: repeating-linear-gradient(to bottom, var(--rule) 0, var(--rule) 1px, transparent 1px, transparent var(--hour-h)); touch-action: pan-y; }
.tg-col.today { background-color: rgba(220,38,38,0.025); }
.tg-col.weekend { background-color: var(--bg-elev-3); background-color: color-mix(in srgb, var(--bg-elev-3) 45%, transparent); }
.now-line { position: absolute; left: -1px; right: 0; height: 2px; background: var(--now); z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -6px; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--now); }
.ev { position: absolute; border-radius: 7px; padding: 3px 7px; font-size: 12px; line-height: 1.25; overflow: hidden; cursor: pointer; background: var(--evbg); color: var(--evfg); border-left: 3px solid var(--c); box-shadow: 0 0 0 1px var(--bg-elev-1); touch-action: none; user-select: none; z-index: 2; transition: box-shadow var(--dur-1); }
.ev:hover { z-index: 3; box-shadow: 0 0 0 1px var(--bg-elev-1), var(--shadow-md); }
.ev .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev .s { opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.short { display: flex; gap: 6px; align-items: baseline; padding-top: 1px; }
.ev.tentative { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.35) 6px 10px); }
.ev.ro { cursor: default; }
.ev.selected { box-shadow: 0 0 0 2px var(--ws-focus); z-index: 5; }
.ev.dragging { opacity: .9; box-shadow: var(--shadow-lg); z-index: 20; transition: none; }
.ev .ev-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }
.ev-ghost { position: absolute; left: 2px; right: 6px; border-radius: 7px; background: var(--active); border: 2px dashed var(--mmm-brand); z-index: 6; pointer-events: none; font-size: 12px; padding: 3px 7px; font-weight: 700; }
.chip-ev { display: flex; align-items: center; gap: 6px; border-radius: 6px; padding: 1px 6px; font-size: 12px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; background: var(--evbg); color: var(--evfg); min-width: 0; touch-action: none; user-select: none; }
.chip-ev.timed { background: transparent; color: var(--fg); }
.chip-ev.timed::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: 0 0 auto; }
.chip-ev .tm { color: var(--fg-muted); font-size: 11px; }
.chip-ev.selected { outline: 2px solid var(--ws-focus); }

/* Month */
.month { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.month-dows { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); border-bottom: 1px solid var(--rule); }
.month-dows div { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); padding: 8px 0; }
.month-grid { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); grid-auto-rows: minmax(92px, 1fr); overflow-y: auto; }
.m-cell { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; }
.m-cell.out { background: var(--bg-elev-3); background: color-mix(in srgb, var(--bg-elev-3) 50%, transparent); }
.m-cell.drop { background: var(--active); }
.m-num { border: 0; background: none; cursor: pointer; min-width: 24px; padding: 0 4px; width: auto !important; border-radius: 999px !important; font-size: 12px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; align-self: center; }
.m-cell.out .m-num { color: var(--fg-dim); }
.m-cell.today .m-num { background: var(--mmm-brand); color: #fff; }
.m-more { font-size: 11px; font-weight: 700; color: var(--fg-muted); padding: 0 6px; border: 0; background: none; text-align: left; cursor: pointer; }

/* Agenda */
.agenda { overflow-y: auto; flex: 1; padding: 8px 0 80px; }
.ag-day { display: grid; grid-template-columns: 120px minmax(0,1fr); gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--rule); }
.ag-date { display: flex; gap: 10px; align-items: baseline; }
.ag-date .num { font: 600 24px/1 var(--font-display); }
.ag-date .dw { font-size: 12px; font-weight: 700; color: var(--fg-muted); text-transform: uppercase; }
.ag-day.today .num { color: var(--mmm-brand); }
.ag-items { display: grid; gap: 4px; }
.ag-item { display: grid; grid-template-columns: 14px 130px minmax(0,1fr); gap: 10px; align-items: center; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.ag-item:hover, .ag-item.selected { background: var(--hover); }
.ag-item .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.ag-item .tm { color: var(--fg-muted); font-size: 13px; }
.ag-item .tt { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-empty { padding: 60px 20px; text-align: center; color: var(--fg-muted); }

/* Popover + dialogs */
.pop { position: fixed; z-index: 40; width: min(380px, calc(100vw - 24px)); background: var(--bg-elev-1); border: 1px solid var(--rule-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 14px 16px 16px; }
.pop-actions { display: flex; justify-content: flex-end; gap: 2px; margin: -6px -8px 4px 0; }
.pop h3 { margin: 0 0 4px; font: 600 18px/1.25 var(--font-display); display: flex; gap: 10px; align-items: flex-start; }
.pop h3 .sq { width: 14px; height: 14px; border-radius: 4px; background: var(--c); margin-top: 5px; flex: 0 0 auto; }
.pop .meta { display: grid; gap: 8px; margin-top: 10px; font-size: 13px; }
.pop .meta > div { display: grid; grid-template-columns: 20px minmax(0,1fr); gap: 10px; align-items: start; }
.pop .meta svg { width: 16px; height: 16px; color: var(--fg-muted); margin-top: 1px; }
.pop .desc { white-space: pre-wrap; word-break: break-word; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade var(--dur-2) var(--ease-out); }
@keyframes fade { from { opacity: 0; } }
.dialog { width: min(620px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--bg-elev-1); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 20px; animation: rise var(--dur-2) var(--ease-out); }
.dialog.small { width: min(400px, 100%); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.dialog h2 { margin: 0 0 14px; font: 600 20px/1.2 var(--font-display); }
.dialog .title-input { font: 600 20px/1.2 var(--font-display); border: 0; border-bottom: 2px solid var(--rule-strong); border-radius: 0; padding: 6px 2px; background: transparent; }
.dialog .title-input:focus { border-bottom-color: var(--mmm-brand); outline: none; }
.form-grid { display: grid; gap: 12px; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-4 { display: grid; grid-template-columns: 1.3fr 1fr 1.3fr 1fr; gap: 8px; align-items: end; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.dialog-actions .left { margin-right: auto; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 13px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--mmm-brand); }
.scope-list { display: grid; gap: 6px; margin: 4px 0 0; }
.scope-list label { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--rule-strong); border-radius: var(--radius-md); cursor: pointer; font-weight: 600; }
.scope-list input { accent-color: var(--mmm-brand); }
.kbd { font: 600 11px/1 var(--font-mono); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--rule-strong); border-bottom-width: 2px; background: var(--bg-elev-3); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; font-size: 13px; }

/* Toast */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { background: #1c1c1c; color: #fff; border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow-lg); animation: rise var(--dur-2) var(--ease-out); font-size: 13px; }
.toast button { margin-left: auto; background: none; border: 0; color: #FF8B8B; font-weight: 700; cursor: pointer; padding: 4px 6px; }

/* Settings */
.settings { flex: 1; overflow-y: auto; padding: 20px 24px 80px; }
.settings h1 { font: 600 26px/1.15 var(--font-display); margin: 0 0 4px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin: 16px 0 18px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 11px 12px; font-weight: 600; color: var(--fg-muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--mmm-brand); }
.card { background: var(--bg-elev-1); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 4px; font: 600 16px/1.3 var(--font-display); }
.list { display: grid; gap: 8px; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--radius-md); flex-wrap: wrap; }
.list-item .grow { flex: 1; min-width: 180px; }
.hours-grid { display: grid; gap: 6px; }
.hours-grid .hrow { display: grid; grid-template-columns: 70px 22px 1fr 1fr; gap: 8px; align-items: center; }
.secret { font-family: var(--font-mono); font-size: 12px; padding: 10px; border-radius: var(--radius-md); background: var(--bg-elev-3); word-break: break-all; }
.mail-body { white-space: pre-wrap; font-family: var(--font-mono); font-size: 12px; background: var(--bg-elev-3); padding: 10px; border-radius: var(--radius-md); margin-top: 8px; max-height: 220px; overflow: auto; }

/* Sign in / plain pages */
.signin, body.plain { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.signin-card, .plain-card { width: min(440px, 100%); background: var(--bg-elev-1); border: 1px solid var(--rule); border-radius: var(--radius-xl); padding: 32px 28px; box-shadow: var(--shadow-md); text-align: center; }
.signin-card h1, .plain-card h1 { font: 700 26px/1.15 var(--font-display); margin: 14px 0 6px; }
.signin-card .brand-mark { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto; }
.signin-card .brand-mark svg { width: 32px; height: 32px; }

/* FAB + mobile */
.fab { display: none; position: fixed; right: 18px; bottom: 22px; width: 58px; height: 58px; border-radius: 18px; background: var(--mmm-brand); color: #fff; border: 0; box-shadow: 0 12px 28px -8px rgba(200,16,46,.55); z-index: 20; cursor: pointer; }
.fab svg { width: 26px; height: 26px; }
.mobile-only { display: none !important; }
.quickbar { display: none; }
@media (max-width: 1100px) { .quick { flex-basis: 260px; } .brand-name small { display: none; } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0,1fr); grid-template-rows: var(--top-h) auto minmax(0,1fr); }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 45; transform: translateX(-102%); transition: transform var(--dur-2) var(--ease-out); box-shadow: var(--shadow-lg); padding-top: 18px; }
  .sidebar.open { transform: none; }
  .drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 44; }
  .mobile-only { display: inline-grid !important; }
  .desktop-only { display: none !important; }
  .topbar { gap: 4px; padding: 0 6px; }
  .brand { display: none; }
  .today-btn { min-height: 34px; width: 34px; padding: 0; border-radius: 10px; border-width: 2px; }
  .nav-title { flex: 1 1 auto; }
  .nav-title { font-size: 17px; margin: 0 2px; }
  .seg button { padding: 6px 9px; }
  .quickbar { display: block; padding: 8px 12px; border-bottom: 1px solid var(--rule); background: var(--bg-elev-1); }
  .quickbar .quick { max-width: none; }
  .fab { display: grid; place-items: center; }
  :root { --gutter: 44px; --hour-h: 52px; }
  .tg-dayhead .num { font-size: 18px; width: 32px; height: 32px; }
  .ag-day { grid-template-columns: 64px minmax(0,1fr); padding: 10px 12px; }
  .ag-date { flex-direction: column; gap: 2px; }
  .ag-item { grid-template-columns: 10px 86px minmax(0,1fr); gap: 8px; }
  .month-grid { grid-auto-rows: minmax(76px, 1fr); }
  .m-cell { padding: 2px; }
  .chip-ev { font-size: 11px; padding: 0 4px; }
  .chip-ev .tm { display: none; }
  .form-4 { grid-template-columns: 1fr 1fr; }
  .scrim { padding: 0; align-items: end; }
  .dialog { border-radius: 22px 22px 0 0; max-height: 92dvh; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .settings { padding: 16px 16px 80px; }
  .hours-grid .hrow { grid-template-columns: 52px 22px 1fr 1fr; }
}
@media (max-width: 420px) { .form-2 { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
