/* Papilot Cloud Web UI & Review Portal
 * Unified visual system sharing exact surface, border, typography, and accent tokens
 * with Papilot Editor (theme.css) + Figma-grade File Browser ergonomics. */
@font-face { font-family: "Paper Serif"; src: url("/fonts/TeXGyrePagellaX-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Paper Serif"; src: url("/fonts/TeXGyrePagellaX-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Paper Serif"; src: url("/fonts/TeXGyrePagellaX-Italic.otf") format("opentype"); font-style: italic; font-display: swap; }
@font-face { font-family: "Paper Mono"; src: url("/fonts/Inconsolatazi4-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }

:root {
  --serif: "Paper Serif", "TeX Gyre Pagella", Palatino, "Palatino Linotype", "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  --mono: "Paper Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --mark: #dbe6fd;

  /* Exact Papilot Editor light tokens */
  --bg: #ffffff;
  --sidebar: #fafafa;
  --canvas: #f5f5f5;
  --surface: #ffffff;
  --raised: #ffffff;
  --bg-subtle: #fafafa;
  --bg-muted: #f2f2f2;
  --bg-hover: #eaeaea;
  --bg-active: #e6e6e6;
  --thumb: #ffffff;

  --line: #e6e6e6;
  --line-strong: #d9d9d9;
  --line-hover: #d4d4d4;

  --text: #1e1e1e;
  --text-2: #666666;
  --text-3: #8c8c8c;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-line: #bfdbfe;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;

  --ok: #1f883d;
  --ok-soft: #e6f6ec;
  --warn: #b45309;
  --warn-soft: #fff5e0;
  --danger: #d1242f;
  --danger-soft: #fdede9;

  --purple: #7c3aed;
  --purple-soft: #f3ecff;

  --del-bg: #fdede9;
  --del-ink: #d1242f;
  --ins-bg: #e6f6ec;
  --ins-ink: #1f883d;

  --backdrop: linear-gradient(135deg, #eaf5ff 0%, #fafafa 52%, #eef2ff 100%);
  --glass: rgb(255 255 255 / 0.86);
  --shadow-xs: 0 0 0 0.5px rgb(0 0 0 / 0.12), 0 1px 2px rgb(0 0 0 / 0.06);
  --shadow-sm: 0 0 0 0.5px rgb(0 0 0 / 0.1), 0 4px 12px rgb(0 0 0 / 0.07), 0 1px 2px rgb(0 0 0 / 0.05);
  --float: 0 0 0 0.5px rgb(0 0 0 / 0.12), 0 12px 28px rgb(0 0 0 / 0.13), 0 2px 6px rgb(0 0 0 / 0.08);
  --card-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
  --scrim: rgb(0 0 0 / 0.34);

  --menu-bg: var(--raised);
  --menu-text: var(--text);
  --menu-shadow: var(--float);

  --r-sm: 4px;
  --r: 6px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #2c2c2c;
    --sidebar: #262626;
    --canvas: #1e1e1e;
    --surface: #333333;
    --raised: #333333;
    --bg-subtle: #303030;
    --bg-muted: #383838;
    --bg-hover: #424242;
    --bg-active: #4a4a4a;
    --thumb: #4d4d4d;

    --line: #444444;
    --line-strong: #4d4d4d;
    --line-hover: #555555;

    --text: #f0f0f0;
    --text-2: #b8b8b8;
    --text-3: #8a8a8a;

    --accent: #5b8cff;
    --accent-hover: #7ba3ff;
    --accent-soft: #162139;
    --accent-line: #2c4170;
    --primary: #3466e8;
    --primary-hover: #4a78ee;

    --ok: #3fb950;
    --ok-soft: #1e3a2a;
    --warn: #e3b341;
    --warn-soft: #3d3220;
    --danger: #f85149;
    --danger-soft: #47271f;

    --purple: #a78bfa;
    --purple-soft: #31264a;

    --del-bg: #47271f;
    --del-ink: #ff8c73;
    --ins-bg: #1e3a2a;
    --ins-ink: #57d68d;

    --backdrop: linear-gradient(135deg, #212936 0%, #262626 52%, #292536 100%);
    --glass: rgb(38 38 38 / 0.84);
    --shadow-xs: 0 0 0 0.5px rgb(0 0 0 / 0.45), 0 1px 3px rgb(0 0 0 / 0.35);
    --shadow-sm: 0 0 0 0.5px rgb(0 0 0 / 0.55), 0 4px 12px rgb(0 0 0 / 0.35);
    --float: 0 0 0 0.5px rgb(255 255 255 / 0.08), 0 14px 28px rgb(0 0 0 / 0.48), 0 2px 6px rgb(0 0 0 / 0.35);
    --card-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
    --scrim: rgb(0 0 0 / 0.54);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #2c2c2c;
  --sidebar: #262626;
  --canvas: #1e1e1e;
  --surface: #333333;
  --raised: #333333;
  --bg-subtle: #303030;
  --bg-muted: #383838;
  --bg-hover: #424242;
  --bg-active: #4a4a4a;
  --thumb: #4d4d4d;

  --line: #444444;
  --line-strong: #4d4d4d;
  --line-hover: #555555;

  --text: #f0f0f0;
  --text-2: #b8b8b8;
  --text-3: #8a8a8a;

  --accent: #5b8cff;
  --accent-hover: #7ba3ff;
  --accent-soft: #162139;
  --accent-line: #2c4170;
  --primary: #3466e8;
  --primary-hover: #4a78ee;

  --ok: #3fb950;
  --ok-soft: #1e3a2a;
  --warn: #e3b341;
  --warn-soft: #3d3220;
  --danger: #f85149;
  --danger-soft: #47271f;

  --purple: #a78bfa;
  --purple-soft: #31264a;

  --del-bg: #47271f;
  --del-ink: #ff8c73;
  --ins-bg: #1e3a2a;
  --ins-ink: #57d68d;

  --backdrop: linear-gradient(135deg, #212936 0%, #262626 52%, #292536 100%);
  --glass: rgb(38 38 38 / 0.84);
  --shadow-xs: 0 0 0 0.5px rgb(0 0 0 / 0.45), 0 1px 3px rgb(0 0 0 / 0.35);
  --shadow-sm: 0 0 0 0.5px rgb(0 0 0 / 0.55), 0 4px 12px rgb(0 0 0 / 0.35);
  --float: 0 0 0 0.5px rgb(255 255 255 / 0.08), 0 14px 28px rgb(0 0 0 / 0.48), 0 2px 6px rgb(0 0 0 / 0.35);
  --card-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  --scrim: rgb(0 0 0 / 0.54);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  display: flex;
  flex-direction: column;
}
main.container {
  width: 100%;
  flex: 1 0 auto;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

/* Full-bleed Figma Workspace Mode */
html.workspace-mode,
body.workspace-mode {
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
body.workspace-mode main.container {
  max-width: none;
  margin: 0;
  padding: 0;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

html.auth-mode, body.auth-mode {
  background: var(--bg);
}

html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after {
  transition: none !important;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link:focus {
  position: fixed;
  top: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 500;
}

/* Signature Papilot 5-capsule mark */
.papilot-mark { display: block; flex: none; }
.papilot-mark .mark-top { fill: #223575; }
.papilot-mark .mark-line { fill: #ff6a64; }
.papilot-mark .mark-bottom { fill: #4d93f8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .papilot-mark .mark-top { fill: #d8e2f9; }
}
:root[data-theme="dark"] .papilot-mark .mark-top { fill: #d8e2f9; }

/* Public pages inherit papilot.ai's obsidian dark surfaces (#111214 / #17181b),
 * while signed-in workspace (.workspace-mode) retains the editor's #2c2c2c canvas. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body:not(.workspace-mode) {
    --bg: #111214;
    --surface: #17181b;
    --raised: #17181b;
    --bg-subtle: #17181b;
    --bg-muted: #1f2024;
    --bg-hover: #26272b;
    --line: #2a2b30;
    --line-strong: #3a3b41;
    --line-hover: #4a4b52;
    --text: #ececed;
    --text-2: #a9aaaf;
    --text-3: #7d7e84;
    --glass: rgb(17 18 20 / 0.78);
    --mark: rgb(91 140 255 / 0.28);
  }
}
:root[data-theme="dark"] body:not(.workspace-mode) {
  --bg: #111214;
  --surface: #17181b;
  --raised: #17181b;
  --bg-subtle: #17181b;
  --bg-muted: #1f2024;
  --bg-hover: #26272b;
  --line: #2a2b30;
  --line-strong: #3a3b41;
  --line-hover: #4a4b52;
  --text: #ececed;
  --text-2: #a9aaaf;
  --text-3: #7d7e84;
  --glass: rgb(17 18 20 / 0.78);
  --mark: rgb(91 140 255 / 0.28);
}

/* --- Public Topbar (Aligned with papilot.ai: 64px height, Paper Serif brand, left nav, pill actions) --- */
header.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--glass);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1120px;
  min-height: 64px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 21px;
  line-height: 1;
  letter-spacing: -0.005em;
  color: var(--text);
  text-decoration: none;
}
.brand:hover {
  text-decoration: none;
}
.sidebar-brand {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.96rem;
  letter-spacing: -0.02em;
  gap: 0.5rem;
}

nav.primary-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.topbar-inner > .brand + .topbar-actions {
  margin-inline-start: auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
}

.theme-slot {
  display: inline-flex;
  align-items: center;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 400;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  transition: color 140ms ease, background-color 140ms ease;
}
.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}
.nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.topbar-universe {
  color: var(--text);
  font-weight: 500;
  padding-inline: 10px 13px;
}
.universe-icon {
  flex: none;
  overflow: visible;
  color: var(--accent);
}
.universe-planet {
  fill: color-mix(in srgb, currentColor 26%, var(--bg));
}
.universe-orbit {
  transform-origin: 12px 12px;
}
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
  .topbar-universe:hover .universe-orbit {
    animation: universe-orbit 1.4s ease-in-out;
  }
}
@keyframes universe-orbit {
  to { transform: rotate(360deg); }
}

.pill-btn {
  border-radius: 999px;
}
#topbar-get-started {
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--primary);
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
}
#topbar-get-started:hover {
  background: var(--primary-hover);
}

.topbar-actions .pill-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  text-decoration: none;
}
.topbar-actions .pill-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

/* --- Figma-Grade 2-Pane Full-Bleed Workspace Shell --- */
.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: var(--scrim);
}

.app-sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  user-select: none;
}

.sidebar-brand-bar {
  height: 48px;
  flex: none;
  padding: 0 10px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.sidebar-brand-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.rail-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease;
}
.rail-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.mobile-only {
  display: none;
}

.sidebar-search-wrap {
  padding: 10px 10px 6px;
  flex: none;
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 9px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: var(--bg-muted);
  color: var(--text-3);
  transition: background-color 120ms ease, border-color 120ms ease;
}
.sidebar-search:hover {
  border-color: var(--line-hover);
}
.sidebar-search:focus-within {
  background: var(--bg);
  border-color: var(--accent);
}
.sidebar-search svg {
  flex: none;
  color: var(--text-3);
}
.sidebar-search input {
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 28px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.4;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}
.sidebar-search input:focus {
  outline: none;
  box-shadow: none;
}
.sidebar-search input::placeholder {
  color: var(--text-3);
}

.sidebar-nav-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--text-2);
  font: 500 13px/1.2 var(--sans);
  text-align: start;
  cursor: pointer;
  transition: none;
}
.sidebar-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.sidebar-item:active {
  transform: none;
}
.sidebar-item-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.sidebar-item-left svg {
  flex: none;
  color: var(--text-3);
}
.sidebar-item:hover .sidebar-item-left svg {
  color: var(--text-2);
}
.sidebar-item-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-item[aria-current="page"] .sidebar-item-left svg {
  color: var(--accent);
}

.sidebar-count {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  padding: 1px 6px;
  border-radius: 999px;
}
.sidebar-item[aria-current="page"] .sidebar-count {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.sidebar-sep {
  height: 1px;
  background: var(--line);
  margin: 8px 6px;
}

/* Bottom Sidebar Footer — Exact match to Papilot Editor HostAccountMenu */
.sidebar-footer {
  flex: none;
  padding: 6px 8px;
  border-top: 1px solid var(--line);
  background: var(--sidebar);
}

.host-account {
  min-width: 0;
}

.host-account-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 4px 6px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background-color 110ms ease;
}
.host-account-trigger:hover,
.host-account-trigger[aria-expanded="true"] {
  background: var(--bg-hover);
}
.host-account-trigger:active { transform: none; }
.host-account-trigger > svg:last-child {
  flex-shrink: 0;
  color: var(--text-3);
}

.host-account-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.02em;
}

.host-account-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}
.host-account-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.host-account-plan {
  font-size: 10.5px;
  line-height: 1.2;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-account-usage-pill {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-2);
  font: 600 10.5px/1.2 var(--sans);
  font-variant-numeric: tabular-nums;
}
.host-account-usage-pill.is-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.host-account-usage-pill.is-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.host-account-popover {
  min-width: 232px;
  max-width: min(272px, calc(100vw - 16px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--menu-bg);
  color: var(--menu-text);
  box-shadow: var(--menu-shadow);
  font-size: 12px;
}
.host-account-popover:popover-open {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

@supports (position-area: block-start) {
  #account-menu-trigger {
    anchor-name: --host-account-trigger;
  }
  .host-account-popover {
    position-anchor: --host-account-trigger;
    position: fixed;
    inset: auto;
    margin: 0;
    margin-block-end: 6px;
    position-area: block-start span-inline-end;
    position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
  }
}
@supports not (position-area: block-start) {
  .host-account-popover {
    position: fixed;
    inset: auto;
    margin: 0;
  }
}

@supports (transition-behavior: allow-discrete) {
  .host-account-popover,
  .context-popover {
    opacity: 0;
    translate: 0 4px;
    transition: opacity 110ms ease, translate 110ms ease, display 110ms allow-discrete, overlay 110ms allow-discrete;
  }
  .host-account-popover:popover-open,
  .context-popover:popover-open {
    opacity: 1;
    translate: 0 0;
    @starting-style {
      opacity: 0;
      translate: 0 4px;
    }
  }
}

.host-account-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 8px 8px;
}
.host-account-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.host-account-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.host-account-email {
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.host-account-usage {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.host-account-usage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.host-account-usage-row strong {
  font-weight: 600;
  color: var(--text);
}
.host-account-usage.is-warn .host-account-usage-row strong { color: var(--warn); }
.host-account-usage.is-danger .host-account-usage-row strong { color: var(--danger); }

.host-account-progress {
  width: 100%;
  height: 5px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-muted);
  accent-color: var(--accent);
}
.host-account-progress::-webkit-progress-bar {
  background: var(--bg-muted);
  border-radius: 999px;
}
.host-account-progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}
.host-account-usage.is-warn .host-account-progress::-webkit-progress-value { background: var(--warn); }
.host-account-usage.is-danger .host-account-progress::-webkit-progress-value { background: var(--danger); }

.host-account-sep {
  height: 1px;
  border: 0;
  margin: 4px 2px;
  background: var(--line);
}

.host-account-menu {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.host-account-menu > button,
.context-popover > button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 30px;
  padding: 5px 8px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--text);
  font: 400 12.5px/1.25 var(--sans);
  text-align: left;
  justify-content: flex-start;
  cursor: pointer;
  transition: background-color 100ms ease;
}
.host-account-menu > button:hover,
.host-account-menu > button:focus-visible,
.context-popover > button:hover,
.context-popover > button:focus-visible {
  background: var(--bg-muted);
  outline: none;
}
.host-account-menu > button:active,
.context-popover > button:active { transform: none; }
.host-account-menu > button > svg,
.context-popover > button > svg {
  flex-shrink: 0;
  color: var(--text-2);
}
.host-account-menu > .danger-text,
.host-account-menu > .danger-text > svg,
.context-popover > .danger-text,
.context-popover > .danger-text > svg {
  color: var(--danger);
}
.host-account-menu > .danger-text:hover,
.context-popover > .danger-text:hover {
  background: var(--danger-soft);
}

/* --- Main Workspace Pane & Sticky 48px Bar --- */
.ws-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

.ws-topbar {
  height: 48px;
  flex: none;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ws-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ws-topbar-title {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-topbar-count {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

.ws-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* Crisp Figma-style Workspace Buttons */
.ws-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: var(--r);
  font: 500 12.5px/1 var(--sans);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 110ms ease, border-color 110ms ease, color 110ms ease;
}
.ws-btn:active { transform: none; }
.ws-btn.primary {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #ffffff;
}
.ws-btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.ws-btn.secondary {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
}
.ws-btn.secondary:hover {
  background: var(--bg-muted);
  border-color: var(--line-hover);
}
.ws-btn.ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
}
.ws-btn.ghost:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.ws-scroll-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 28px 56px;
}

.ws-inner-container {
  max-width: 1080px;
  margin: 0 auto;
}

.ws-page-title {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 2.5vw, 1.95rem);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.ws-projects-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* --- Slim Projects Toolbar (Sort & Grid/List Switcher) --- */
.projects-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.projects-subbar-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.projects-visible-count {
  font-size: 12px;
  color: var(--text-3);
}

.projects-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-select {
  width: auto;
  min-height: 28px !important;
  height: 28px;
  padding: 0 26px 0 9px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}
.sort-select:hover {
  border-color: var(--line-hover);
  color: var(--text);
}

.view-switcher {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: var(--r);
  background: var(--bg-muted);
  border: 1px solid var(--line);
}

.view-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease;
}
.view-switch-btn:hover {
  color: var(--text);
  background: transparent;
}
.view-switch-btn:active { transform: none; }
.view-switch-btn[aria-pressed="true"] {
  background: var(--thumb);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.1);
}

/* --- Figma Visual Project Cards Grid --- */
.projects-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(256px, 1fr));
  gap: 16px;
}

.project-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}
.project-card:hover {
  border-color: var(--line-hover);
  box-shadow: var(--shadow-sm);
}

.project-thumb {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  aspect-ratio: 16 / 10;
  padding: 16px 24px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--canvas);
  overflow: hidden;
  cursor: pointer;
  text-align: start;
}
.project-thumb:hover {
  background: var(--canvas);
}
.project-thumb:active { transform: none; }

/* Miniature Typeset Paper Sheet inside Thumbnail */
.paper-sheet-preview {
  width: 78%;
  height: 100%;
  background: #ffffff;
  color: #1e1e1e;
  border: 1px solid rgb(0 0 0 / 0.09);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  box-shadow: 0 3px 12px rgb(0 0 0 / 0.08);
  padding: 12px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  transition: transform 180ms ease;
}
:root[data-theme="dark"] .paper-sheet-preview {
  background: #f3f3f1;
  border-color: rgb(0 0 0 / 0.35);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .paper-sheet-preview {
    background: #f3f3f1;
    border-color: rgb(0 0 0 / 0.35);
    box-shadow: 0 4px 14px rgb(0 0 0 / 0.35);
  }
}
.project-card:hover .paper-sheet-preview {
  transform: translateY(-3px);
}

.paper-sheet-rule-top {
  width: 28%;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.72;
}
.paper-sheet-title {
  font-family: var(--serif);
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1.25;
  color: #1e1e1e;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.paper-sheet-abstract {
  height: 2.5px;
  width: 68%;
  border-radius: 2px;
  background: #b0b0b0;
  margin-bottom: 2px;
}
.paper-sheet-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
.paper-sheet-cols.is-twocol {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.paper-sheet-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.paper-line {
  height: 2.5px;
  border-radius: 2px;
  background: #d8d8d8;
  width: 100%;
}
.paper-line.w-90 { width: 90%; }
.paper-line.w-80 { width: 80%; }
.paper-line.w-65 { width: 65%; }
.paper-line.heading {
  height: 3px;
  width: 48%;
  background: #9a9a9a;
  margin-top: 2px;
}

.thumb-status-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-2);
  backdrop-filter: blur(6px);
}

.thumb-open-pill,
.project-open-pill {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: #1e1e1e;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}
:root[data-theme="dark"] .thumb-open-pill,
:root[data-theme="dark"] .project-open-pill {
  background: #f0f0f0;
  color: #1e1e1e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .thumb-open-pill,
  :root:not([data-theme="light"]) .project-open-pill {
    background: #f0f0f0;
    color: #1e1e1e;
  }
}
.project-card:hover .thumb-open-pill,
.project-thumb:focus-visible .thumb-open-pill {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.project-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 8px 10px 12px;
}

.project-card-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.project-card-title {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 3px;
  color: var(--text);
  font: 600 13px/1.3 var(--sans);
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.project-card-title:hover {
  background: transparent;
  color: var(--accent);
}
.project-card-title:active { transform: none; }

.project-card-sub {
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background-color 100ms ease, color 100ms ease;
}
.card-menu-btn:hover,
.card-menu-btn[aria-expanded="true"] {
  background: var(--bg-muted);
  color: var(--text);
}
.card-menu-btn:active { transform: none; }

/* Shared Project Context Popover */
.context-popover {
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 190px;
  max-width: calc(100vw - 16px);
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--menu-bg);
  color: var(--menu-text);
  box-shadow: var(--menu-shadow);
}
.context-popover:popover-open {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Crisp Figma List View Table */
.card.projects-table-card {
  padding: 0;
  border-radius: var(--r-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.projects-table th {
  padding: 9px 14px;
  background: var(--bg-subtle);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}
.projects-table td {
  padding: 10px 14px;
  vertical-align: middle;
  font-size: 13px;
}
.projects-table tbody tr {
  transition: background-color 90ms ease;
}
.projects-table tbody tr:hover {
  background: var(--bg-subtle);
}
.projects-table tbody tr:last-child td {
  border-bottom: 0;
}

.list-paper-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.list-paper-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--r);
  background: var(--canvas);
  border: 1px solid var(--line);
  color: var(--text-2);
}

.project-title-btn {
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 3px;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  text-align: start;
  justify-content: flex-start;
  cursor: pointer;
}
.project-title-btn:hover {
  background: transparent;
  color: var(--accent);
}
.project-title-btn:active { transform: none; }

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  flex: none;
}
.status-dot.running { background: var(--ok); }
.status-dot.starting { background: var(--accent); animation: status-pulse 1.2s ease-in-out infinite; }
.status-dot.stopped { background: var(--text-3); }
.status-dot.suspended { background: var(--warn); }
.status-dot.archived { background: var(--text-3); }
@keyframes status-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .status-dot.starting { animation: none; } }

.list-status-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
}

.actions-col {
  text-align: end;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.empty-projects {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 44px 24px;
  border-radius: var(--r-lg);
  border: 1px dashed var(--line-strong);
  background: var(--bg-subtle);
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--bg-muted);
  color: var(--text-2);
}
.empty-projects p {
  max-width: 44ch;
}

/* --- Faithful Papilot New Paper Dialog (Blank | Import | Templates) --- */
dialog.np-dialog {
  width: 580px;
  max-width: calc(100vw - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--float);
  overflow: visible;
}
dialog.np-dialog::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(2px);
}

.np-dialog-inner {
  padding: 16px 18px 18px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.np-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.np-dialog-head h2 {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

/* Hairline-underlined tabs copied from new-paper-dialog.css */
.new-paper-tabs {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 38px;
  margin: 0 -18px 16px;
  padding: 0 18px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}
.new-paper-tabs [role="tab"] {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font: 500 12.5px/1 var(--sans);
  color: var(--text-3);
  white-space: nowrap;
  cursor: pointer;
  transition: color 130ms ease;
}
.new-paper-tabs [role="tab"]:hover:not(:disabled) {
  background: transparent;
  color: var(--text-2);
}
.new-paper-tabs [role="tab"]:active { transform: none; }
.new-paper-tabs [role="tab"][aria-selected="true"] {
  color: var(--text);
  font-weight: 600;
}
.new-paper-tabs [role="tab"][aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}
.new-paper-tabs [role="tab"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: var(--r-sm);
}

.np-panel {
  min-width: 0;
}

.np-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.np-field label,
.np-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}
.np-field input[type="text"],
.np-field input[type="url"] {
  min-height: 34px !important;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  font-size: 13px;
}

/* Segmented starter layout control */
.np-segmented {
  display: inline-flex;
  align-self: flex-start;
  padding: 2px;
  border-radius: 7px;
  background: var(--bg-muted);
  border: 1px solid var(--line);
  gap: 2px;
  flex-wrap: wrap;
}
.np-seg-btn {
  height: 26px;
  padding: 0 11px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font: 500 12px/1 var(--sans);
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease;
}
.np-seg-btn:hover {
  background: transparent;
  color: var(--text);
}
.np-seg-btn:active { transform: none; }
.np-seg-btn[aria-checked="true"] {
  background: var(--thumb);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.1);
}

.np-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* --- Import Tab (copied faithfully from import-dialog.css) --- */
.import-copy h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.import-copy > p {
  margin: 4px 0 14px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}

.import-path {
  margin: 0 0 16px;
}
.import-path > label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}
.import-path-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.import-path-row input {
  flex: 1;
  min-width: 0;
  min-height: 32px !important;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r);
  font-size: 12.5px;
  margin: 0;
}
.import-path-row .ws-btn {
  height: 32px;
  flex: none;
}

.import-link-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-3);
}
.import-source {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  color: var(--text-2);
}
.import-source svg {
  flex: none;
  opacity: 0.85;
}

.import-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 16px 18px;
  border: 1px dashed var(--line-hover);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  transition: border-color 140ms ease, background-color 140ms ease;
}
.import-drop.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.import-drop-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-2);
  text-align: center;
}
.import-drop-hint svg {
  flex: none;
  color: var(--text-3);
}
.import-options {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.import-options .ws-btn svg {
  color: var(--text-2);
}

.import-location {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 10px 10px 12px;
  border-radius: var(--r-md);
  background: var(--bg-muted);
}
.import-location > svg {
  flex: none;
  color: var(--text-2);
}
.import-location-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.import-location-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
}
.import-location-path {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text);
}
.import-location-path strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-staged-count {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
}

.import-reading,
.create-paper-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-2);
}

.inline-error {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: var(--r);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--accent-line);
  border-top-color: var(--accent);
  animation: spin 700ms linear infinite;
  flex: none;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Templates Tab (copied faithfully from create-paper-dialog.css) --- */
.template-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 6px 8px 6px 12px;
  border-radius: var(--r-md);
  background: var(--bg-muted);
  font-size: 12px;
  color: var(--text-2);
}
.template-status > span { flex: 1; min-width: 0; }
.template-status > .ws-btn { flex: none; }

.template-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  margin: 0 0 14px;
}
.template-browse {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.template-search {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 248px;
  max-width: 100%;
  min-width: 0;
  height: 30px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: var(--bg-muted);
  color: var(--text-3);
  transition: background-color 120ms ease, border-color 120ms ease;
}
.template-search:hover { border-color: var(--line-hover); }
.template-search:focus-within {
  background: var(--bg);
  border-color: var(--accent);
}
.template-search input {
  width: 100%;
  min-width: 0;
  min-height: 0 !important;
  height: 28px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}
.template-search input:focus { outline: none; box-shadow: none; }

.template-contribute {
  flex: none;
  font-size: 12px;
}

.template-groups {
  display: flex;
  align-self: flex-start;
  gap: 2px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding: 2px;
  border-radius: 7px;
  background: var(--bg-muted);
}
.template-group-btn {
  flex: none;
  height: 24px;
  padding: 0 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font: 500 12px/1 var(--sans);
  color: var(--text-2);
  cursor: pointer;
}
.template-group-btn:hover {
  background: transparent;
  color: var(--text);
}
.template-group-btn:active { transform: none; }
.template-group-btn[aria-pressed="true"] {
  background: var(--thumb);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
  max-height: min(52dvh, 420px);
  overflow-y: auto;
  list-style: none;
  padding: 2px;
  margin: 0 -2px;
}
.template-grid > li {
  display: flex;
  min-width: 0;
}
.template-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  text-align: left;
  justify-content: flex-start;
  cursor: pointer;
}
.template-card:hover { background: transparent; }
.template-card:active { transform: none; }
.template-card .template-thumb {
  aspect-ratio: 3 / 4;
  margin-bottom: 6px;
  border-radius: var(--r-md);
  box-shadow: 0 0 0 1px var(--line);
}
.template-card:hover .template-thumb {
  box-shadow: 0 0 0 1px var(--line-hover);
}
.template-card[aria-pressed="true"] .template-thumb {
  box-shadow: 0 0 0 2px var(--accent);
}
.template-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.template-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--canvas);
  color: var(--text-3);
}
.template-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  background: #ffffff;
}

/* Miniature typographic preview inside built-in template cards */
.tpl-paper-mini {
  width: 100%;
  height: 100%;
  background: #ffffff;
  color: #1e1e1e;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.tpl-paper-mini.is-mini {
  padding: 6px 5px;
  gap: 3px;
}
.tpl-paper-mini-tag {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0b8af0;
}
.tpl-paper-mini-title {
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  color: #1e1e1e;
}
.tpl-paper-mini.is-mini .tpl-paper-mini-title {
  font-size: 5px;
}

.template-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.template-meta {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.template-card.placeholder .template-thumb {
  animation: template-pulse 1.15s ease-in-out infinite alternate;
}
@keyframes template-pulse {
  from { opacity: 0.45; }
  to { opacity: 0.95; }
}

.template-empty-msg {
  text-align: center;
  padding: 24px 12px;
}

.template-chosen {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  padding: 8px;
  border-radius: var(--r-md);
  background: var(--bg-muted);
}
.template-chosen .template-thumb {
  flex: none;
  width: 36px;
  height: 48px;
  border-radius: var(--r-sm);
  box-shadow: 0 0 0 1px var(--line);
  background: var(--bg);
}
.template-chosen-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.template-chosen-text strong {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.template-chosen-text span {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Minimalist Single-Viewport Pricing Stage --- */
.stack-lg { display: flex; flex-direction: column; gap: 2rem; }

.pricing-stage {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1.75rem 0 2.5rem;
}

.pricing-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.55rem;
  max-width: 540px;
  margin: 0 auto;
}

.pricing-title {
  font-family: var(--serif);
  font-size: clamp(2.15rem, 3.8vw, 2.85rem);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--text);
}
.pricing-title ins {
  padding: 0 0.05em;
  background: linear-gradient(transparent 66%, var(--mark) 66%, var(--mark) 90%, transparent 90%) no-repeat 0 0 / 100% 100%;
  text-decoration: none;
}

.pricing-lead {
  color: var(--text-2);
  font-size: 0.95rem;
  line-height: 1.55;
  text-wrap: balance;
}

.billing-toggle {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg-muted);
  border: 1px solid var(--line);
  margin-top: 0.7rem;
}

.billing-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  border-radius: 999px;
  padding: 0.36rem 1rem;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
}
.billing-toggle-btn[aria-pressed="true"] {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
  font-weight: 600;
}

.save-chip {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ok);
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.plan-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.35rem;
  overflow: hidden;
  transition: border-color 140ms ease, background-color 140ms ease;
}
.plan-card:hover {
  border-color: var(--line-hover);
}
.plan-card.starter {
  background: var(--bg-subtle);
}
.plan-card.starter .feat-mark.is-yes {
  background: var(--bg-muted);
  color: var(--text-2);
}

/* Pro — Crisp Light Blue (clearly stronger than Free gray, one calm step below Max blue) */
.plan-card.pro-tier {
  border: 1.5px solid #60a5fa;
  background: #f4f8ff;
}
.plan-card.pro-tier:hover {
  border-color: #3b82f6;
}
.plan-card.pro-tier .plan-badge {
  background: #dbeafe;
  color: #1d4ed8;
}
.plan-card.pro-tier .feat-mark.is-yes {
  background: #dbeafe;
  color: #2563eb;
}

/* Max — Popular Papilot Theme Blue */
.plan-card.featured {
  border: 1.5px solid var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 72%, var(--surface));
}
.plan-card.featured:hover {
  border-color: var(--accent-hover);
}

/* Ultra — Flat Cobalt-to-Violet Spectrum (inspired by ChatGPT Max effort: #2545cb → #5f55e3 → #9964ff) */
.plan-card.flagship {
  border: 1.5px solid transparent;
  background:
    linear-gradient(#f8f6ff, #f8f6ff) padding-box,
    linear-gradient(135deg, #2545cb 0%, #5f55e3 42%, #9964ff 78%, #7c65fa 100%) border-box;
}
.plan-card.flagship:hover {
  background:
    linear-gradient(#f5f2ff, #f5f2ff) padding-box,
    linear-gradient(135deg, #1e3ab5 0%, #5046d4 42%, #8953ee 78%, #6c53eb 100%) border-box;
}
.plan-card.flagship .plan-badge {
  background: linear-gradient(95deg, #2545cb 0%, #6857ea 52%, #9964ff 100%);
  color: #ffffff;
}
.plan-card.flagship .feat-mark.is-yes {
  background: #ede9fe;
  color: #8953ee;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .plan-card.pro-tier {
    border-color: #4f7fe0;
    background: #141c2c;
  }
  :root:not([data-theme="light"]) .plan-card.pro-tier .plan-badge {
    background: #1b2f57;
    color: #93c5fd;
  }
  :root:not([data-theme="light"]) .plan-card.pro-tier .feat-mark.is-yes {
    background: #1b2f57;
    color: #7ba3ff;
  }
  :root:not([data-theme="light"]) .plan-card.flagship {
    background:
      linear-gradient(#1a1729, #1a1729) padding-box,
      linear-gradient(135deg, #3b63e6 0%, #7366f0 45%, #a87bff 82%, #8c75ff 100%) border-box;
  }
  :root:not([data-theme="light"]) .plan-card.flagship:hover {
    background:
      linear-gradient(#1f1b31, #1f1b31) padding-box,
      linear-gradient(135deg, #4f74f0 0%, #8377f5 45%, #b58cff 82%, #9a85ff 100%) border-box;
  }
  :root:not([data-theme="light"]) .plan-card.flagship .feat-mark.is-yes {
    background: #2b2147;
    color: #b191ff;
  }
}
:root[data-theme="dark"] .plan-card.pro-tier {
  border-color: #4f7fe0;
  background: #141c2c;
}
:root[data-theme="dark"] .plan-card.pro-tier .plan-badge {
  background: #1b2f57;
  color: #93c5fd;
}
:root[data-theme="dark"] .plan-card.pro-tier .feat-mark.is-yes {
  background: #1b2f57;
  color: #7ba3ff;
}
:root[data-theme="dark"] .plan-card.flagship {
  background:
    linear-gradient(#1a1729, #1a1729) padding-box,
    linear-gradient(135deg, #3b63e6 0%, #7366f0 45%, #a87bff 82%, #8c75ff 100%) border-box;
}
:root[data-theme="dark"] .plan-card.flagship:hover {
  background:
    linear-gradient(#1f1b31, #1f1b31) padding-box,
    linear-gradient(135deg, #4f74f0 0%, #8377f5 45%, #b58cff 82%, #9a85ff 100%) border-box;
}
:root[data-theme="dark"] .plan-card.flagship .feat-mark.is-yes {
  background: #2b2147;
  color: #b191ff;
}

.plan-card-head {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.plan-card-head .between {
  min-height: 24px;
  flex-wrap: nowrap;
}
.plan-card-head h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.plan-tagline {
  font-size: 0.82rem;
  line-height: 1.4;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.52rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-muted);
  color: var(--text-2);
}
.plan-card.featured .plan-badge {
  background: var(--primary);
  color: #ffffff;
}

.plan-price-block {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.plan-price-row {
  display: flex;
  align-items: baseline;
  gap: 0.32rem;
  flex-wrap: nowrap;
}
.plan-price-strike {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  text-decoration: line-through;
}
.plan-price {
  font-family: var(--sans);
  font-size: 1.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--text);
}
.plan-period {
  font-size: 0.78rem;
  color: var(--text-3);
  white-space: nowrap;
}
.plan-savings-pill {
  margin-left: auto;
  flex: none;
  white-space: nowrap;
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--ok-soft);
  color: var(--ok);
}

.plan-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
  font-size: 0.83rem;
  line-height: 1.38;
  color: var(--text);
}
.plan-features li {
  display: flex;
  align-items: center;
  gap: 0.52rem;
}
.plan-features li.is-excluded {
  color: var(--text-3);
}
.plan-features li.is-excluded > span:last-child {
  opacity: 0.68;
}
.feat-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 999px;
}
.feat-mark.is-yes {
  background: var(--ok-soft);
  color: var(--ok);
}
.plan-card.featured .feat-mark.is-yes {
  background: var(--accent-soft);
  color: var(--accent);
}
.feat-mark.is-no {
  background: transparent;
  color: var(--text-3);
  opacity: 0.55;
}
.feat-mark svg {
  width: 11px;
  height: 11px;
  stroke-width: 2.6;
}

.plan-cta {
  width: 100%;
  height: 40px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;
}
.plan-cta:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--line-hover);
}
.plan-cta.pro-cta {
  border: 1.5px solid #60a5fa;
  background: #dbeafe;
  color: #1d4ed8;
}
.plan-cta.pro-cta:hover:not(:disabled) {
  background: #bfdbfe;
  border-color: #3b82f6;
}
.plan-cta.featured-cta {
  border-color: transparent;
  background: var(--primary);
  color: #ffffff;
}
.plan-cta.featured-cta:hover:not(:disabled) {
  background: var(--primary-hover);
}
.plan-cta.flagship-cta {
  border-color: transparent;
  background: linear-gradient(95deg, #2545cb 0%, #5f55e3 36%, #9964ff 74%, #8953ee 100%);
  color: #ffffff;
}
.plan-cta.flagship-cta:hover:not(:disabled) {
  background: linear-gradient(95deg, #1e3ab5 0%, #5046d4 36%, #8953ee 74%, #7945e0 100%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .plan-cta.pro-cta {
    border-color: #5b8cff;
    background: #1e3563;
    color: #dbeafe;
  }
  :root:not([data-theme="light"]) .plan-cta.pro-cta:hover:not(:disabled) {
    background: #25417a;
    border-color: #7ba3ff;
  }
  :root:not([data-theme="light"]) .plan-cta.flagship-cta {
    background: linear-gradient(95deg, #2d51db 0%, #685dec 38%, #9b6bff 76%, #8a5ef5 100%);
    color: #ffffff;
  }
  :root:not([data-theme="light"]) .plan-cta.flagship-cta:hover:not(:disabled) {
    background: linear-gradient(95deg, #3a5ee6 0%, #766cf2 38%, #a97dff 76%, #986fff 100%);
  }
}
:root[data-theme="dark"] .plan-cta.pro-cta {
  border-color: #5b8cff;
  background: #1e3563;
  color: #dbeafe;
}
:root[data-theme="dark"] .plan-cta.pro-cta:hover:not(:disabled) {
  background: #25417a;
  border-color: #7ba3ff;
}
:root[data-theme="dark"] .plan-cta.flagship-cta {
  background: linear-gradient(95deg, #2d51db 0%, #685dec 38%, #9b6bff 76%, #8a5ef5 100%);
  color: #ffffff;
}
:root[data-theme="dark"] .plan-cta.flagship-cta:hover:not(:disabled) {
  background: linear-gradient(95deg, #3a5ee6 0%, #766cf2 38%, #a97dff 76%, #986fff 100%);
}

/* Open-Source Local Companion Banner (papilot.ai 16px flat hairline card + pill controls) */
.local-oss-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 1.15rem 1.4rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
}
.local-oss-copy {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  flex: 1 1 320px;
}
.local-oss-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.local-oss-title {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text);
}
.local-oss-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-muted);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 500;
}
.local-oss-copy p {
  font-size: 0.86rem;
  line-height: 1.5;
}
.local-oss-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.local-install-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  height: 38px;
  padding: 0 0.45rem 0 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text);
}
.local-prompt {
  color: var(--accent);
  margin-inline-end: 0.25rem;
}
.local-copy-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.local-copy-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.local-copy-btn .icon-check { display: none; color: var(--ok); }
.local-copy-btn.is-copied .icon-copy { display: none; }
.local-copy-btn.is-copied .icon-check { display: block; }
.btn.local-download-btn {
  height: 38px;
  padding: 0 1.05rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Billing & Quota Widgets */
.mono.balance-figure {
  font-size: 2rem;
  line-height: 1.1;
  font-weight: 600;
  color: var(--accent);
}
.quota-figure-row {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.quota-progress {
  width: 100%;
  height: 8px;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-muted);
}
.quota-progress::-webkit-progress-bar {
  background: var(--bg-muted);
  border-radius: 999px;
}
.quota-progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
  transition: width 220ms ease;
}
.quota-progress[data-level="warn"]::-webkit-progress-value { background: var(--warn); }
.quota-progress[data-level="high"]::-webkit-progress-value { background: var(--danger); }
.quota-progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}
.quota-progress[data-level="warn"]::-moz-progress-bar { background: var(--warn); }
.quota-progress[data-level="high"]::-moz-progress-bar { background: var(--danger); }

.profile-form-row { align-items: flex-end; }
.profile-field { flex: 1; min-width: 220px; }
.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.dialog-intro { margin: 0.35rem 0 1rem; }
.dialog-form { margin-top: 0.85rem; }
.dialog-actions { justify-content: flex-end; margin-top: 1rem; }
.flex-1 { flex: 1; }
.review-layout-top { margin-top: 1rem; }
.review-comments-heading { font-size: 1.2rem; }
.comment-quote-line { margin: 0.35rem 0; }
.comment-body-line { margin: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.ledger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.ledger-row:last-child { border-bottom: 0; }
.ledger-pos { color: var(--ok); font-weight: 600; }
.ledger-neg { color: var(--text-2); font-weight: 600; }

/* Public Footer */
.site-footer {
  margin-top: auto;
}
.site-footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.subtle-link {
  color: var(--text-3);
  font-size: 0.83rem;
  text-decoration: none;
}
.subtle-link:hover { color: var(--text); }

/* Typography */
h1, h2 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0;
}
h1 { font-size: clamp(1.7rem, 3vw, 2.2rem); line-height: 1.2; }
h2 { font-size: 1.25rem; line-height: 1.3; }
h3 { font-size: 0.98rem; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
p { margin: 0; }
.muted { color: var(--text-2); font-size: 0.88rem; }
.subtle { color: var(--text-3); font-size: 0.8rem; }
code, .mono { font-family: var(--mono); font-size: 0.88em; }

/* Flash Banner */
.banner {
  max-width: 100%;
  padding: 0.65rem 0.95rem;
  border-radius: var(--r-md);
  font-size: 0.85rem;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.banner.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.banner.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.banner-text { flex: 1; min-width: 0; }
.banner-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: currentColor;
  opacity: 0.7;
  cursor: pointer;
}
.banner-close:hover {
  opacity: 1;
  background: rgb(128 128 128 / 0.14);
}

/* --- Side-by-Side Editorial Auth Stage (Flat papilot.ai aesthetic) --- */
.auth-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 156px);
  padding: 2rem 0 2.75rem;
}

.auth-split {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 3.5rem;
  align-items: center;
}

.auth-aside {
  display: flex;
  flex-direction: column;
  gap: 1.45rem;
  padding: 2rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
}

.auth-aside-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
  width: fit-content;
  padding: 0.28rem 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-2);
}

.auth-aside-title {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 2.5vw, 2.2rem);
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--text);
}
.auth-aside-title ins {
  padding: 0 0.05em;
  background: linear-gradient(transparent 66%, var(--mark) 66%, var(--mark) 90%, transparent 90%) no-repeat 0 0 / 100% 100%;
  text-decoration: none;
}

.auth-diff-card {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}
.auth-diff-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--line);
  background: var(--accent-soft);
  font-size: 0.75rem;
}
.auth-diff-num {
  font-weight: 600;
  color: var(--text);
}
.auth-diff-loc {
  font-family: var(--mono);
  font-size: 0.73rem;
  color: var(--text-2);
}
.auth-diff-pills {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.auth-diff-ok,
.auth-diff-no {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
}
.auth-diff-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.auth-diff-no {
  background: var(--bg-muted);
  color: var(--text-3);
}

.auth-diff-row {
  padding: 0.65rem 0.85rem;
  border-left: 2.5px solid transparent;
}
.auth-diff-row.is-before {
  background: var(--del-bg);
  border-left-color: var(--danger);
  border-bottom: 1px solid var(--line);
}
.auth-diff-row.is-after {
  background: var(--ins-bg);
  border-left-color: var(--ok);
}
.auth-diff-label {
  display: block;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.2rem;
}
.auth-diff-row p {
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.48;
  color: var(--text);
}
.auth-diff-row del {
  text-decoration-color: var(--del-ink);
  color: var(--del-ink);
}
.auth-diff-row ins {
  text-decoration: none;
  color: var(--ins-ink);
  font-weight: 600;
}

.auth-aside-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--text-2);
}
.auth-aside-list li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.auth-aside-list svg {
  color: var(--accent);
  flex: none;
}

.auth-card {
  width: 100%;
  max-width: 372px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.auth-card-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 0.4rem;
}

.auth-card-head h1 {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.16;
  letter-spacing: -0.02em;
  color: var(--text);
}
.auth-card-head p {
  color: var(--text-2);
  font-size: 0.9rem;
  line-height: 1.48;
  text-wrap: balance;
}

.auth-form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.auth-providers {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.oauth-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-provider-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  height: 42px;
  padding: 0 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 110ms ease, border-color 110ms ease;
}
.auth-provider-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--line-hover);
  text-decoration: none;
}
.auth-provider-btn:active {
  transform: none;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--text-3);
  font-size: 0.78rem;
  font-weight: 400;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-email-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}
.auth-field label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
}
.auth-field input {
  width: 100%;
  height: 42px;
  padding: 0 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.89rem;
  transition: border-color 110ms ease, box-shadow 110ms ease;
}
.auth-field input:hover {
  border-color: var(--line-hover);
}
.auth-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 42px;
  margin-top: 0.15rem;
  padding: 0 1.2rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
  font-family: var(--sans);
  font-size: 0.89rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 110ms ease, opacity 110ms ease;
}
.auth-submit-btn:hover {
  background: var(--primary-hover);
}
.auth-submit-btn:active {
  transform: none;
}

.otp-step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.8rem;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 0.83rem;
  color: var(--text-2);
}
.otp-step-head strong { color: var(--text); font-weight: 600; }
.otp-input {
  height: 46px !important;
  font-family: var(--mono);
  font-size: 1.35rem !important;
  font-weight: 600;
  letter-spacing: 0.38em;
  text-align: center;
  padding: 0 0.9rem !important;
}
.dev-code-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0.8rem;
  border-radius: 9px;
  background: var(--accent-soft);
  border: 1px dashed var(--accent-line);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.auth-footer-switch {
  text-align: center;
  font-size: 0.84rem;
  color: var(--text-2);
}
.link-btn {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--text);
  font-weight: 600;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-hover);
}
.link-btn:hover {
  background: transparent;
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* --- Cards & Generic Layout Utilities --- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
}

.nudge-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 7px 10px 7px 13px;
  margin-bottom: 14px;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-2);
}
.nudge-copy strong {
  color: var(--text);
  font-weight: 600;
}
.nudge-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: 0.6rem; }
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.25rem;
}

/* --- Generic Buttons & Inputs (Public, Pricing, Account, Dialogs) --- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r);
  padding: 0.5rem 0.95rem;
  font: 500 0.86rem/1.2 var(--sans);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
button:hover, .btn:hover { background: var(--bg-muted); border-color: var(--line-hover); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.primary, .btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}
button.primary:hover, .btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

button.ghost, .btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}
button.ghost:hover, .btn.ghost:hover {
  background: var(--bg-muted);
  color: var(--text);
}

button.danger, .btn.danger {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
  background: transparent;
}
button.danger:hover, .btn.danger:hover { background: var(--danger-soft); }

button.small, .btn.small { padding: 0.34rem 0.74rem; font-size: 0.8rem; }
button.full, .btn.full { width: 100%; padding: 0.62rem 1rem; }

.icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
}
.icon-btn:hover { color: var(--text); background: var(--bg-muted); }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}
.field:last-child { margin-bottom: 0; }
.row > .field { margin-bottom: 0; }
.fields-row { align-items: flex-end; margin-bottom: 0.85rem; }
.field label { font-size: 0.82rem; font-weight: 500; color: var(--text); }

input, select, textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 0.55rem 0.78rem;
  font: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select {
  min-height: 38px;
}
input:hover, select:hover, textarea:hover { border-color: var(--line-hover); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
  outline: none;
}
textarea { min-height: 88px; resize: vertical; }
input:user-invalid, textarea:user-invalid { border-color: var(--danger); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.16rem 0.56rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  background: var(--bg-muted);
  color: var(--text-2);
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.running, .badge.online, .badge.healthy, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.suspended, .badge.draining { background: var(--warn-soft); color: var(--warn); }
.badge.archived, .badge.offline { background: var(--bg-muted); color: var(--text-3); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { text-align: start; padding: 0.62rem 0.7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--text-3); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }
caption { text-align: start; color: var(--text-2); font-size: 0.82rem; padding-bottom: 0.6rem; }

/* Standard Native Modal Dialogs */
dialog:not(.np-dialog) {
  width: min(92vw, 440px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--raised);
  color: var(--text);
  padding: 1.35rem;
  box-shadow: var(--float);
}
dialog::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(2px);
}
dialog:not(.np-dialog) h2 {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* Review Portal (review.html) */
.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.pdf-frame {
  width: 100%;
  height: 78vh;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
}

/* Editorial Legal Pages (/terms, /privacy) */
.legal-page {
  padding-top: clamp(2rem, 5vw, 3.5rem);
  padding-bottom: 4rem;
}
.legal-article {
  max-width: 760px;
  margin: 0 auto;
}
.legal-hero {
  margin-bottom: 1.75rem;
}
.legal-eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.55rem;
}
.legal-hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 4.4vw, 3rem);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.65rem;
}
.legal-title-mark {
  background: linear-gradient(transparent 62%, var(--mark) 62%, var(--mark) 94%, transparent 94%);
  padding: 0 0.06em;
}
.legal-meta {
  font-size: 0.9rem;
  color: var(--text-2);
}
.legal-summary {
  border-radius: var(--r-xl);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
}
.legal-summary h2 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 400;
  margin-bottom: 0.7rem;
  color: var(--text);
}
.legal-summary ul {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.5rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-2);
}
.legal-summary li strong {
  color: var(--text);
  font-weight: 600;
}
.legal-summary code,
.legal-section code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 0.08rem 0.35rem;
  border-radius: 5px;
  background: var(--bg-muted);
  color: var(--text);
}
.legal-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 2rem;
  padding-bottom: 1.35rem;
  border-bottom: 1px solid var(--line);
}
.legal-toc a {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}
.legal-toc a:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--bg-hover);
}
.legal-body {
  display: grid;
  gap: 2rem;
}
.legal-section {
  scroll-margin-top: 84px;
}
.legal-section h2 {
  font-family: var(--serif);
  font-size: 1.38rem;
  font-weight: 400;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 0.65rem;
}
.legal-section p {
  font-size: 0.96rem;
  line-height: 1.72;
  color: var(--text-2);
  margin-bottom: 0.8rem;
}
.legal-section p:last-child,
.legal-section ul:last-child {
  margin-bottom: 0;
}
.legal-section strong {
  color: var(--text);
  font-weight: 600;
}
.legal-section ul {
  margin: 0.45rem 0 0.9rem;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.5rem;
  font-size: 0.95rem;
  line-height: 1.68;
  color: var(--text-2);
}
.legal-section a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.legal-section a:hover {
  color: var(--accent-hover);
}
.auth-legal-note {
  margin-top: 0.85rem;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-3);
}
.auth-legal-note a {
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-legal-note a:hover {
  color: var(--text);
}

/* Account Danger Zone */
.danger-card {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}
.danger-card .between {
  flex-wrap: wrap;
  gap: 0.9rem 1.25rem;
}
.danger-card .between > div {
  flex: 1 1 320px;
  min-width: 0;
}
.danger-card .between > button {
  flex-shrink: 0;
}
.danger-card h3 {
  color: var(--danger);
}
.danger-list {
  margin: 0.25rem 0 0.85rem;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-2);
}
.comment-item {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.8rem 0.9rem;
  background: var(--bg-subtle);
}
.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.swatch.yellow { background: #eab308; }
.swatch.green { background: var(--ok); }
.swatch.purple { background: var(--purple); }
.swatch.orange { background: var(--warn); }
.swatch.red { background: var(--danger); }

/* --- Responsive Breakpoints --- */
@media (max-width: 1100px) {
  .pricing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* Slide-over Mobile Sidebar Drawer <= 840px */
@media (max-width: 840px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .mobile-only {
    display: inline-flex;
  }
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(276px, 84vw);
    transform: translateX(-105%);
    visibility: hidden;
    pointer-events: none;
    box-shadow: var(--float);
  }
  .app-sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform 180ms ease;
  }
  .ws-topbar {
    padding: 0 14px;
  }
  .ws-scroll-area {
    padding: 16px 14px 44px;
  }
  .auth-stage {
    min-height: calc(100dvh - 88px);
    padding: 1.25rem 0 2.5rem;
  }
  .auth-split {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .auth-aside {
    display: none;
  }
  .auth-card-head {
    align-items: center;
    text-align: center;
  }
  .review-layout { grid-template-columns: 1fr; }
  .pdf-frame { height: 55vh; }
}

@media (max-width: 680px) {
  nav.primary-nav {
    display: none;
  }
  .topbar-actions {
    margin-left: auto;
  }
  .host-account-popover,
  .context-popover {
    position: fixed;
    inset: auto 8px max(8px, env(safe-area-inset-bottom)) 8px;
    width: auto;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 8px;
    position-area: none;
    box-shadow: var(--float);
  }
  .host-account-popover::backdrop,
  .context-popover::backdrop {
    background: var(--scrim);
  }
  .host-account-menu > button,
  .context-popover > button {
    min-height: 44px;
    font-size: 14px;
    padding: 6px 12px;
    gap: 10px;
    border-radius: 8px;
  }
  .pricing-grid { grid-template-columns: 1fr; }
  .ws-topbar-count { display: none; }
}

@media (max-width: 560px) {
  main.container { padding: 1rem 0.9rem 2.5rem; }
  .topbar-inner { padding: 0.6rem 0.9rem; }
  .projects-card-grid { grid-template-columns: 1fr; }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .template-contribute > span { display: none; }
  #open-import-ws > span { display: none; }
}

/* Reduced Motion Respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
