/* =========================================================================
   NOVA SketchBoard AI — editor design system
   Tokens, auth, app shell, canvas chrome, inspector, overlays, responsive.
   ========================================================================= */

:root {
  color-scheme: light;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;

  --bg: #f2f4f9;
  --bg-deep: #e9ecf5;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4fa;
  --glass: rgba(255, 255, 255, 0.82);
  --ink: #0e1526;
  --ink-2: #33405a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e3e8f0;
  --line-strong: #cbd5e1;
  --accent: #5b5bd6;
  --accent-2: #0891b2;
  --accent-ink: #ffffff;
  --accent-soft: #ececfb;
  --success: #0f766e;
  --warning: #b45309;
  --danger: #be123c;
  --danger-soft: #fff1f2;
  --focus: #6366f1;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 6px 16px -8px rgba(15, 23, 42, 0.16);
  --shadow-md: 0 2px 6px rgba(15, 23, 42, 0.06), 0 18px 40px -18px rgba(15, 23, 42, 0.28);
  --shadow-lg: 0 40px 90px -40px rgba(15, 23, 42, 0.45), 0 8px 24px -12px rgba(15, 23, 42, 0.2);
  --ring: 0 0 0 3px rgba(99, 102, 241, 0.32);
  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --tap: 44px;
  --topbar-h: 62px;
  --rail-w: 72px;
  --inspector-w: 276px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fast: 140ms;
  --med: 240ms;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0c13;
  --bg-deep: #070910;
  --surface: #131826;
  --surface-2: #171d2c;
  --surface-3: #1d2436;
  --glass: rgba(19, 24, 38, 0.86);
  --ink: #eef1f8;
  --ink-2: #cbd3e4;
  --muted: #93a0b8;
  --muted-2: #6b7893;
  --line: #252d40;
  --line-strong: #35405a;
  --accent: #7c7cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(124, 124, 255, 0.14);
  --accent-ink: #0b0d14;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.12);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 18px 40px -18px rgba(0, 0, 0, 0.75);
  --shadow-lg: 0 50px 100px -40px rgba(0, 0, 0, 0.85);
  --ring: 0 0 0 3px rgba(124, 124, 255, 0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
h1, h2, h3, h4, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.ic { width: 20px; height: 20px; flex: none; display: block; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.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;
}
.skip-link {
  position: fixed; left: 12px; top: -80px; z-index: 999;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: var(--r-sm);
  transition: top var(--fast) var(--ease);
}
.skip-link:focus { top: 12px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-xs); }
::selection { background: rgba(91, 91, 214, 0.22); }

/* ------------------------------------------------------------------ boot */
.boot {
  position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; gap: 18px;
  justify-items: center; background:
    radial-gradient(1200px 600px at 20% 10%, rgba(91, 91, 214, 0.10), transparent 60%),
    radial-gradient(900px 500px at 85% 85%, rgba(8, 145, 178, 0.10), transparent 60%),
    var(--bg);
}
.boot-mark { color: var(--accent); animation: float 2.6s var(--ease) infinite; }
.boot-text { color: var(--muted); font-size: 13px; letter-spacing: 0.01em; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ------------------------------------------------------------------ auth */
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
  background: var(--bg);
}
.auth-visual {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(700px 500px at 8% 0%, rgba(91, 91, 214, 0.16), transparent 62%),
    radial-gradient(600px 500px at 100% 90%, rgba(6, 182, 212, 0.16), transparent 60%),
    linear-gradient(160deg, var(--surface), var(--bg-deep));
}
.auth-glow {
  position: absolute; width: 420px; height: 420px; left: 8%; top: 4%; border-radius: 50%;
  background: conic-gradient(from 120deg, rgba(91, 91, 214, 0.35), rgba(6, 182, 212, 0.28), rgba(124, 58, 237, 0.3), rgba(91, 91, 214, 0.35));
  filter: blur(90px); opacity: 0.55; animation: drift 18s linear infinite;
}
@keyframes drift { 0% { transform: translate3d(0, 0, 0) rotate(0deg); } 100% { transform: translate3d(40px, 30px, 0) rotate(360deg); } }
.auth-sketch { position: relative; width: min(640px, 100%); height: auto; margin-top: 3vh; }
.auth-quote { position: relative; max-width: 540px; }
.auth-quote-title { margin: 0; font-size: clamp(26px, 2.6vw, 36px); font-weight: 650; letter-spacing: -0.025em; color: var(--ink); }
.auth-quote-body { margin-top: 10px; color: var(--muted); font-size: 15px; line-height: 1.65; }
.auth-quote-body em { font-style: normal; color: var(--ink-2); }
.auth-hero-links { margin-top: 20px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.auth-hero-links a { color: var(--accent); font-weight: 650; text-decoration: none; }
.auth-hero-links a:hover { text-decoration: underline; }
.auth-points { margin-top: 22px; display: grid; gap: 10px; }
.auth-points li { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 13.5px; }
.auth-points .ic { color: var(--accent); width: 18px; height: 18px; }
.auth-panel {
  display: flex; flex-direction: column; justify-content: center; gap: 26px;
  padding: clamp(24px, 5vw, 64px);
  background: var(--surface);
}
.auth-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-lockup { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--accent); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); }
.brand-mark svg { width: 30px; height: 30px; }
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 14px; letter-spacing: 0.14em; }
.brand-copy span { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.auth-head-tools { display: flex; align-items: center; gap: 6px; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2);
  font-size: 12.5px; max-width: 180px;
}
.lang-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-btn .chev { width: 14px; height: 14px; opacity: 0.6; }
.lang-btn:hover { border-color: var(--line-strong); background: var(--surface-3); }
.auth-card { width: min(460px, 100%); margin: 0 auto; }
.auth-title { font-size: clamp(24px, 2.4vw, 30px); letter-spacing: -0.03em; font-weight: 650; }
.auth-sub { margin-top: 8px; color: var(--muted); font-size: 13.5px; line-height: 1.6; max-width: 42ch; }
.auth-form { margin-top: 22px; display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: 0.01em; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="search"], textarea, select {
  width: 100%; min-height: 42px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
input:hover, textarea:hover, select:hover { border-color: var(--line-strong); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.16);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(190, 18, 60, 0.12); }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 44px; }
.reveal {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted);
}
.reveal:hover { background: var(--surface-3); color: var(--ink); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error {
  margin: 0; padding: 10px 12px; border-radius: var(--r-sm); font-size: 12.5px;
  color: var(--danger); background: var(--danger-soft); border: 1px solid rgba(190, 18, 60, 0.18);
}
.setup-note {
  display: flex; gap: 8px; align-items: flex-start; margin: 0 0 4px;
  padding: 12px; border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.55;
  color: var(--accent); background: var(--accent-soft);
}
.setup-note .ic { width: 16px; height: 16px; margin-top: 1px; }
.auth-fineprint { display: flex; align-items: center; gap: 7px; color: var(--muted-2); font-size: 11.5px; }
.auth-fineprint .ic { width: 14px; height: 14px; }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted-2); font-size: 11.5px; flex-wrap: wrap; }
.auth-foot .dot { width: 3px; height: 3px; background: var(--muted-2); border-radius: 50%; }
.segmented {
  display: flex; gap: 4px; padding: 4px; margin-top: 22px;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 999px;
}
.seg {
  flex: 1; min-height: 36px; border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font-size: 12.5px; font-weight: 600;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.seg:hover { color: var(--ink); }
.seg.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }

/* ------------------------------------------------------------------ buttons */
.btn {
  --btn-bg: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--btn-bg); color: var(--ink-2);
  font-size: 13px; font-weight: 600; letter-spacing: -0.005em; white-space: nowrap;
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease), border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), color var(--fast) var(--ease);
}
.btn .ic { width: 17px; height: 17px; }
.btn:hover { border-color: var(--line-strong); background: var(--surface-3); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent));
  border-color: color-mix(in srgb, var(--accent) 70%, #000);
  color: var(--accent-ink); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 8px 18px -10px rgba(91, 91, 214, 0.8);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 88%, #000)); color: var(--accent-ink); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); border-color: transparent; color: #fff; }
.btn-ai {
  background: linear-gradient(120deg, rgba(91, 91, 214, 0.14), rgba(8, 145, 178, 0.14));
  border-color: rgba(91, 91, 214, 0.3); color: var(--accent);
}
.btn-ai:hover { background: linear-gradient(120deg, rgba(91, 91, 214, 0.22), rgba(8, 145, 178, 0.2)); border-color: var(--accent); color: var(--accent); }
.btn-block { width: 100%; min-height: 46px; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-lg { min-height: 48px; padding: 0 18px; font-size: 14px; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; flex: none;
  border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--ink-2);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.is-active { background: var(--accent-soft); color: var(--accent); }
.icon-btn[disabled] { opacity: 0.4; pointer-events: none; }
.linkish {
  display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--muted);
  font-size: 11.5px; padding: 2px 3px; border-radius: 6px;
}
.linkish .ic { width: 13px; height: 13px; }
.linkish:hover { color: var(--accent); background: var(--accent-soft); }
.spinner {
  display: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.is-busy .spinner { display: block; }
.is-busy .btn-label { opacity: 0.75; }
@keyframes spin { to { transform: rotate(360deg); } }
kbd {
  font-family: var(--mono); font-size: 10.5px; line-height: 1;
  padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted);
}
.badge {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: 9.5px; font-weight: 700; display: grid; place-items: center;
}
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* ------------------------------------------------------------------ shell */
.shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
}
.topbar {
  grid-column: 1 / -1; grid-row: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 12px 0 8px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.topbar-logo { display: grid; place-items: center; width: 34px; height: 34px; color: var(--accent); border-radius: 10px; background: var(--accent-soft); }
.topbar-logo svg { width: 26px; height: 26px; }
.title-block { min-width: 0; display: grid; gap: 1px; }
.board-title {
  width: min(42vw, 460px); min-width: 80px; height: 26px; padding: 0 6px; margin-left: -6px;
  border: 1px solid transparent; border-radius: 7px; background: transparent;
  font-size: 14px; font-weight: 650; letter-spacing: -0.015em; color: var(--ink);
  text-overflow: ellipsis;
}
.board-title:hover { background: var(--surface-3); }
.board-title:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.14); }
.board-status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); padding-left: 1px; min-height: 16px; }
.save-state { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.save-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px color-mix(in srgb, var(--success) 18%, transparent); }
.save-state[data-state="saving"] .save-dot { background: var(--warning); animation: pulse 1.1s ease-in-out infinite; }
.save-state[data-state="dirty"] .save-dot { background: var(--muted-2); box-shadow: none; }
.save-state[data-state="offline"] .save-dot,
.save-state[data-state="error"] .save-dot { background: var(--danger); box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 18%, transparent); }
.save-state[data-state="readonly"] .save-dot { background: var(--accent-2); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.status-sep { color: var(--line-strong); }
.muted-count { white-space: nowrap; }
.topbar-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.presence { display: flex; align-items: center; padding-left: 8px; }
.presence .avatar {
  width: 28px; height: 28px; margin-left: -8px; border-radius: 50%;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: #fff;
  border: 2px solid var(--surface); box-shadow: var(--shadow-xs); letter-spacing: 0.02em;
}
.presence .avatar:first-child { margin-left: 0; }
.presence .avatar.is-self { box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px var(--surface); }
.presence-more { margin-left: 4px; font-size: 11px; color: var(--muted); }
.presence-empty { font-size: 11px; color: var(--muted-2); }
.topbar-right { display: flex; align-items: center; gap: 4px; flex: none; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 244px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-md); animation: pop var(--fast) var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.menu button {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); text-align: left; font-size: 12.5px;
}
.menu button .ic { width: 16px; height: 16px; color: var(--muted); }
.menu button span { flex: 1; }
.menu button:hover { background: var(--surface-3); color: var(--ink); }
.menu button:hover .ic { color: var(--ink-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

/* rail */
.rail {
  grid-column: 1; grid-row: 2; z-index: 15;
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: 10px 0 12px; gap: 12px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.rail-group { display: grid; gap: 4px; justify-items: center; }
.rail-bottom { gap: 2px; }
.rail-btn {
  position: relative; width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--muted);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.rail-btn:hover { background: var(--surface-3); color: var(--ink); }
.rail-btn.is-active { background: var(--accent-soft); color: var(--accent); }
.rail-btn[aria-pressed="false"] { color: var(--muted-2); }
.rail-ai { color: var(--accent); background: linear-gradient(135deg, rgba(91, 91, 214, 0.12), rgba(8, 145, 178, 0.12)); }
.rail-ai:hover { background: linear-gradient(135deg, rgba(91, 91, 214, 0.2), rgba(8, 145, 178, 0.2)); }
.raildot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 1.5px solid var(--surface); }
.avatar-btn {
  width: 36px; height: 36px; margin-top: 6px; border-radius: 50%; border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; display: grid; place-items: center;
}
.avatar-btn:hover { filter: brightness(1.06); }
.rail-btn .theme-dark { display: none; }
html[data-theme="dark"] .rail-btn .theme-light { display: none; }
html[data-theme="dark"] .rail-btn .theme-dark { display: block; }
.rail-btn[data-tip]::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  padding: 4px 8px; border-radius: 6px; background: var(--ink); color: var(--surface);
  font-size: 11px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--fast) var(--ease);
  z-index: 40;
}
.rail-btn[data-tip]:hover::after { opacity: 1; transition-delay: 420ms; }

/* workspace + canvas */
.workspace { grid-column: 2; grid-row: 2; position: relative; min-width: 0; min-height: 0; }
.canvas-wrap { position: absolute; inset: 0; overflow: hidden; background: var(--bg); touch-action: none; }
#board-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.canvas-wrap.is-panning #board-canvas { cursor: grabbing; }
.canvas-wrap.tool-select #board-canvas { cursor: default; }
.canvas-wrap.tool-hand #board-canvas { cursor: grab; }
.canvas-wrap.tool-text #board-canvas { cursor: text; }
.canvas-wrap.is-space #board-canvas { cursor: grab; }
.canvas-wrap.is-readonly #board-canvas { cursor: default; }

.toolbar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 18;
  display: flex; align-items: center; gap: 2px; padding: 5px;
  background: var(--glass); backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-md);
  max-width: calc(100% - 24px);
}
.tool {
  position: relative; width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--ink-2);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.tool .ic { width: 19px; height: 19px; }
.tool:hover { background: var(--surface-3); color: var(--ink); }
.tool:active { transform: scale(0.94); }
.tool.is-active { background: var(--accent); border-color: color-mix(in srgb, var(--accent) 70%, #000); color: var(--accent-ink); box-shadow: 0 6px 14px -8px rgba(91, 91, 214, 0.9); }
.tool-sep { width: 1px; height: 24px; margin: 0 4px; background: var(--line); flex: none; }
.tool-hint {
  position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  padding: 4px 7px; border-radius: 6px; background: var(--ink); color: var(--surface);
  font-size: 10.5px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--fast) var(--ease);
}
.tool:hover .tool-hint { opacity: 1; transition-delay: 380ms; }
.tool-hint kbd { background: transparent; border: 0; color: color-mix(in srgb, var(--surface) 65%, transparent); padding: 0 0 0 4px; font-size: 10px; }
.toolbar .tool[data-tool="eraser"] { box-shadow: none; }

/* empty state */
.empty-state {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(700px 420px at 50% 30%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 70%);
  pointer-events: none;
}
.empty-card {
  pointer-events: auto; width: min(560px, 100%); text-align: center;
  padding: clamp(22px, 4vw, 34px); border-radius: var(--r-xl);
  border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-md); backdrop-filter: blur(12px);
  animation: rise 380ms var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.empty-mark { display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); }
.empty-mark svg { width: 34px; height: 34px; }
.empty-card h2 { margin-top: 14px; font-size: 22px; letter-spacing: -0.025em; }
.empty-card p { margin: 8px auto 0; max-width: 44ch; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.empty-actions { margin-top: 18px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.empty-starters { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.starter {
  padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink-2); font-size: 11.5px; display: inline-flex; gap: 6px; align-items: center;
}
.starter:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.starter kbd { padding: 2px 4px; font-size: 9.5px; }

/* zoom + minimap */
.canvas-tools-left { position: absolute; left: 14px; bottom: 16px; z-index: 14; }
.zoom-pill {
  display: flex; align-items: center; gap: 1px; padding: 4px;
  background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-sm);
}
.zoom-btn, .zoom-value {
  min-width: 32px; height: 32px; padding: 0 6px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-2); display: grid; place-items: center; font-size: 13px; font-variant-numeric: tabular-nums;
}
.zoom-btn:hover, .zoom-value:hover { background: var(--surface-3); color: var(--ink); }
.zoom-value { min-width: 52px; font-size: 11.5px; font-weight: 600; }
.zoom-divider { width: 1px; height: 18px; background: var(--line); margin: 0 2px; }
.zoom-btn .ic { width: 16px; height: 16px; }
.canvas-tools-right { position: absolute; right: 14px; bottom: 16px; z-index: 14; display: flex; align-items: flex-end; gap: 8px; }
.mini-toggle {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--line); background: var(--glass); color: var(--muted); box-shadow: var(--shadow-sm);
}
.mini-toggle:hover { color: var(--ink); }
.mini-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.minimap {
  width: 220px; height: 150px; padding: 4px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-md); overflow: hidden;
}
.minimap canvas { width: 100%; height: 100%; border-radius: 8px; display: block; }
#minimap { display: none; }
#minimap.is-open { display: block; }

/* comments layer + pins */
.comment-layer, .remote-cursors { position: absolute; inset: 0; pointer-events: none; z-index: 12; }
.comment-pin {
  position: absolute; transform: translate(-50%, -100%); pointer-events: auto;
  width: 30px; height: 30px; border-radius: 10px 10px 10px 3px;
  border: 2px solid var(--surface); background: var(--accent); color: #fff;
  display: grid; place-items: center; box-shadow: var(--shadow-sm); font-size: 11px; font-weight: 700;
  transition: transform var(--fast) var(--ease);
}
.comment-pin::after { content: ""; position: absolute; inset: -4px; border-radius: 14px 14px 14px 4px; border: 2px solid var(--accent); opacity: 0.18; }
.comment-pin:hover { transform: translate(-50%, -100%) scale(1.08); }
.comment-pin.is-resolved { background: var(--muted-2); }
.comment-pin.is-active { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.remote-cursor {
  position: absolute; left: 0; top: 0; display: flex; align-items: flex-start; gap: 4px;
  will-change: transform; transition: transform 90ms linear;
}
.remote-cursor svg { width: 18px; height: 22px; filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.25)); }
.remote-cursor span {
  margin-top: 14px; padding: 2px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 600; color: #fff;
  white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis;
}

/* text editing overlay */
.text-layer { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
.text-editor {
  position: absolute; pointer-events: auto; margin: 0; padding: 6px 8px;
  border: 2px solid var(--accent); border-radius: 8px; resize: none; overflow: hidden;
  background: color-mix(in srgb, var(--surface) 96%, transparent); color: var(--ink);
  box-shadow: var(--shadow-md); line-height: 1.35; min-width: 60px; min-height: 34px;
  white-space: pre-wrap; word-break: break-word;
}
.marquee-hint {
  position: absolute; top: 74px; left: 50%; transform: translateX(-50%); z-index: 16;
  padding: 6px 12px; border-radius: 999px; background: var(--ink); color: var(--surface);
  font-size: 11.5px; box-shadow: var(--shadow-sm);
}

/* statusbar */
.statusbar {
  position: absolute; left: calc(var(--rail-w) + 14px); bottom: 8px; z-index: 13;
  display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted-2);
  pointer-events: none; max-width: 50vw;
}
.statusbar #status-tool { color: var(--muted); font-weight: 600; }
.statusbar #status-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* inspector */
.inspector {
  position: absolute; top: 14px; right: 14px; bottom: 14px; width: var(--inspector-w); z-index: 17;
  display: flex; flex-direction: column;
  background: var(--glass); backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-md);
  overflow: hidden; transition: transform var(--med) var(--ease), opacity var(--med) var(--ease);
}
.inspector.is-collapsed { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }
.insp-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
}
.insp-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 650; flex: 1; }
.insp-head .icon-btn { width: 30px; height: 30px; }
.insp-body { padding: 4px 12px 24px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.insp-empty { padding: 26px 8px; text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.insp-empty .ic { width: 28px; height: 28px; margin: 0 auto 10px; color: var(--muted-2); }
.insp-section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.insp-section:last-child { border-bottom: 0; }
.insp-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.insp-label > span:first-child { font-size: 11px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.insp-row { display: flex; align-items: center; gap: 6px; }
.insp-row + .insp-row { margin-top: 8px; }
.insp-grid { display: grid; gap: 8px; }
.insp-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.swatch {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 7px; border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
  background: var(--sw); transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.swatch:hover { transform: scale(1.08); }
.swatch.is-active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch.is-transparent::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background-image: linear-gradient(45deg, #d6dbe6 25%, transparent 25%, transparent 75%, #d6dbe6 75%), linear-gradient(45deg, #d6dbe6 25%, transparent 25%, transparent 75%, #d6dbe6 75%);
  background-size: 8px 8px; background-position: 0 0, 4px 4px;
}
.color-line { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.color-line input[type="color"] { width: 30px; height: 30px; padding: 2px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); }
.color-line input[type="text"] { min-height: 30px; padding: 4px 8px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; }
.seg-row { display: flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: 9px; }
.seg-row button {
  flex: 1; min-height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  display: grid; place-items: center; font-size: 11px; gap: 2px;
}
.seg-row button .ic { width: 15px; height: 15px; }
.seg-row button:hover { color: var(--ink); }
.seg-row button.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-xs); }
.slider-row { display: flex; align-items: center; gap: 8px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent); height: 22px; }
.slider-val { width: 38px; text-align: right; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; }
.toggle-row span { font-size: 12.5px; color: var(--ink-2); }
.switch {
  position: relative; width: 38px; height: 22px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface-3); flex: none; transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-xs); transition: transform var(--fast) var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.num-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.num-field { position: relative; }
.num-field label {
  position: absolute; top: 4px; left: 8px; font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted-2); pointer-events: none;
}
.num-field input { min-height: 40px; padding: 16px 8px 4px; font-size: 12px; font-variant-numeric: tabular-nums; }
.insp-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.insp-actions button {
  min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
  color: var(--muted); display: grid; place-items: center;
}
.insp-actions button:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-3); }
.insp-actions button.is-danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.insp-actions .ic { width: 16px; height: 16px; }
.type-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 10.5px; font-weight: 650; text-transform: capitalize; }
.insp-foot { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-size: 10.5px; color: var(--muted-2); }

/* present mode */
.shell.is-presenting { grid-template-columns: 0 1fr; grid-template-rows: 0 1fr; }
.shell.is-presenting .topbar, .shell.is-presenting .rail, .shell.is-presenting .toolbar,
.shell.is-presenting .inspector, .shell.is-presenting .statusbar, .shell.is-presenting .canvas-tools-right { display: none; }
.shell.is-presenting .present-bar { display: flex; }
.present-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 16px;
  background: var(--glass); backdrop-filter: blur(16px); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: var(--shadow-md);
}
.present-bar span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.present-actions { display: flex; gap: 4px; }
.present-bar .btn { min-height: 34px; border-radius: 999px; }

/* ------------------------------------------------------------------ shared overlay system */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(8, 12, 24, 0.46); backdrop-filter: blur(6px);
  animation: fade var(--fast) var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(560px, 100%); max-height: min(86dvh, 880px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); animation: modal-in var(--med) var(--ease);
  overflow: hidden;
}
.modal.modal-wide { width: min(920px, 100%); }
.modal.modal-sm { width: min(420px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-head-copy { flex: 1; min-width: 0; }
.modal-head h2 { font-size: 17px; letter-spacing: -0.02em; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.modal-head h2 .ic { width: 19px; height: 19px; color: var(--accent); }
.modal-head p { margin-top: 4px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.modal-body { padding: 18px 22px; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.modal-foot .grow { flex: 1; }
.modal-close { width: 34px; height: 34px; }
.modal-note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 12px; line-height: 1.55; color: var(--muted); background: var(--surface-3); }
.modal-note .ic { width: 15px; height: 15px; margin-top: 1px; flex: none; }
.modal-note.is-warn { background: color-mix(in srgb, var(--warning) 10%, transparent); color: var(--warning); }
.modal-note.is-danger { background: var(--danger-soft); color: var(--danger); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 32px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2); font-size: 12px; display: inline-flex; align-items: center; gap: 5px;
  transition: all var(--fast) var(--ease);
}
.chip:hover { border-color: var(--line-strong); background: var(--surface-3); }
.chip.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip .ic { width: 14px; height: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-start { display: flex; align-items: center; gap: 8px; }
.stack { display: grid; gap: 12px; }
.stack-sm { display: grid; gap: 8px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.muted-sm { color: var(--muted); font-size: 12px; line-height: 1.55; }
.warn-text { color: var(--warning); }

/* ------------------------------------------------------------------ dashboard */
.sheet {
  position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column;
  background: var(--bg); animation: fade var(--fast) var(--ease);
}
.sheet-top {
  display: flex; align-items: center; gap: 12px; padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap;
}
.sheet-brand { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.sheet-brand svg { width: 30px; height: 30px; }
.sheet-brand strong { color: var(--ink); font-size: 14px; letter-spacing: -0.01em; }
.sheet-brand span { display: block; color: var(--muted); font-size: 11px; letter-spacing: 0.02em; }
.sheet-top .grow { flex: 1; }
.sheet-actions { display: flex; align-items: center; gap: 6px; }
.sheet-body { flex: 1; overflow-y: auto; padding: clamp(16px, 3vw, 32px) clamp(16px, 4vw, 40px) 60px; }
.dash-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.dash-hero h1 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -0.035em; font-weight: 680; }
.dash-hero p { margin-top: 6px; color: var(--muted); font-size: 13px; max-width: 60ch; }
.dash-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-card {
  min-width: 104px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-xs);
}
.stat-card strong { display: block; font-size: 20px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-card span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.dash-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.search-field { position: relative; flex: 1; min-width: 180px; max-width: 360px; }
.search-field .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-2); }
.search-field input { padding-left: 36px; min-height: 40px; background: var(--surface); }
.dash-tabs {
  display: flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: 999px;
  /* A flex child defaults to min-width:auto, which let the pill row push past the
     viewport on a 390px phone. min-width:0 + scroll keeps all four tabs reachable. */
  overflow-x: auto; max-width: 100%; min-width: 0; flex: 0 1 auto;
  scrollbar-width: none; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
}
.dash-tabs::-webkit-scrollbar { display: none; }
.dash-tabs button {
  min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted);
  font-size: 12px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.dash-tabs button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); font-weight: 600; }
.dash-tabs .count { font-size: 10px; color: var(--muted-2); }
.board-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 14px;
}
.board-card {
  position: relative; display: flex; flex-direction: column; text-align: left;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  box-shadow: var(--shadow-xs); overflow: hidden; cursor: pointer;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.board-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.board-card:focus-visible { outline: none; box-shadow: var(--ring); }
.board-thumb {
  aspect-ratio: 16 / 10; background: var(--surface-3); border-bottom: 1px solid var(--line);
  display: grid; place-items: center; overflow: hidden; position: relative;
}
.board-thumb img, .board-thumb svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.board-thumb .thumb-empty { color: var(--muted-2); display: grid; gap: 4px; justify-items: center; font-size: 10.5px; }
.board-thumb .thumb-empty .ic { width: 22px; height: 22px; }
.board-card-body { padding: 10px 12px 12px; display: grid; gap: 3px; }
.board-card-title { font-size: 13px; font-weight: 620; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 26px; }
.board-card-meta { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); }
.board-card-meta .dot { width: 2.5px; height: 2.5px; border-radius: 50%; background: var(--muted-2); }
.board-star {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; border: 1px solid transparent; background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--muted); opacity: 0; transition: opacity var(--fast) var(--ease);
  backdrop-filter: blur(6px);
}
.board-card:hover .board-star, .board-star.is-on { opacity: 1; }
.board-star.is-on { color: #d97706; }
.board-star:hover { color: #d97706; background: var(--surface); }
.board-star .ic { width: 15px; height: 15px; }
.card-menu-btn {
  position: absolute; top: 8px; right: 42px; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; border: 1px solid transparent;
  background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--muted);
  opacity: 0; transition: opacity var(--fast) var(--ease); backdrop-filter: blur(6px);
}
.board-card:hover .card-menu-btn, .card-menu-btn:focus-visible { opacity: 1; }
.board-tag {
  position: absolute; left: 8px; top: 8px; padding: 2px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--muted);
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
  backdrop-filter: blur(6px);
}
.empty-list { padding: 46px 20px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); color: var(--muted); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.empty-list .ic { width: 30px; height: 30px; margin: 0 auto 10px; color: var(--muted-2); }
.empty-list h3 { font-size: 15px; color: var(--ink); margin-bottom: 4px; }
.empty-list p { font-size: 12.5px; max-width: 46ch; margin: 0 auto 14px; }
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 14px; }
.skeleton-card { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.skeleton-thumb { aspect-ratio: 16/10; background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton-line { height: 10px; margin: 12px; border-radius: 4px; background: var(--surface-3); }
.skeleton-line.short { width: 55%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ templates */
.tpl-cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tpl-card {
  text-align: left; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
  background: var(--surface); display: flex; flex-direction: column; transition: all var(--fast) var(--ease);
}
.tpl-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.tpl-preview { aspect-ratio: 16/10; background: var(--surface-2); border-bottom: 1px solid var(--line); overflow: hidden; padding: 8px; }
.tpl-preview svg { width: 100%; height: 100%; }
.tpl-info { padding: 10px 12px 12px; }
.tpl-info strong { font-size: 12.5px; display: block; letter-spacing: -0.01em; }
.tpl-info span { font-size: 10.5px; color: var(--muted); line-height: 1.45; display: block; margin-top: 2px; }
.tpl-cat { display: inline-block; margin-top: 6px; font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); }

/* ------------------------------------------------------------------ AI dialog */
.ai-prompt-wrap { position: relative; }
.ai-prompt {
  min-height: 132px; resize: vertical; padding: 12px 14px; font-size: 13.5px; line-height: 1.6;
  border-radius: 12px; background: var(--surface-2);
}
.ai-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-example {
  max-width: 100%; padding: 6px 10px; border-radius: 8px; border: 1px dashed var(--line-strong);
  background: transparent; color: var(--muted); font-size: 11.5px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-example:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ai-meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.ai-status { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-3); font-size: 12px; color: var(--ink-2); }
.ai-status .spinner { display: block; color: var(--accent); }
.ai-result { padding: 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--success) 30%, var(--line)); background: color-mix(in srgb, var(--success) 7%, transparent); font-size: 12px; color: var(--ink-2); }
.ai-result strong { color: var(--ink); }
.ai-warn { margin-top: 6px; color: var(--warning); font-size: 11.5px; }

/* ------------------------------------------------------------------ share / export / versions / settings */
.list { display: grid; gap: 8px; }
.list-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.list-row .grow { flex: 1; min-width: 0; }
.list-row strong { font-size: 12.5px; font-weight: 600; display: block; }
.list-row span { font-size: 11px; color: var(--muted); }
.list-row code { font-family: var(--mono); font-size: 10.5px; color: var(--muted); background: var(--surface-3); padding: 2px 5px; border-radius: 4px; }
.share-link-box { display: flex; gap: 6px; }
.share-link-box input { font-family: var(--mono); font-size: 11.5px; background: var(--surface-3); }
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-card {
  text-align: left; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); display: grid; gap: 3px;
}
.mode-card strong { font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.mode-card span { font-size: 11px; color: var(--muted); line-height: 1.5; }
.mode-card .ic { width: 15px; height: 15px; color: var(--muted); }
.mode-card.is-active { border-color: var(--accent); background: var(--accent-soft); }
.mode-card.is-active strong, .mode-card.is-active .ic { color: var(--accent); }
.version-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.version-row:last-child { border-bottom: 0; }
.version-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.version-row.is-current .version-dot { background: var(--accent); }
.version-main { flex: 1; min-width: 0; }
.version-main strong { font-size: 12.5px; display: block; }
.version-main span { font-size: 11px; color: var(--muted); }
.pref-grid { display: grid; gap: 4px; }
.pref-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pref-row:last-child { border-bottom: 0; }
.pref-copy strong { display: block; font-size: 12.5px; }
.pref-copy span { font-size: 11px; color: var(--muted); }
.kbd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.kbd-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 12px; color: var(--ink-2); }
.kbd-row kbd { flex: none; }

/* ------------------------------------------------------------------ drawers */
.drawer-backdrop { position: fixed; inset: 0; z-index: 95; background: rgba(8, 12, 24, 0.3); backdrop-filter: blur(2px); animation: fade var(--fast) var(--ease); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 96; width: min(400px, 100%);
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: drawer-in var(--med) var(--ease);
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 15px; flex: 1; display: flex; align-items: center; gap: 8px; }
.drawer-head .ic { width: 18px; height: 18px; color: var(--accent); }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 18px 24px; display: grid; gap: 10px; align-content: start; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
.comment-card {
  padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
  display: grid; gap: 6px; cursor: pointer; transition: border-color var(--fast) var(--ease);
}
.comment-card:hover { border-color: var(--line-strong); }
.comment-card.is-active { border-color: var(--accent); background: var(--accent-soft); }
.comment-card header { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.comment-author { font-weight: 650; color: var(--ink-2); }
.comment-body { font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-reply { margin-left: 10px; padding-left: 10px; border-left: 2px solid var(--line); font-size: 11.5px; color: var(--ink-2); }
.comment-actions { display: flex; gap: 4px; }
.comment-actions .icon-btn { width: 28px; height: 28px; }
.comment-form { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-xs); }
.comment-form textarea { min-height: 70px; resize: vertical; }

/* ------------------------------------------------------------------ language menu */
.lang-menu {
  position: fixed; z-index: 130; width: min(360px, calc(100vw - 24px));
  max-height: min(520px, 72dvh); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; animation: pop var(--fast) var(--ease);
}
.lang-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
.lang-head strong { font-size: 12.5px; display: block; }
.lang-head span { font-size: 11px; color: var(--muted); }
.lang-search-wrap { position: relative; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.lang-search-wrap .ic { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); }
.lang-search { padding-left: 34px; min-height: 38px; }
.lang-list { overflow-y: auto; padding: 6px; }
.lang-item {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border: 0; border-radius: 8px; background: transparent; text-align: left; color: var(--ink-2); font-size: 12.5px;
}
.lang-item:hover { background: var(--surface-3); color: var(--ink); }
.lang-item .native { color: var(--muted); font-size: 11.5px; margin-left: auto; }
.lang-item .code { font-family: var(--mono); font-size: 9.5px; color: var(--muted-2); text-transform: uppercase; }
.lang-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.lang-item.is-active .native { color: var(--accent); }
.lang-item .check { width: 16px; height: 16px; opacity: 0; }
.lang-item.is-active .check { opacity: 1; }
.lang-foot { padding: 8px 12px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--muted-2); display: flex; justify-content: space-between; gap: 8px; }

/* ------------------------------------------------------------------ context menu + tooltip + toast */
.ctx-menu {
  position: fixed; z-index: 140; min-width: 228px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); animation: pop 120ms var(--ease);
}
.ctx-menu button {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 9px;
  border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); font-size: 12px; text-align: left;
}
.ctx-menu button .ic { width: 15px; height: 15px; color: var(--muted); }
.ctx-menu button span { flex: 1; }
.ctx-menu button:hover { background: var(--surface-3); color: var(--ink); }
.ctx-menu button.is-danger { color: var(--danger); }
.ctx-menu button.is-danger .ic { color: var(--danger); }
.ctx-menu button.is-danger:hover { background: var(--danger-soft); }
.ctx-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 3px; }
.ctx-menu .ctx-title { padding: 5px 9px; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-2); }
.tooltip {
  position: fixed; z-index: 150; padding: 5px 8px; border-radius: 6px;
  background: var(--ink); color: var(--surface); font-size: 11px; pointer-events: none;
  box-shadow: var(--shadow-sm); max-width: 240px;
}
.toast-region {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 160;
  display: grid; gap: 8px; justify-items: center; pointer-events: none; width: min(460px, calc(100vw - 24px));
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 9px; padding: 10px 12px;
  border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow-md); font-size: 12.5px; color: var(--ink-2);
  animation: toast-in 220ms var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.toast .ic { width: 17px; height: 17px; color: var(--success); flex: none; }
.toast.is-error .ic { color: var(--danger); }
.toast.is-warn .ic { color: var(--warning); }
.toast .grow { flex: 1; }
.toast button { border: 0; background: transparent; color: var(--accent); font-size: 12px; font-weight: 600; padding: 2px 4px; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all 180ms var(--ease); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  :root { --inspector-w: 252px; }
  .topbar-center { display: none; }
  .presence { position: absolute; right: 190px; top: 50%; transform: translateY(-50%); }
}
@media (max-width: 900px) {
  :root { --rail-w: 56px; --topbar-h: 58px; }
  .shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .rail-btn { width: 40px; height: 40px; }
  .rail-btn[data-tip]::after { display: none; }
  .board-title { width: min(34vw, 260px); }
  .topbar-logo { display: none; }
  .share-label span { display: none; }
  .topbar-right .btn-ai span { display: none; }
  .topbar-right .btn-ai { min-width: 40px; padding: 0 10px; }
  .inspector {
    top: auto; left: 10px; right: 10px; bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    width: auto; max-height: min(58dvh, 520px); border-radius: var(--r-lg);
    transform: translateY(calc(100% + 100px));
  }
  .inspector.is-open { transform: none; opacity: 1; pointer-events: auto; }
  .inspector.is-collapsed { transform: translateY(calc(100% + 100px)); }
  .toolbar {
    top: auto; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); left: 10px; right: 10px;
    transform: none; max-width: none; overflow-x: auto; scrollbar-width: none;
    justify-content: flex-start; border-radius: 16px; padding: 5px 6px;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .tool { width: 44px; height: 44px; flex: none; }
  .tool-hint { display: none; }
  .canvas-tools-left { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); left: 10px; }
  .canvas-tools-right { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); right: 10px; }
  #minimap { display: none !important; }
  .statusbar { display: none; }
  .empty-card { max-width: 460px; }
  .modal { max-height: 92dvh; }
  .auth { grid-template-columns: 1fr; }
  /* Public product: a phone still gets the pitch above the form, just compact. */
  .auth-visual { display: block; padding: 26px 20px 6px; min-height: 0; }
  .auth-visual .auth-sketch, .auth-visual .auth-glow { display: none; }
  .auth-visual .auth-points { display: none; }
  .auth-quote-title { font-size: 27px; }
  .auth-quote-body { font-size: 14px; margin-top: 8px; }
  .auth-hero-links { margin-top: 12px; }
  .auth-panel { min-height: 0; justify-content: flex-start; padding: 10px 20px 30px; gap: 16px; }
  .auth-card { margin: 0; }
  .kbd-grid { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
}
@media (max-width: 640px) {
  .topbar { gap: 6px; padding: 0 6px 0 4px; }
  .topbar-left { gap: 2px; }
  .board-title { width: min(44vw, 220px); font-size: 13px; }
  .board-status .status-sep, .board-status #board-count { display: none; }
  .topbar-right { gap: 0; }
  .topbar-right .share-label, .topbar-right [data-action="present"], .topbar-right [data-action="comments"] { display: none; }
  .btn-ai { min-height: 38px; }
  .rail { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .rail-ai { display: none; }
  .sheet-top { padding: 10px 14px; }
  .sheet-actions .btn span { display: none; }
  .sheet-actions .btn { min-width: 40px; padding: 0 10px; }
  .dash-hero h1 { font-size: 24px; }
  .board-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .board-card-body { padding: 8px 9px 10px; }
  .board-card-meta { font-size: 9.5px; }
  .board-star { opacity: 1; }
  .card-menu-btn { opacity: 1; right: 40px; }
  .modal-backdrop { padding: 0; place-items: end center; }
  .modal { width: 100%; max-height: 94dvh; border-radius: 20px 20px 0 0; animation: sheet-up 260ms var(--ease); }
  @keyframes sheet-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
  .modal-head { padding: 16px 16px 12px; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .mode-cards { grid-template-columns: 1fr; }
  .empty-card { padding: 20px; }
  .empty-actions .btn { flex: 1; min-width: 140px; }
  .empty-starters { display: none; }
  .auth-head { gap: 6px; }
  .grid-2 { grid-template-columns: 1fr; }
  .lang-btn span { display: none; }
  .lang-btn { width: 38px; justify-content: center; padding: 0; }
  .lang-btn .chev { display: none; }
  .presence { display: none; }
  .toast-region { bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .auth-visual { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-panel { padding: 14px 18px; min-height: 100dvh; overflow-y: auto; }
  .auth-card { margin: 0 auto; }
  .empty-card { padding: 14px; }
  .empty-card p, .empty-starters { display: none; }
  .inspector { max-height: 80dvh; }
  .modal { max-height: 96dvh; }
}
@media (hover: none) {
  .rail-btn[data-tip]::after, .tool-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
@media print {
  .rail, .topbar, .toolbar, .inspector, .canvas-tools-left, .canvas-tools-right, .statusbar, .present-bar { display: none !important; }
}

/* RTL */
html[dir="rtl"] .shell { grid-template-columns: minmax(0, 1fr) var(--rail-w); }
html[dir="rtl"] .rail { grid-column: 2; border-right: 0; border-left: 1px solid var(--line); }
html[dir="rtl"] .workspace { grid-column: 1; }
html[dir="rtl"] .inspector { right: auto; left: 14px; }
html[dir="rtl"] .menu { right: auto; left: 0; }
html[dir="rtl"] .rail-btn[data-tip]::after { left: auto; right: calc(100% + 8px); }
html[dir="rtl"] .board-star { right: auto; left: 8px; }
html[dir="rtl"] .card-menu-btn { right: auto; left: 42px; }
html[dir="rtl"] .board-tag { left: auto; right: 8px; }
html[dir="rtl"] .board-title { padding-left: 0; padding-right: 6px; margin-left: 0; margin-right: -6px; }
html[dir="rtl"] .statusbar { left: auto; right: calc(var(--rail-w) + 14px); }
html[dir="rtl"] .drawer { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--line); }
html[dir="rtl"] .search-field .ic { left: auto; right: 12px; }
html[dir="rtl"] .search-field input { padding-left: 12px; padding-right: 36px; }
html[dir="rtl"] .comment-pin { transform: translate(50%, -100%); }
html[dir="rtl"] .lang-item .native { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .modal-head h2, html[dir="rtl"] .menu button, html[dir="rtl"] .ctx-menu button { text-align: right; }
html[dir="rtl"] .zoom-btn, html[dir="rtl"] .zoom-value { direction: ltr; }
@media (max-width: 900px) {
  html[dir="rtl"] .inspector { left: 10px; right: 10px; }
}

/* =========================================================================
   NOVA SketchBoard AI — component aliases used by the client modules
   (toolbar, dialogs, settings, share, comments, toasts, share gate)
   ========================================================================= */

.glyph { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.glyph .ic { width: 18px; height: 18px; }
.btn .glyph .ic, .chip .glyph .ic, .seg-btn .glyph .ic { width: 15px; height: 15px; }
.tool-locked { display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; font-size: 11px; color: var(--muted); }
.tool-locked .ic { width: 14px; height: 14px; }
.tool .glyph { pointer-events: none; }
.tool .tool-hint { pointer-events: none; }

/* form primitives inside dialogs */
.field-label { font-size: 12px; font-weight: 650; color: var(--ink-2); letter-spacing: 0.01em; }
.field-input { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); }
.field-input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.16); }
.field-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.field-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ai-prompt { min-height: 126px; resize: vertical; line-height: 1.6; font-size: 13.5px; }
.ai-examples .chip { font-size: 11.5px; }
.ai-result-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.ai-result-head > .glyph { color: var(--accent); margin-top: 2px; }
.ai-result-head strong { display: block; font-size: 13px; color: var(--ink); }
.ai-result-head .hint { font-size: 11px; }
.ai-result .btn { margin-top: 10px; }
.ai-warnings { margin: 6px 0 0; padding-left: 18px; color: var(--warning); font-size: 11.5px; line-height: 1.5; }
.inline-status { min-height: 0; padding: 9px 12px; border-radius: 9px; font-size: 12px; line-height: 1.5; color: var(--ink-2); background: var(--surface-3); }
.inline-status:empty { display: none; }
.inline-status.is-ok { background: color-mix(in srgb, var(--success) 9%, transparent); color: var(--success); }
.inline-status.is-error { background: var(--danger-soft); color: var(--danger); }
.field-error { color: var(--danger); font-size: 11.5px; }
.field-hint, .hint { color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.modal .badge, .drawer .badge, .settings-profile .badge { position: static; height: auto; min-width: 0; padding: 2px 8px; font-size: 10px; border-radius: 999px; display: inline-flex; align-items: center; width: fit-content; }
.modal .badge.soft, .drawer .badge.soft, .settings-profile .badge.soft { background: var(--surface-3); color: var(--muted); }
.badge-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.modal-spacer { flex: 1; }

/* segmented control used inside dialogs */
.modal .seg, .drawer .seg, .share-gate .seg {
  display: flex; gap: 2px; padding: 3px; background: var(--surface-3);
  border: 1px solid var(--line); border-radius: 9px; margin-top: 2px;
}
.modal .seg-btn, .drawer .seg-btn, .share-gate .seg-btn {
  flex: 1; min-height: 34px; padding: 0 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.modal .seg-btn:hover, .drawer .seg-btn:hover { color: var(--ink); }
.modal .seg-btn.is-active, .drawer .seg-btn.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-xs); }

/* export */
.export-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.export-card { text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); display: grid; gap: 5px; color: var(--ink-2); }
.export-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.export-card .glyph { color: var(--accent); }
.export-card strong { font-size: 13px; }
.export-card span { font-size: 11px; color: var(--muted); line-height: 1.45; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 38px; font-size: 12px; color: var(--ink-2); }
.check-row input { width: 18px; height: 18px; min-height: 18px; accent-color: var(--accent); }
.swatch-row { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line); background: var(--sw); }
.swatch.is-active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

/* settings */
.settings-profile { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.avatar.lg { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--accent); color: #fff; }
.settings-profile-main strong { display: block; font-size: 14px; }
.settings-profile-main .hint { display: block; }
.settings-section { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.settings-section:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.settings-section h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 8px; }
.settings-form { display: grid; gap: 10px; }
.meta-list { display: grid; gap: 7px; margin: 0; }
.meta-list > div { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; color: var(--ink-2); font-weight: 600; text-align: right; }
.modal .pref-row { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.modal .pref-row:last-child { border-bottom: 0; }
.pref-main strong { display: block; font-size: 12.5px; }
.pref-main .hint { display: block; }

/* share + versions */
.share-created { margin-top: 10px; }
.share-created-inner { padding: 12px; border: 1px solid color-mix(in srgb, var(--success) 32%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--success) 7%, transparent); display: grid; gap: 8px; }
.share-created-inner strong { display: block; font-size: 12.5px; }
.copy-row { display: flex; gap: 6px; align-items: center; }
.copy-row input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 11.5px; background: var(--surface); }
.share-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.share-row:last-child { border-bottom: 0; }
.share-main { flex: 1; min-width: 0; }
.share-main strong { font-size: 12.5px; display: inline-block; margin-right: 6px; }
.share-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--accent); }
.share-list { display: grid; }
.version-list { display: grid; max-height: min(52vh, 480px); overflow: auto; }
.version-dot { flex: none; }
.empty-inline { display: flex; align-items: flex-start; gap: 10px; padding: 18px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); }
.empty-inline > .glyph { color: var(--muted-2); margin-top: 2px; }
.empty-inline strong { display: block; color: var(--ink-2); font-size: 12.5px; margin-bottom: 2px; }
.skeleton-row { padding: 10px 0; }
.skeleton { display: block; height: 38px; border-radius: 9px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }

/* comments drawer */
.drawer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.comment-list { display: grid; gap: 10px; }
.comment-thread { padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); display: grid; gap: 7px; }
.comment-thread.is-active { border-color: var(--accent); background: var(--accent-soft); }
.comment-thread.is-resolved { opacity: 0.68; }
.comment-head { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; text-align: left; padding: 0; }
.comment-avatar { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.comment-avatar.sm { width: 21px; height: 21px; font-size: 9.5px; }
.comment-head-main { flex: 1; min-width: 0; }
.comment-head-main strong { display: block; font-size: 12px; }
.comment-head-main .hint { display: block; font-size: 10.5px; }
.comment-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.comment-body { margin: 0; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); }
.comment-replies { display: grid; gap: 6px; }
.comment-reply { display: flex; gap: 7px; padding-left: 9px; border-left: 2px solid var(--line); }
.comment-reply strong { font-size: 11px; }
.comment-reply p { margin: 1px 0; font-size: 11.5px; line-height: 1.5; }
.comment-reply .hint { font-size: 10px; }
.comment-actions { display: grid; gap: 6px; }
.comment-reply-row { display: flex; gap: 5px; }
.comment-reply-row input { min-height: 34px; font-size: 12px; }
.comment-buttons { display: flex; gap: 5px; }
.comment-compose { display: grid; gap: 7px; }
.comment-compose textarea { min-height: 64px; resize: vertical; font-size: 12.5px; }
.comment-compose-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.comment-compose-actions .hint { max-width: 60%; font-size: 10.5px; }

/* command palette */
.modal-palette .modal-body { padding: 12px; }
.palette-body { display: grid; gap: 8px; }
.palette-input { min-height: 46px; font-size: 14px; }
.palette-list { display: grid; gap: 2px; max-height: min(48vh, 420px); overflow-y: auto; }
.palette-row { display: flex; align-items: center; gap: 10px; padding: 10px 11px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); text-align: left; font-size: 12.5px; width: 100%; }
.palette-row .glyph { color: var(--muted); }
.palette-row span:nth-child(2) { flex: 1; }
.palette-row.is-active { background: var(--accent-soft); color: var(--accent); }
.palette-row.is-active .glyph { color: var(--accent); }

/* share gate (public link password screen) */
.share-gate { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(900px 600px at 30% 10%, rgba(91, 91, 214, 0.12), transparent 70%), var(--bg); }
.share-gate-card { padding: clamp(20px, 4vw, 30px); border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-lg); }
.share-gate .brand-lockup { margin-bottom: 18px; }
.share-gate .auth-title { margin-top: 4px; }
.share-gate .auth-form { margin-top: 16px; }
.share-gate .form-error { margin: 0; }

@media (max-width: 720px) {
  .field-grid-2, .field-grid-3 { grid-template-columns: 1fr; }
  .export-cards { grid-template-columns: 1fr; }
  .settings-profile { align-items: flex-start; }
  .modal .seg { flex-wrap: wrap; }
  .comment-compose-actions { align-items: flex-end; }
}

@media (max-width: 480px) {
  .copy-row { flex-wrap: wrap; }
  .copy-row .btn { flex: 1; }
  .tool { width: 44px; height: 44px; }
}

/* ---------------------------------------------------- touch target contract */
/* Owner requirement: a control a finger can hit is at least 44x44 on a touch
   device. Desktop keeps its dense layout because this only applies to coarse
   pointers (phones, tablets, touch laptops in tablet mode). */
@media (pointer: coarse) {
  .btn, .btn-sm, .icon-btn, .seg, .linkish, .lang-btn, .tool, .swatch,
  .board-star, .card-menu-btn, .chip, .pill, .dash-tabs button,
  .sheet-actions .btn, .rail button, .topbar button, .modal button {
    min-height: 44px;
  }
  .icon-btn, .lang-btn, .tool, .board-star, .card-menu-btn, .swatch {
    min-width: 44px;
  }
  .btn-sm { padding: 0 12px; }
  .dash-tabs { padding: 4px; }
  .dash-tabs button { padding: 0 14px; font-size: 13px; }
  .comment-actions .icon-btn, .insp-head .icon-btn { width: 44px; height: auto; }
  .rail { gap: 4px; }
  /* Measured on a 390px viewport during QA: these three still fell short. */
  .avatar-btn { min-width: 44px; min-height: 44px; }
  .sheet-actions .btn { min-width: 44px; }
  .search-field input { min-height: 44px; }
  /* Board view: the canvas chrome is the most-used touch surface of the app. */
  .topbar button, .topbar .icon-btn, .topbar-right .btn-ai { min-width: 44px; }
  .topbar-right { gap: 0; }
  .rail button, .rail-btn { min-width: 44px; min-height: 44px; }
  .mini-toggle { width: 44px; height: 44px; }
  .pref-row .switch { min-height: 44px; min-width: 44px; }
  .insp-actions button { min-height: 44px; }
  .zoombar button { width: 44px; height: 44px; }
  .zoom-pill button, .zoom-btn, .zoom-value { min-width: 44px; min-height: 44px; }
  .zoom-pill { gap: 0; }
  .board-title { min-height: 44px; }
  .board-status .version-chip, .version-btn { min-width: 44px; min-height: 44px; }
  .inspector input, .inspector select, .inspector textarea { min-height: 44px; }
}
