/* Planner — app shell styles + design tokens (A6). Other CSS files use only these tokens. */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e0e3e8;
  --text: #161a22;
  --text-muted: #5f6775;
  --accent: #4f46e5;
  --accent-contrast: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .08);
  --topbar-h: 52px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  /* node type colors */
  --t-idea: #0891b2;
  --t-company: #9333ea;
  --t-department: #2563eb;
  --t-team: #db2777;
  --t-person: #ea580c;
  --t-tech: #059669;
  --t-goal: #dc2626;
  --t-task: #65a30d;
  --t-note: #ca8a04;
  --t-group: #64748b;

  /* edge kind colors */
  --k-child: #64748b;
  --k-reports_to: #ea580c;
  --k-part_of: #2563eb;
  --k-uses: #059669;
  --k-depends_on: #dc2626;
  --k-owns: #9333ea;
  --k-flows_to: #0891b2;
  --k-related: #9ca3af;

  /* derived helpers (shell extras; safe for others to use) */
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  --backdrop: rgba(15, 18, 25, .45);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --topbar-total: calc(var(--topbar-h) + var(--safe-top));
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #20242d;
    --border: #2d323d;
    --text: #e7e9ee;
    --text-muted: #9ba3b0;
    --accent: #818cf8;
    --accent-contrast: #0c0f1d;
    --danger: #f87171;
    --success: #4ade80;
    --warning: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);

    --t-idea: #22d3ee;
    --t-company: #c084fc;
    --t-department: #60a5fa;
    --t-team: #f472b6;
    --t-person: #fb923c;
    --t-tech: #34d399;
    --t-goal: #f87171;
    --t-task: #a3e635;
    --t-note: #facc15;
    --t-group: #94a3b8;

    --k-child: #94a3b8;
    --k-reports_to: #fb923c;
    --k-part_of: #60a5fa;
    --k-uses: #34d399;
    --k-depends_on: #f87171;
    --k-owns: #c084fc;
    --k-flows_to: #22d3ee;
    --k-related: #6b7280;

    --backdrop: rgba(0, 0, 0, .6);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-top: var(--topbar-total);
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; }
p { margin: 0 0 .75em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: 13px; }
img, svg { vertical-align: middle; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.text-muted { color: var(--text-muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.spacer { flex: 1; }
.skip-link {
  position: fixed; left: 8px; top: -60px; z-index: 1000; padding: 8px 12px;
  background: var(--accent); color: var(--accent-contrast); border-radius: var(--radius);
}
.skip-link:focus { top: calc(8px + var(--safe-top)); }

.ico {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  font: inherit; font-weight: 550; font-size: 14px; line-height: 1;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; user-select: none; white-space: nowrap; text-decoration: none;
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn .ico { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); border-color: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: var(--danger); }
.btn-icon {
  width: 38px; min-width: 38px; padding: 0;
  background: transparent; border-color: transparent; color: var(--text-muted);
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon.active, .btn-icon[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-copy.copied { color: var(--success); border-color: var(--success); }

@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-icon { width: 44px; min-width: 44px; }
  .btn-sm { min-height: 40px; }
}

/* ---------- inputs ---------- */
.input, input[type="text"], input[type="search"], input[type="password"], input[type="email"],
input[type="url"], input[type="number"], input[type="date"], select, textarea {
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px);
  padding: 8px 10px; min-height: 38px; width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 72px; line-height: 1.45; }
select { cursor: pointer; }
.input:focus, input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.input.invalid, input.invalid { border-color: var(--danger); }
.input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .8; }
.input-color { padding: 2px; width: 64px; height: 38px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; }
@media (pointer: coarse) {
  .input, input[type="text"], input[type="search"], input[type="password"], input[type="number"],
  input[type="date"], select { min-height: 44px; font-size: 16px; /* prevents iOS zoom */ }
  textarea { font-size: 16px; }
}
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.inline-form { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.inline-form .input { flex: 1 1 180px; width: auto; }

/* ---------- cards / badges / callouts ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
}
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 8px;
  border-radius: 999px; background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border); white-space: nowrap;
}
.callout {
  padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.callout-error { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.callout-warning { border-color: color-mix(in srgb, var(--warning) 45%, transparent); background: color-mix(in srgb, var(--warning) 11%, var(--surface)); display: block; }
.code {
  font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 3px); padding: 2px 6px; word-break: break-all;
}
.code-block {
  margin: 0; padding: 10px 12px; overflow-x: auto; white-space: pre; word-break: normal;
  line-height: 1.5; max-width: 100%;
}
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-muted); padding: 24px 0; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: var(--topbar-total);
  padding: var(--safe-top) calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left));
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px; color: var(--text);
  font-weight: 700; font-size: 16px; letter-spacing: -.01em; padding: 4px 6px 4px 0; min-height: 44px;
}
.brand:hover { text-decoration: none; }
.brand img { border-radius: 7px; }
.nav { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.nav-link {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px;
  border-radius: var(--radius); color: var(--text-muted); font-weight: 550; font-size: 14px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link .ico { width: 18px; height: 18px; }

.search { margin-left: auto; position: relative; display: flex; align-items: center; }
.search-toggle, .search-close { display: none; }
.search-panel { position: relative; display: flex; align-items: center; width: 280px; transition: width .15s; }
.search-panel:focus-within { width: 360px; }
.search-ico { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.search-input.input { padding-left: 32px; min-height: 36px; background: var(--surface-2); border-color: transparent; }
.search-input.input:focus { background: var(--surface); border-color: var(--accent); }
.search-input::-webkit-search-cancel-button { cursor: pointer; }
.search-results {
  position: absolute; top: calc(100% + 6px); right: 0; width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 520px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; z-index: 60;
}
.search-group + .search-group { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 4px; }
.search-group-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); padding: 6px 8px 4px;
}
.search-item {
  display: flex; align-items: center; gap: 10px; padding: 8px; min-height: 44px;
  border-radius: calc(var(--radius) - 3px); color: var(--text);
}
.search-item:hover, .search-item.active { background: var(--surface-2); text-decoration: none; }
.search-item.active { box-shadow: inset 2px 0 0 var(--accent); }
.search-item-ico { display: inline-flex; color: var(--text-muted); }
.search-item-text { display: flex; flex-direction: column; min-width: 0; }
.search-item-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.search-item-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 14px 10px; color: var(--text-muted); font-size: 14px; }

/* compact top bar on phones: icon nav, search as overlay */
@media (max-width: 640px) {
  :root { --topbar-h: 52px; }
  .topbar { gap: 2px; padding-left: calc(8px + var(--safe-left)); padding-right: calc(6px + var(--safe-right)); }
  .brand-name { display: none; }
  .brand { padding-right: 2px; }
  .nav { margin-left: 4px; gap: 0; }
  .nav-link { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .nav-link .ico { width: 22px; height: 22px; }
  .nav-text { display: none; }
  .search-toggle { display: inline-flex; }
  .search-panel { display: none; width: auto; }
  .search-panel:focus-within { width: auto; }
  .topbar.search-open .search-panel {
    display: flex; position: fixed; left: 0; right: 0; top: var(--safe-top); height: var(--topbar-h);
    padding: 0 calc(6px + var(--safe-right)) 0 calc(8px + var(--safe-left)); gap: 4px;
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar.search-open .search-ico { left: 18px; }
  .topbar.search-open .search-close { display: inline-flex; }
  .search-results {
    position: fixed; top: calc(var(--topbar-total) + 4px); left: 8px; right: 8px; width: auto;
    max-height: calc(100dvh - var(--topbar-total) - 16px - var(--safe-bottom));
  }
}

/* ---------- main view ---------- */
#view { outline: none; }
.page {
  max-width: 1200px; margin: 0 auto;
  padding: 24px calc(24px + var(--safe-right)) calc(40px + var(--safe-bottom)) calc(24px + var(--safe-left));
}
.page-narrow { max-width: 820px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 24px; margin: 0; letter-spacing: -.015em; }
.page-sub { margin: 2px 0 0; font-size: 14px; min-height: 1em; }
@media (max-width: 640px) {
  .page { padding: 16px calc(16px + var(--safe-right)) calc(32px + var(--safe-bottom)) calc(16px + var(--safe-left)); }
  .page-title { font-size: 21px; }
}

/* Board view: #view becomes a fixed box filling the viewport below the top bar. */
body.view-board { overflow: hidden; overscroll-behavior: none; }
body.view-board #view {
  position: fixed; top: var(--topbar-total); left: 0; right: 0; bottom: 0;
  overflow: hidden; display: flex; flex-direction: column;
}
body.view-board #view > * { flex: 1 1 auto; min-height: 0; }

/* ---------- boards home ---------- */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.board-grid.is-empty { display: block; }
.board-card {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 14px 14px 12px;
  border-top: 3px solid var(--kind-color, var(--accent));
  transition: box-shadow .15s, transform .15s, border-color .15s;
  min-height: 150px;
}
.board-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.board-card:focus-within { box-shadow: var(--focus-ring); }
.board-card-top { display: flex; align-items: center; gap: 8px; }
.board-card-ico {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px;
  color: var(--kind-color); background: color-mix(in srgb, var(--kind-color) 13%, transparent);
}
.badge-kind { color: var(--kind-color); background: color-mix(in srgb, var(--kind-color) 10%, transparent); border-color: color-mix(in srgb, var(--kind-color) 30%, transparent); }
.card-menu { margin-left: auto; position: relative; z-index: 2; }
.board-card-title { font-size: 16px; margin: 2px 0 0; overflow-wrap: anywhere; }
.card-link { color: var(--text); }
.card-link:hover { text-decoration: none; }
.card-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 1; }
.card-link:focus-visible { outline: none; }
.board-card-desc {
  margin: 0; font-size: 13px; color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.board-card-meta { margin-top: auto; display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-muted); }

.empty-state { text-align: center; padding: 40px 12px; max-width: 720px; margin: 0 auto; }
.empty-icon {
  display: inline-flex; width: 72px; height: 72px; border-radius: 20px; align-items: center; justify-content: center;
  color: var(--accent); background: var(--accent-soft); margin-bottom: 14px;
}
.empty-icon .ico { width: 36px; height: 36px; stroke-width: 1.5; }
.empty-title { font-size: 20px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 20px; text-align: left; }
.template-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px;
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; text-align: left; min-height: 44px;
  transition: border-color .12s, box-shadow .12s, background-color .12s;
}
.template-tile:hover { border-color: var(--kind-color, var(--accent)); box-shadow: var(--shadow); }
.template-tile:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.template-tile[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.template-ico {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 9px;
  color: var(--kind-color); background: color-mix(in srgb, var(--kind-color) 13%, transparent);
}
.template-tile .template-ico { color: var(--kind-color); }
.template-name { font-weight: 600; }
.template-desc { font-size: 13px; color: var(--text-muted); }
.template-grid-sm { grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 0; }
.template-tile-sm { align-items: center; text-align: center; padding: 10px 6px; font-size: 13px; }
.template-tile-sm .template-ico { width: 32px; height: 32px; }
@media (max-width: 420px) { .template-grid-sm { grid-template-columns: repeat(2, 1fr); } }

/* ---------- settings ---------- */
.settings { display: flex; flex-direction: column; gap: 16px; }
.settings .page-head { margin-bottom: 4px; }
.settings-section { padding: 18px; }
.settings-section h2 { font-size: 17px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-head p { margin: 0; }
.token-reveal { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.code-row { display: flex; gap: 8px; align-items: center; width: 100%; }
.token-value { flex: 1; padding: 8px 10px; font-size: 13px; user-select: all; min-width: 0; }
.token-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; }
.token-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.token-row:first-child { border-top: 0; }
.token-ico { color: var(--text-muted); display: inline-flex; }
.token-info { flex: 1; min-width: 0; }
.token-name { font-weight: 600; overflow-wrap: anywhere; }
.token-meta { font-size: 13px; }
.token-empty { padding: 8px 0; font-size: 14px; }
.snippets { display: flex; flex-direction: column; gap: 14px; margin: 6px 0 14px; }
.snippet { min-width: 0; }
.snippet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; gap: 8px; }
.snippet-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.doc-links { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- modals: dialogs + sheets ---------- */
body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: var(--backdrop);
  display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  opacity: 0; transition: opacity .16s ease;
}
.modal-backdrop.open { opacity: 1; }
.modal-backdrop.closing { opacity: 0; }
.modal {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  width: 100%; max-width: 440px; max-height: 100%;
  display: flex; flex-direction: column; outline: none;
  transform: translateY(8px) scale(.98); transition: transform .16s ease;
}
.modal-backdrop.open .modal { transform: none; }
.modal-sheet { max-width: 560px; }
.modal-newboard { max-width: 520px; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 6px 18px; }
.modal-title { flex: 1; font-size: 17px; margin: 0; overflow-wrap: anywhere; }
.modal-body { padding: 8px 18px 16px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.modal-message { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
}
.sheet-grip { display: none; }

@media (max-width: 640px) {
  .backdrop-sheet { align-items: flex-end; padding: var(--safe-top) 0 0 0; }
  .modal-sheet {
    max-width: none; border-radius: 16px 16px 0 0; border-bottom: 0;
    max-height: 92dvh; padding-bottom: var(--safe-bottom);
    transform: translateY(40px);
  }
  .sheet-grip {
    display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border);
    margin: 8px auto -4px;
  }
  .modal-foot { padding-bottom: calc(14px + var(--safe-bottom)); }
  .modal-sheet .modal-foot { padding-bottom: 14px; }
  .modal-foot .btn { flex: 1; }
}

/* ---------- popover menu ---------- */
.menu {
  position: fixed; z-index: 300; min-width: 180px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 10px;
  font: inherit; font-size: 14px; color: var(--text); background: none; border: 0; border-radius: calc(var(--radius) - 3px);
  cursor: pointer; text-align: left;
}
.menu-item .ico { width: 18px; height: 18px; color: var(--text-muted); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item.danger, .menu-item.danger .ico { color: var(--danger); }
.menu-item:disabled { opacity: .5; cursor: default; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
@media (pointer: coarse) { .menu-item { min-height: 44px; } }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 400;
  bottom: calc(16px + var(--safe-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: max-content; max-width: calc(100vw - 24px); pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius); max-width: 100%;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
  font-size: 14px; font-weight: 500; overflow-wrap: anywhere;
  animation: toast-in .18s ease;
  border-left: 4px solid var(--accent);
}
.toast-error { border-left-color: var(--danger); }
.toast-success { border-left-color: var(--success); }
.toast-out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- login ---------- */
body.login-page { padding-top: 0; }
.login-wrap {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
}
.login-card { width: 100%; max-width: 360px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand img { border-radius: 10px; }
.login-brand h1 { margin: 0; font-size: 22px; }
.login-sub { margin: -6px 0 4px; color: var(--text-muted); }
.login-error {
  padding: 10px 12px; border-radius: var(--radius); font-size: 14px;
  color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}
.login-card .btn-block { min-height: 44px; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
