/* Shared surfaces, contrast and viewport-safe dialogs. */
:root { color-scheme: light; --surface:#ffffff; --surface-soft:#f5f7fb; --surface-raised:#edf2f8; --text:#233249; --input:#ffffff; --success-bg:#e8f6ee; --success-text:#175c38; --error-bg:#fdecea; --error-text:#982b26; }
:root[data-theme="dark"] { color-scheme:dark; --surface:#142e50; --surface-soft:#0c203b; --surface-raised:#1c3b61; --text:#e6eef9; --ink:#f1f6ff; --muted:#b1c3dc; --line:#3a5577; --blue:#9cc2ff; --input:#102742; --success-bg:#173e35; --success-text:#b9ebcf; --error-bg:#492c39; --error-text:#ffd2cc; }
html,body { background:var(--surface-soft); color:var(--text); }
body { padding-bottom:68px; }
dialog[open] { display:flex; flex-direction:column; max-height:calc(100dvh - 24px); overflow:hidden; background:var(--surface); color:var(--text); }
.modal-header { flex:0 0 auto; background:var(--surface); }
.modal-content { min-height:0; flex:1 1 auto; overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; }
.modal-footer { position:sticky; bottom:-24px; padding:14px 0; background:var(--surface); border-top:1px solid var(--line); z-index:2; }
.planner-dialog[open] { height:min(850px,calc(100dvh - 24px)); }
.planner-dialog-layout { flex:1 1 auto; min-height:0; max-height:none; overflow-y:auto; overscroll-behavior:contain; align-items:start; }
.planner-dialog-main,.planner-dialog-side { overflow:visible; min-height:0; }
.planner-dialog-header { flex:0 0 auto; }
dialog form { min-width:0; }
input,select,textarea { color:var(--text); background:var(--input); border-color:var(--line); }
input::placeholder,textarea::placeholder { color:var(--muted); opacity:1; }
button { color:var(--text); }
button.primary { background:#165bd8; color:#fff; border-color:#165bd8; }
button.primary:hover { background:#124cb8; }
.theme-toggle { position:static; display:flex; align-items:center; gap:10px; }
.theme-toggle svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; }
#toast { position:fixed; inset:18px 18px auto auto; margin:0; bottom:auto; left:auto; transform:none; width:max-content; max-width:min(460px,calc(100vw - 36px)); display:none; align-items:center; gap:12px; padding:14px 16px; border-radius:12px; border:1px solid #b6dec7; background:var(--success-bg); color:var(--success-text); font-size:14px; line-height:1.45; box-shadow:0 8px 30px #0002; animation:toast-enter .25s ease-out; }
#toast[data-kind="error"] { background:var(--error-bg); color:var(--error-text); border-color:#e5b7b2; }
#toast .toast-symbol { font-size:20px; font-weight:700; }
#toast button { padding:0 4px; border:0; color:inherit; background:transparent; font-size:22px; }
@keyframes toast-enter { from { opacity:0; translate:0 -22px; } to { opacity:1; translate:0 0; } }
@media(prefers-reduced-motion:reduce) { #toast { animation:none; } }
:root[data-theme="dark"] .top,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .stat,
:root[data-theme="dark"] .stats,
:root[data-theme="dark"] .filter-options,
:root[data-theme="dark"] .filter-select summary,
:root[data-theme="dark"] .seg,
:root[data-theme="dark"] .login-form,
:root[data-theme="dark"] button:not(.primary),
:root[data-theme="dark"] .month-grid,
:root[data-theme="dark"] .day,
:root[data-theme="dark"] .month-cell,
:root[data-theme="dark"] .week-cell { background:var(--surface); color:var(--text); border-color:var(--line); }
:root[data-theme="dark"] .column,
:root[data-theme="dark"] .planner-card-footer,
:root[data-theme="dark"] .planner-dialog-header,
:root[data-theme="dark"] .planner-dialog-side,
:root[data-theme="dark"] .inline-note,
:root[data-theme="dark"] .weekdays,
:root[data-theme="dark"] th { background:var(--surface-raised); color:var(--text); }
:root[data-theme="dark"] h1,:root[data-theme="dark"] h2,:root[data-theme="dark"] h3,:root[data-theme="dark"] strong,:root[data-theme="dark"] label,:root[data-theme="dark"] legend { color:var(--ink); }
:root[data-theme="dark"] .help,:root[data-theme="dark"] .subtitle,:root[data-theme="dark"] small,:root[data-theme="dark"] .eyebrow { color:var(--muted); }
:root[data-theme="dark"] .badge { background:#304967; color:#e2ecfb; }
:root[data-theme="dark"] .badge.blue,:root[data-theme="dark"] .event,:root[data-theme="dark"] .seg .selected,:root[data-theme="dark"] .nav .active { background:#254b78; color:#e8f1ff; }
:root[data-theme="dark"] .badge.green,:root[data-theme="dark"] .event.done { background:#234b41; color:#b9efd1; }
:root[data-theme="dark"] .badge.orange { background:#51422d; color:#ffe0a5; }
:root[data-theme="dark"] .badge.red,:root[data-theme="dark"] .event.cancelled { background:#542e3c; color:#ffd0cf; }
:root[data-theme="dark"] .error,:root[data-theme="dark"] .danger { color:#ffb8af; }
:root[data-theme="dark"] button:hover:not(.primary),:root[data-theme="dark"] .nav button:hover { background:#254565; }
:root[data-theme="dark"] .planner-card-title,:root[data-theme="dark"] .planner-task-name,:root[data-theme="dark"] .quiet { background:transparent!important; color:var(--ink); }
:root[data-theme="dark"] .branddivider,:root[data-theme="dark"] .progress { background:var(--line); }
:root[data-theme="dark"] .column-title b,:root[data-theme="dark"] .avatar { background:#355778; color:#f2f7ff; }
:root[data-theme="dark"] table,:root[data-theme="dark"] td,:root[data-theme="dark"] .people-picker { border-color:var(--line); }
@media(max-width:760px) { dialog[open] { max-height:calc(100dvh - 16px); } .planner-dialog[open] { height:calc(100dvh - 16px); } .planner-dialog-layout { display:block; } .modal-content { padding:18px; } .modal-footer { bottom:-18px; } #toast { inset:12px 12px auto 12px; max-width:none; width:auto; } }

/* Account settings stay anchored to the person who opened them. */
.account { position:relative; }
.account-trigger { display:flex; align-items:center; gap:12px; padding:6px 8px; border:0; background:transparent; text-align:left; }
.account-trigger .identity { display:flex; flex-direction:column; gap:3px; }
.account-menu { position:absolute; right:0; top:calc(100% + 12px); z-index:1200; width:280px; max-width:calc(100vw - 32px); padding:8px; border:1px solid var(--line); border-radius:12px; background:var(--surface); color:var(--text); box-shadow:0 12px 36px #0003; }
.account-menu[hidden] { display:none; }
.account-info { display:flex; flex-direction:column; gap:5px; padding:12px; border-bottom:1px solid var(--line); margin-bottom:6px; overflow-wrap:anywhere; }
.account-info small { color:var(--muted); }
.account-menu button { display:flex; align-items:center; justify-content:flex-start; gap:10px; width:100%; border:0; border-radius:7px; padding:11px 12px; background:transparent; text-align:left; }
.account-menu button:hover { background:var(--surface-raised); }
.account-menu button:focus-visible,.account-trigger:focus-visible { outline:2px solid var(--blue); outline-offset:2px; }
:root[data-theme="dark"] .account-trigger { background:transparent; }

.nav button,:root[data-theme="dark"] .nav button,:root[data-theme="dark"] .nav button:hover,:root[data-theme="dark"] .nav button.active { position:relative; background:transparent; border-bottom-color:transparent; transition:color .18s ease; }
.nav button::after { content:""; position:absolute; bottom:1px; left:4px; right:4px; border-bottom:1px dashed currentColor; opacity:0; transition:opacity .18s ease; }
.nav button.active::after { opacity:.85; }
:root[data-theme="dark"] .nav button.active { color:#fff; }
:root[data-theme="dark"] .nav button { color:var(--muted); }
:root[data-theme="dark"] .nav button:hover { color:#fff; }

:root[data-theme="dark"] .filter-bar,
:root[data-theme="dark"] .page-filters .filter-bar { background:var(--surface); color:var(--text); border-color:var(--line); }
:root[data-theme="dark"] .page-filters #filter-search,
:root[data-theme="dark"] .page-filters .filter-date,
:root[data-theme="dark"] .page-filters .filter-bar > .checkline,
:root[data-theme="dark"] .page-filters .filter-select summary,
:root[data-theme="dark"] .page-filters #clear-filters { background:var(--input); color:var(--text); border-color:var(--line); }
:root[data-theme="dark"] .page-filters .filter-date input { background:transparent; color:var(--text); }
:root[data-theme="dark"] .date-square { background:var(--surface-raised); color:#b9d4ff; }
:root[data-theme="dark"] .date-square strong { color:#f1f6ff; }
.badge.yellow { background:#fff1bf; color:#755100; }
:root[data-theme="dark"] .badge.yellow { background:#51422d; color:#ffe0a5; }
@media(max-width:760px) { .account-trigger { gap:7px; padding:4px; } .account-trigger .identity { display:none; } }
