/* Foxtap layout: app shell, rails, top bar, buttons, generic controls. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 400 var(--fs)/1.4 var(--font); color: var(--ink); background: var(--bg-2); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--accent); }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: var(--rail-left) minmax(0, 1fr) auto auto; height: 100vh; position: relative; }
.app.panel-open .rail-right { display: none; }

/* left rail */
.rail-left { display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 2px; background: var(--bg-2); border-right: 1px solid var(--line); }
.brand { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; margin-bottom: 10px; }
.brand svg { width: 22px; height: 22px; }
.nav-btn { width: 54px; padding: 8px 0 6px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-3); font-size: 10.5px; font-weight: 500; letter-spacing: .01em; }
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn:hover { background: var(--bg-hover); color: var(--ink); }
.nav-btn.active { color: var(--accent); background: var(--accent-soft); }
.rail-spacer { flex: 1; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-size: 12px; font-weight: 600; margin-top: 8px; }

/* main column */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg); flex: none; }
.tb-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin: 0 6px 0 2px; white-space: nowrap; }
.tb-sub { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
.tb-spacer { flex: 1; }
.content { position: relative; flex: 1; min-height: 0; }
.view { position: absolute; inset: 0; display: none; overflow: hidden; }
.app[data-view="week"] #view-week, .app[data-view="day"] #view-day, .app[data-view="timesheet"] #view-timesheet,
.app[data-view="timers"] #view-timers, .app[data-view="matters"] #view-matters, .app[data-view="settings"] #view-settings { display: block; }
.view.scroll { overflow: auto; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink); font-weight: 500; font-size: 13px; white-space: nowrap; }
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--ink); }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn.danger { color: var(--danger); }
.btn .count { background: rgba(255,255,255,.25); border-radius: 999px; padding: 0 7px; font-size: 11.5px; line-height: 18px; font-weight: 600; }
.btn.ghost .count, .btn:not(.primary) .count { background: var(--bg-3); color: var(--ink-2); }
.seg { display: inline-flex; background: var(--bg-3); border-radius: 8px; padding: 2px; }
.seg button { height: 28px; padding: 0 12px; border-radius: 6px; color: var(--ink-3); font-weight: 500; font-size: 12.5px; }
.seg button.active { background: var(--bg); color: var(--ink); box-shadow: var(--shadow-1); }
.search { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 8px; background: var(--bg-3); color: var(--ink-3); width: 220px; }
.search input { border: 0; background: transparent; outline: 0; width: 100%; color: var(--ink); }
.search input::placeholder { color: var(--ink-4); }
.kbd { font: 500 10.5px/1 var(--mono); color: var(--ink-3); background: var(--bg-3); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; }

/* inputs */
.input { height: 34px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); width: 100%; outline: 0; transition: border-color .12s, box-shadow .12s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; min-height: 72px; line-height: 1.45; }
.input.mono { font-family: var(--mono); font-size: 13px; }
.field { display: grid; grid-template-columns: 76px 1fr; align-items: start; gap: 10px; margin-bottom: 12px; }
.field > label { color: var(--ink-3); font-size: 12px; padding-top: 9px; }
.field.mid { align-items: center; }
.field.mid > label { padding-top: 0; }
.seg.wide button { padding: 0 16px; min-width: 96px; }
.seg button.on-fw.active { color: var(--ink); }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.chip:hover { background: var(--bg-hover); }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.hue { --h: 220; border-color: hsl(var(--h) var(--blk-s) 70%); background: hsl(var(--h) var(--blk-s) var(--blk-fill-l)); color: hsl(var(--h) 40% var(--blk-ink-l)); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--h) var(--blk-s) var(--blk-edge-l)); }
.toggle { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--line-2); transition: background .15s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: left .15s; }
.toggle.on { background: var(--ok); }
.toggle.on::after { left: 18px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.pill.open { background: var(--bg-3); color: var(--ink-2); }
.pill.closed { background: var(--ok-soft); color: var(--ok); }
.pill.posted { background: var(--ink); color: var(--bg); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.nb { background: var(--bg-3); color: var(--ink-3); }

.banner { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 50; background: var(--warn-soft); color: var(--warn); padding: 6px 12px; border-radius: 8px; font-size: 12.5px; box-shadow: var(--shadow-2); }

/* toasts */
.toast-host { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--bg); padding: 10px 12px 10px 14px; border-radius: 10px; box-shadow: var(--shadow-3); font-size: 13px; animation: toast-in .18s ease-out; }
.toast button { color: var(--accent); font-weight: 600; padding: 2px 6px; border-radius: 6px; }
[data-theme="dark"] .toast button { color: #ffb48a; }
.toast button:hover { background: rgba(255,255,255,.12); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.empty { color: var(--ink-3); text-align: center; padding: 40px 20px; }
.empty b { display: block; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
