/* Formwork design system: warm paper, ink, one ember accent. Tokens first, then base, then components. */

:root {
  color-scheme: light;
  --paper: #f6f3ec;
  --surface: #fffdf9;
  --surface-2: #efebe1;
  --surface-3: #e7e2d5;
  --ink: #1d1b16;
  --ink-2: #5b564b;
  --ink-3: #6e685b;
  --line: #e4dfd3;
  --line-strong: #cfc8b8;
  --accent: #c43d17;
  --accent-hover: #a83210;
  --accent-ink: #ffffff;
  --accent-soft: #fbe7df;
  --ok: #2f7d4f;
  --ok-soft: #e1f0e6;
  --warn: #8a5a0d;
  --warn-soft: #f8ebcf;
  --danger: #b42318;
  --danger-soft: #fbe4e1;
  --info-soft: #e8e6f6;

  --font-ui: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --r-xs: 4px; --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;
  --shadow-1: 0 0 0 1px oklch(0 0 0 / .05), 0 1px 2px oklch(0 0 0 / .05);
  --shadow-2: 0 0 0 1px oklch(0 0 0 / .06), 0 2px 4px oklch(0 0 0 / .05), 0 10px 24px -8px oklch(0 0 0 / .14);
  --shadow-3: 0 0 0 1px oklch(0 0 0 / .07), 0 8px 16px oklch(0 0 0 / .08), 0 24px 48px -12px oklch(0 0 0 / .22);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --sidebar-w: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --paper: #14130f;
    --surface: #1c1a15;
    --surface-2: #26241d;
    --surface-3: #312e25;
    --ink: #f3efe6;
    --ink-2: #b8b2a4;
    --ink-3: #a39d8f;
    --line: #2f2c24;
    --line-strong: #453f33;
    --accent: #ff8a63;
    --accent-hover: #ffa283;
    --accent-ink: #1a0d07;
    --accent-soft: #3a2118;
    --ok: #6fce93; --ok-soft: #17301f;
    --warn: #e6b35a; --warn-soft: #33270f;
    --danger: #ff8f84; --danger-soft: #3a1815;
    --info-soft: #24223a;
    --shadow-1: 0 0 0 1px oklch(1 0 0 / .07);
    --shadow-2: 0 0 0 1px oklch(1 0 0 / .08), 0 10px 24px -8px oklch(0 0 0 / .6);
    --shadow-3: 0 0 0 1px oklch(1 0 0 / .1), 0 24px 48px -12px oklch(0 0 0 / .7);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #14130f; --surface: #1c1a15; --surface-2: #26241d; --surface-3: #312e25;
  --ink: #f3efe6; --ink-2: #b8b2a4; --ink-3: #a39d8f; --line: #2f2c24; --line-strong: #453f33;
  --accent: #ff8a63; --accent-hover: #ffa283; --accent-ink: #1a0d07; --accent-soft: #3a2118;
  --ok: #6fce93; --ok-soft: #17301f; --warn: #e6b35a; --warn-soft: #33270f; --danger: #ff8f84; --danger-soft: #3a1815; --info-soft: #24223a;
  --shadow-1: 0 0 0 1px oklch(1 0 0 / .07);
  --shadow-2: 0 0 0 1px oklch(1 0 0 / .08), 0 10px 24px -8px oklch(0 0 0 / .6);
  --shadow-3: 0 0 0 1px oklch(1 0 0 / .1), 0 24px 48px -12px oklch(0 0 0 / .7);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 15px/1.5 var(--font-ui); font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  min-height: 100dvh; overflow-wrap: anywhere;
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; text-decoration-color: color-mix(in oklab, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
img, svg, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: color-mix(in oklab, var(--accent) 28%, transparent); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: .86em; letter-spacing: -.01em; }

.icon { width: 1.125em; height: 1.125em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 1.5em; height: 1.5em; }

/* Typography */
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -.015em; line-height: 1.05; }
.h-page { font: 400 clamp(34px, 4vw, 48px)/1.02 var(--font-display); letter-spacing: -.02em; }
.h-section { font: 600 13px/1.2 var(--font-ui); letter-spacing: .01em; }
.eyebrow { font: 500 11px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }

/* Buttons */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--r-md); border: 1px solid var(--btn-bd); background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 500; font-size: 14px; line-height: 1; text-decoration: none; white-space: nowrap; user-select: none;
  box-shadow: 0 1px 0 oklch(1 0 0 / .5) inset, 0 1px 2px oklch(0 0 0 / .04);
  transition-property: background-color, border-color, color, transform, box-shadow; transition-duration: 140ms; transition-timing-function: var(--ease-out);
}
.btn:active { transform: scale(.96); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: .5; pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .btn:hover { --btn-bg: var(--surface-2); } }
.btn-primary { --btn-bg: var(--ink); --btn-fg: var(--paper); --btn-bd: var(--ink); box-shadow: 0 1px 0 oklch(1 0 0 / .18) inset; }
@media (hover: hover) and (pointer: fine) { .btn-primary:hover { --btn-bg: color-mix(in oklab, var(--ink) 86%, var(--paper)); } }
.btn-accent { --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-bd: var(--accent); box-shadow: 0 1px 0 oklch(1 0 0 / .22) inset; }
@media (hover: hover) and (pointer: fine) { .btn-accent:hover { --btn-bg: var(--accent-hover); --btn-bd: var(--accent-hover); } }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; }
@media (hover: hover) and (pointer: fine) { .btn-ghost:hover { --btn-bg: var(--surface-2); } }
.btn-danger { --btn-fg: var(--danger); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; }
.btn-icon.btn-sm { width: 32px; min-height: 32px; }
.btn-block { width: 100%; }
.btn .spin { display: none; }
.btn[data-loading] .spin { display: inline-block; }
.btn[data-loading] { pointer-events: none; opacity: .8; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Fields */
.field { display: grid; gap: 6px; }
.label { font-weight: 500; font-size: 14px; }
.hint { color: var(--ink-3); font-size: 13px; }
.field-error { color: var(--danger); font-size: 13px; display: flex; gap: 6px; align-items: flex-start; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-size: 16px; line-height: 1.35;
  transition-property: border-color, box-shadow, background-color; transition-duration: 140ms; transition-timing-function: var(--ease-out);
}
.textarea { min-height: 96px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: .8; }
@media (hover: hover) and (pointer: fine) { .input:hover, .select:hover, .textarea:hover { border-color: color-mix(in oklab, var(--ink) 40%, var(--line-strong)); } }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); }
.input[aria-invalid='true'], .select[aria-invalid='true'], .textarea[aria-invalid='true'] { border-color: var(--danger); }
.input-sm { min-height: 36px; padding: 6px 10px; font-size: 14px; border-radius: var(--r-sm); }
.select { appearance: none; padding-inline-end: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236e685b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.pw { position: relative; }
.pw .input { padding-inline-end: 48px; }
.pw button { position: absolute; inset-block: 0; inset-inline-end: 4px; width: 40px; border: 0; background: none; color: var(--ink-3); border-radius: var(--r-sm); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-plain::before { display: none; }

/* Flash banners */
.flashes { display: grid; gap: 8px; margin-bottom: 20px; }
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); font-size: 14px; transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out); }
.flash.out { opacity: 0; transform: translateY(-4px); }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-info { background: var(--info-soft); }
.flash .icon { margin-top: 2px; }

/* Toasts (JS) */
.toasts { position: fixed; inset: auto 0 20px 0; margin: 0; width: auto; height: auto; max-height: none; overflow: visible; background: none; border: 0; display: grid; justify-items: center; gap: 8px; pointer-events: none; z-index: 100; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-md); background: var(--ink); color: var(--paper); font-size: 14px; box-shadow: var(--shadow-3);
  opacity: 1; transform: translateY(0); transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out); }
@starting-style { .toast { opacity: 0; transform: translateY(8px); } }
.toast.out { opacity: 0; transform: translateY(4px); transition-duration: 150ms; }

/* Popover menus (native popover attribute) */
.menu { position: fixed; inset: auto; margin: 0; min-width: 200px; max-width: min(320px, calc(100vw - 16px)); padding: 6px; border: 0; border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); overflow: auto; max-height: min(70vh, 480px);
  opacity: 0; transform: translateY(-4px) scale(.97); transform-origin: var(--ox, top left); transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out), overlay 150ms allow-discrete, display 150ms allow-discrete; }
.menu:popover-open { opacity: 1; transform: none; }
@starting-style { .menu:popover-open { opacity: 0; transform: translateY(-4px) scale(.97); } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 8px; background: none; color: inherit; text-align: start; text-decoration: none; font-size: 14px; }
.menu-item .icon { color: var(--ink-3); }
@media (hover: hover) and (pointer: fine) { .menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; } }
.menu-item.danger { color: var(--danger); } .menu-item.danger .icon { color: inherit; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-label { padding: 8px 10px 4px; }

/* Tooltips (assets/js/app.js) */
.tip { position: fixed; z-index: 300; max-width: 240px; padding: 6px 10px; border-radius: 8px; background: var(--ink); color: var(--paper); font: 500 12px/1.3 var(--font-ui); pointer-events: none; box-shadow: var(--shadow-2);
  opacity: 0; transform: translateY(2px) scale(.97); transition: opacity 125ms var(--ease-out), transform 125ms var(--ease-out); }
.tip[data-side='below'] { transform: translateY(-2px) scale(.97); }
.tip.on { opacity: 1; transform: none; }
.tip.instant { transition-duration: 0ms; }

/* Dialog */
dialog.modal { padding: 0; border: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  opacity: 1; transform: none; transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), overlay 200ms allow-discrete, display 200ms allow-discrete; }
dialog.modal:not([open]) { opacity: 0; transform: translateY(8px) scale(.98); }
@starting-style { dialog.modal[open] { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog.modal::backdrop { background: oklch(0.2 0.02 60 / .45); backdrop-filter: blur(2px); transition: opacity 200ms var(--ease-out); }
.modal-body { padding: 24px; display: grid; gap: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* App shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; border-inline-end: 1px solid var(--line); background: color-mix(in oklab, var(--paper) 60%, var(--surface-2)); }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; text-decoration: none; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-name { font: 400 24px/1 var(--font-display); letter-spacing: -.01em; }
.ws-switch { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); text-align: start; margin-bottom: 12px; }
.ws-avatar { width: 28px; height: 28px; border-radius: 8px; background: var(--ink); color: var(--paper); display: grid; place-items: center; font: 600 12px var(--font-ui); flex: none; }
.ws-name { font-weight: 500; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; border-radius: var(--r-md); text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 14px; transition: background-color 120ms var(--ease-out), color 120ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .nav a:hover { background: var(--surface-2); color: var(--ink); } }
.nav a[aria-current='page'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.nav .count { margin-inline-start: auto; font: 500 12px var(--font-mono); color: var(--ink-3); }
.sidebar-foot { margin-top: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; }
.sidebar-foot .flash { background: var(--surface-2); box-shadow: none; }
.user-chip { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; background: none; border-radius: var(--r-md); text-align: start; }
@media (hover: hover) and (pointer: fine) { .user-chip:hover { background: var(--surface-2); } }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font: 600 12px var(--font-ui); flex: none; }
.main { min-width: 0; padding: clamp(20px, 4vw, 48px); max-width: 1240px; width: 100%; margin-inline: auto; }
.topbar-m { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(288px, 86vw); z-index: 60; transform: translateX(-102%); transition: transform 240ms var(--ease-out); box-shadow: var(--shadow-3); background: var(--surface); }
  .sidebar[data-open] { transform: none; }
  .scrim { position: fixed; inset: 0; background: oklch(0.2 0.02 60 / .4); z-index: 50; opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease-out); }
  .scrim[data-open] { opacity: 1; pointer-events: auto; }
  .topbar-m { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); z-index: 40; }
  .main { padding: 20px 16px 48px; }
}

/* Page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head p { margin-top: 6px; }

/* Auth layout */
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100dvh; }
.auth-aside { position: relative; overflow: hidden; padding: clamp(28px, 5vw, 64px); background: var(--ink); color: var(--paper); display: flex; flex-direction: column; justify-content: flex-start; gap: 40px; }
.auth-aside .brand-name { color: var(--paper); }
.auth-quote { font: 400 clamp(36px, 4.6vw, 64px)/1.02 var(--font-display); letter-spacing: -.02em; max-width: 14ch; margin-top: auto; }
.auth-quote em { font-style: normal; color: var(--accent); }
.auth-sheet { position: relative; align-self: flex-end; margin-inline-end: -8%; width: min(340px, 100%); transform: rotate(-3deg); transform-origin: bottom right; border-radius: 18px; background: var(--surface); color: var(--ink); padding: 22px; box-shadow: var(--shadow-3); display: grid; gap: 12px; pointer-events: none; }
.auth-sheet .line { height: 10px; border-radius: 6px; background: var(--surface-3); }
.auth-sheet .opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 14px; }
.auth-sheet .opt.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.auth-sheet .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; flex: none; }
.auth-sheet .opt.on .dot { background: currentColor; box-shadow: inset 0 0 0 2px var(--accent-soft); }
.auth-main { display: grid; place-items: center; padding: clamp(20px, 5vw, 56px); }
.auth-card { width: min(420px, 100%); display: grid; gap: 24px; }
.auth-card form { display: grid; gap: 16px; }
.auth-links { display: flex; gap: 8px 16px; flex-wrap: wrap; justify-content: space-between; font-size: 14px; }
@media (max-height: 760px) { .auth-sheet { display: none; } }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } .auth-aside { min-height: 0; padding: 20px; flex-direction: row; align-items: center; } .auth-quote, .auth-sheet { display: none; } }

.tpl-more { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 100%; padding: 14px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); color: var(--ink-2); font-weight: 500; font-size: 14px; text-decoration: none; transition: border-color 140ms var(--ease-out), color 140ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .tpl-more:hover { border-color: var(--ink-3); color: var(--ink); } }

/* Social sign-in */
.kc-btn { gap: 10px; }
.kc-mark { width: 24px; height: 24px; flex: none; border-radius: 7px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Appearance switch */
.theme-switch { display: flex; width: 100%; }
.theme-switch button { flex: 1; justify-content: center; white-space: nowrap; padding-inline: 8px; }
#user-menu { min-width: 272px; }
.theme-switch .icon { width: 15px; height: 15px; }
.theme-cycle .ti { display: none; }
.theme-cycle[data-mode='system'] .ti-system, .theme-cycle[data-mode='light'] .ti-light, .theme-cycle[data-mode='dark'] .ti-dark { display: inline-flex; }
.auth-corner { position: absolute; inset-block-start: 16px; inset-inline-end: 16px; }
.auth-main { position: relative; }
@media (max-width: 860px) { .theme-switch span { display: none; } }

/* Illustrations (generated with Codex, paper/ink/ember style) */
.art { display: block; width: min(200px, 56vw); aspect-ratio: 1; object-fit: cover; border-radius: 24px; outline: 1px solid oklch(0 0 0 / .08); outline-offset: -1px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .art { outline-color: oklch(1 0 0 / .1); } }
:root[data-theme='dark'] .art { outline-color: oklch(1 0 0 / .1); }

/* Error page */
.err { min-height: 100dvh; display: grid; place-items: center; padding: 24px; text-align: center; }
.err-code { font: 400 clamp(96px, 20vw, 200px)/.9 var(--font-display); letter-spacing: -.04em; color: var(--accent); }

/* Cards & dashboard */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.search { position: relative; flex: 1 1 220px; max-width: 360px; }
.search .icon { position: absolute; inset-inline-start: 12px; top: 50%; translate: 0 -50%; color: var(--ink-3); pointer-events: none; }
.search .input { padding-inline-start: 38px; min-height: 40px; font-size: 14px; }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); gap: 2px; }
.segmented button, .segmented a { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: var(--ink-2); font-size: 13px; font-weight: 500; text-decoration: none; transition: background-color 120ms var(--ease-out), color 120ms var(--ease-out); }
.segmented [aria-pressed='true'], .segmented [aria-current='true'], .segmented [aria-current='page'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.form-card { position: relative; display: flex; flex-direction: column; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); overflow: clip; transition: box-shadow 180ms var(--ease-out), transform 180ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .form-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); } }
.form-card > a.cover-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.form-card .thumb { aspect-ratio: 16 / 10; background: var(--tint, var(--surface-2)); display: grid; place-items: center; padding: 18px 18px 0; overflow: hidden; }
.thumb-sheet { width: 100%; height: 100%; background: var(--surface); border-radius: 10px 10px 0 0; padding: 14px; display: grid; align-content: start; gap: 9px; box-shadow: 0 0 0 1px oklch(0 0 0 / .05); }
.thumb-sheet i { display: block; height: 7px; border-radius: 4px; background: var(--surface-3); }
.thumb-sheet i.t { height: 10px; width: 60%; background: var(--ink); opacity: .82; }
.thumb-sheet i.a { width: 32%; background: var(--tint-ink, var(--accent)); opacity: .9; }
.form-card .meta { padding: 14px 16px 16px; display: grid; gap: 8px; }
.form-card .title { font-weight: 600; font-size: 15px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-card .sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); }
.form-card .card-actions { position: absolute; inset-block-start: 10px; inset-inline-end: 10px; z-index: 2; display: flex; gap: 6px; }
.card-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 9px; background: color-mix(in oklab, var(--surface) 88%, transparent); color: var(--ink-2); backdrop-filter: blur(6px); box-shadow: var(--shadow-1); transition: transform 120ms var(--ease-out), color 120ms var(--ease-out); }
.card-btn:active { transform: scale(.94); }
.card-btn[aria-pressed='true'] { color: var(--accent); }
.card-btn[aria-pressed='true'] .icon { fill: currentColor; }
.list .grid { grid-template-columns: 1fr; gap: 8px; }
.list .form-card { flex-direction: row; align-items: center; border-radius: var(--r-md); }
.list .form-card .thumb { display: none; }
.list .form-card .meta { flex: 1; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 12px 16px; padding-inline-end: 96px; }
.empty { display: grid; justify-items: center; gap: 14px; text-align: center; padding: clamp(40px, 8vw, 96px) 24px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-xl); }
.empty h2 { font: 400 32px/1.1 var(--font-display); }
.tpl-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 28px; }
.tpl { width: 100%; height: 100%; display: grid; align-content: start; gap: 4px; padding: 14px; border: 0; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); text-align: start; transition: box-shadow 160ms var(--ease-out), transform 160ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .tpl:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); } }
.tpl .icon-wrap { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 8px; }
.tpl b { font-weight: 600; font-size: 14px; }
.tpl span { font-size: 13px; color: var(--ink-3); line-height: 1.35; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .btn:active, .card-btn:active { transform: none; }
}

/* Phone layout for the dashboard (kept last so it wins over the base rules) */
@media (max-width: 640px) {
  .tpl-row { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; margin-inline: -16px; padding: 2px 16px 10px; gap: 10px; scrollbar-width: none; }
  .tpl-row::-webkit-scrollbar { display: none; }
  .tpl { flex: 0 0 74%; scroll-snap-align: start; height: auto; }
  .tpl-more { flex: 0 0 42%; scroll-snap-align: start; }
  .page-head { margin-bottom: 20px; }
  .page-head > div:last-child:not(:first-child) { width: 100%; display: flex; gap: 8px; }
  .page-head > div:last-child:not(:first-child) > * { flex: 1; }
  .page-head > div:last-child:not(:first-child) form .btn { width: 100%; }
  /* Forms as compact rows on phones: thumbnails are wasted space at this width */
  [data-view-root] .grid { grid-template-columns: 1fr; gap: 8px; }
  [data-view-root] .form-card { flex-direction: row; align-items: center; border-radius: var(--r-md); }
  [data-view-root] .form-card .thumb { display: none; }
  [data-view-root] .form-card .meta { flex: 1; min-width: 0; padding: 14px 92px 14px 16px; }
  [data-view-root] .form-card .sub { font-size: 12px; gap: 6px; }
  .segmented[aria-label='Layout'] { display: none; }
  .toolbar .search { flex: 1 1 100%; max-width: none; }
  .tpl-row { scroll-padding-inline: 16px; }
  .form-card .dot { display: none; }
}
.theme-snap *, .theme-snap *::before, .theme-snap *::after { transition: none !important; } /* set by app.js for the frame it takes to flip light/dark */
