/* ============================================================
   Draw Docco design system — clean, professional, blue + grey
   ============================================================ */

:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* Palette */
  --blue-900: #0f2a5c;
  --blue-800: #143a80;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50: #eff6ff;

  --grey-900: #16202b;
  --grey-700: #3b4a5a;
  --grey-500: #64748b;
  --grey-300: #cbd5e1;
  --grey-200: #e2e8f0;
  --grey-100: #f1f5f9;
  --grey-50: #f8fafc;

  /* Semantic tokens */
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-alt: var(--grey-50);
  --ink: var(--grey-900);
  --muted: var(--grey-500);
  --accent: var(--blue-600);
  --accent-strong: var(--blue-700);
  --accent-soft: var(--blue-50);
  --border: var(--grey-200);
  --border-strong: var(--grey-300);
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --success: #067647;
  --success-soft: #ecfdf3;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(22, 32, 43, 0.06);
  --shadow: 0 4px 16px rgba(22, 32, 43, 0.08);
  --shadow-lg: 0 12px 32px rgba(22, 32, 43, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}

/* ------------------------------------------------------------
   Buttons & form controls
   ------------------------------------------------------------ */

button,
.primary-button,
.ghost-button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease,
    box-shadow 120ms ease;
  white-space: nowrap;
}

button.primary,
.primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

button.primary:hover,
.primary-button:hover {
  background: var(--accent-strong);
}

button.ghost,
.ghost-button {
  background: var(--surface);
  color: var(--grey-700);
  border: 1px solid var(--border);
}

button.ghost:hover,
.ghost-button:hover {
  border-color: var(--border-strong);
  background: var(--grey-50);
  color: var(--ink);
}

button.subtle {
  background: transparent;
  color: var(--muted);
  padding: 7px 10px;
}

button.subtle:hover {
  background: var(--grey-100);
  color: var(--ink);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
}

button.danger:hover {
  background: var(--danger-soft);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--grey-700);
}

.field input,
.field textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}

.field textarea {
  resize: vertical;
  min-height: 72px;
}

/* ------------------------------------------------------------
   Shared top bar / brand
   ------------------------------------------------------------ */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: block;
  flex-shrink: 0;
}

.brand-name {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.status-chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--blue-100);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-chip.warn {
  background: #fffaeb;
  border-color: #fedf89;
  color: #b54708;
}

/* ------------------------------------------------------------
   Document versioning
   ------------------------------------------------------------ */

.readonly-banner {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
  font-size: 13px;
}

body.readonly .readonly-banner {
  display: flex;
}

body.readonly .palette-rail,
body.readonly .canvas-toolbar,
body.readonly #save-document,
body.readonly #preview-pdf,
body.readonly #export-docx {
  display: none;
}

/* With the palette rail gone, its grid column would otherwise get
   auto-reflowed into by whichever element comes next (the diagram
   canvas), squashing it into the palette's old 216px track while the
   document panel balloons into the middle 1fr track. Re-declare the
   grid explicitly instead of relying on reflow: diagram gets the
   lion's share, the document panel keeps a readable minimum width. */
body.readonly .editor-body {
  grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr);
}

body.readonly .canvas-wrap {
  grid-column: 1;
}

body.readonly .doc-rail {
  grid-column: 2;
}

.version-create-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.version-create-row input {
  flex: 1;
}

/* ------------------------------------------------------------
   Landing page (index.html)
   ------------------------------------------------------------ */

body.auth-page {
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 480px);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  width: min(1160px, 94vw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
}

.brand-lg .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
}

.brand-lg .brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-mark.sm {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.brand-name.sm {
  font-size: 14px;
}

.site-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.primary-button.lg,
.ghost-button.lg {
  padding: 12px 24px;
  font-size: 15px;
  border-radius: var(--radius);
}

/* Hero */

.hero {
  padding: 72px 0 48px;
}

.hero-inner {
  width: min(1160px, 94vw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 64px;
  align-items: center;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(36px, 4.2vw, 52px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.12;
  color: var(--grey-900);
}

.hero-copy h1 em {
  font-style: normal;
  color: var(--accent);
}

.landing-lead {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
  max-width: 50ch;
}

.hero-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.badge {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--grey-700);
  font-size: 12.5px;
  font-weight: 500;
}

/* Hero product preview */

.hero-preview {
  position: relative;
  width: min(1160px, 94vw);
  margin: 40px auto 0;
  padding-bottom: 8px;
}

.hero-preview::before {
  content: "";
  position: absolute;
  inset: 10% 6% -4% 6%;
  background: radial-gradient(ellipse at center, rgba(37, 99, 235, 0.16), transparent 70%);
  z-index: 0;
  pointer-events: none;
}

.preview-frame {
  position: relative;
  z-index: 1;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 24px 64px rgba(15, 42, 92, 0.16), 0 2px 8px rgba(15, 42, 92, 0.06);
}

.preview-frame svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: inherit;
}

/* Page sections */

.section {
  padding: 88px 0;
}

.section-alt {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-inner {
  width: min(1160px, 94vw);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.section-head {
  max-width: 60ch;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-lead {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

#features,
#pricing {
  scroll-margin-top: 84px;
}

/* How-it-works steps */

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.step-card:hover {
  border-color: var(--blue-500);
  box-shadow: var(--shadow);
}

.step-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.step-num {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.step-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: grid;
  place-items: center;
}

.step-icon svg {
  width: 22px;
  height: 22px;
}

.step-card h3 {
  margin: 0;
  font-size: 18px;
}

.step-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.6;
}

/* Footer */

.site-footer {
  padding: 28px 0 40px;
}

.site-footer-inner {
  width: min(1160px, 94vw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Auth card */

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-intro {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-intro h3 {
  margin: 0;
  font-size: 20px;
}

.auth-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.plan-summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--blue-100);
  background: var(--accent-soft);
  font-size: 12px;
  color: var(--grey-700);
  width: fit-content;
}

.plan-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}

.plan-value {
  font-weight: 700;
  color: var(--accent-strong);
}

.plan-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.plan-link:hover {
  text-decoration: underline;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--grey-100);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.auth-tabs button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
}

.auth-tabs button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-message {
  min-height: 20px;
  font-size: 13px;
  color: var(--muted);
}

/* Pricing */

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.pricing-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pricing-card.featured {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 1px var(--blue-500), var(--shadow);
}

.pricing-flag {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.pricing-card h3 {
  margin: 0;
  font-size: 18px;
}

.pricing-price {
  margin: 6px 0;
  font-size: 30px;
  font-weight: 700;
  color: var(--grey-900);
}

.pricing-price span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.pricing-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.pricing-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--grey-700);
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.pricing-card .primary-button {
  margin-top: auto;
}

/* ------------------------------------------------------------
   App chrome (dashboard + editor top bar)
   ------------------------------------------------------------ */

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.appbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.appbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}

/* ------------------------------------------------------------
   Documents dashboard
   ------------------------------------------------------------ */

.dashboard {
  width: min(1160px, 94vw);
  margin: 0 auto;
  padding: 32px 0 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dashboard-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.dashboard-heading h2 {
  margin: 0;
  font-size: 24px;
}

.dashboard-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
  cursor: pointer;
}

.doc-card:hover {
  border-color: var(--blue-500);
  box-shadow: var(--shadow);
}

.doc-card h3 {
  margin: 0;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-card-meta {
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  gap: 12px;
}

.doc-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: auto;
  border-top: 1px solid var(--grey-100);
  padding-top: 10px;
}

.doc-card.new-doc {
  border-style: dashed;
  border-color: var(--border-strong);
  align-items: center;
  justify-content: center;
  color: var(--muted);
  min-height: 140px;
  font-weight: 600;
  background: transparent;
  box-shadow: none;
}

.doc-card.new-doc:hover {
  border-color: var(--blue-500);
  color: var(--accent);
  background: var(--accent-soft);
}

.empty-state {
  text-align: center;
  padding: 72px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-state h3 {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  max-width: 44ch;
}

.empty-state .primary {
  margin-top: 16px;
}

.empty-art {
  width: 180px;
  height: auto;
  color: var(--grey-300);
}

.empty-art .accent {
  color: var(--blue-500);
}

.notice {
  border-radius: var(--radius);
  border: 1px solid #fedf89;
  background: #fffaeb;
  color: #b54708;
  padding: 12px 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------
   Admin portal
   ------------------------------------------------------------ */

.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 720px;
}

.admin-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  white-space: nowrap;
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--grey-100);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: var(--grey-50);
}

.admin-user {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-user-email {
  font-weight: 600;
}

.admin-user-name {
  font-size: 12px;
}

.admin-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12.5px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.admin-select:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}

.admin-status-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: capitalize;
}

.status-badge.ok {
  background: var(--success-soft);
  color: var(--success);
}

.status-badge.warn {
  background: #fffaeb;
  color: #b54708;
}

.status-badge.off {
  background: var(--grey-100);
  color: var(--muted);
}

/* ------------------------------------------------------------
   Editor layout
   ------------------------------------------------------------ */

body.editor-page {
  overflow: hidden;
}

.editor-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.doc-title-input {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  padding: 6px 10px;
  min-width: 120px;
  width: 320px;
  max-width: 40vw;
}

.doc-title-input:hover {
  background: var(--grey-100);
}

.doc-title-input:focus {
  outline: none;
  border-color: var(--blue-500);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--blue-100);
}

.save-state {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 200ms ease;
}

.save-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  transition: background-color 200ms ease;
}

.save-state.dirty {
  color: #b54708;
}

.save-state.dirty::before {
  background: #f79009;
}

.editor-body {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr) 320px;
  flex: 1;
  min-height: 0;
}

/* Left rail: shape palette */

.palette-rail {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rail-title {
  margin: 0;
  padding: 14px 16px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

#palette {
  flex: 1;
  min-height: 0;
  border: none;
}

/* Re-theme the Syncfusion palette accordion to match the app */

.palette-rail .e-accordion {
  border: none;
  background: transparent;
}

.palette-rail .e-accordion .e-acrdn-item .e-acrdn-header .e-acrdn-header-content {
  color: var(--grey-700);
  font-weight: 600;
  font-size: 12px;
  font-family: inherit;
}

.palette-rail .e-accordion .e-acrdn-item.e-select.e-active > .e-acrdn-header .e-acrdn-header-content,
.palette-rail .e-accordion .e-acrdn-item.e-select.e-item-focus > .e-acrdn-header .e-acrdn-header-content {
  color: var(--accent-strong);
}

.palette-rail .e-accordion .e-acrdn-item .e-acrdn-header:hover {
  background: var(--grey-50);
}

.palette-rail .e-symbolpalette .e-symbol-hover {
  background: var(--accent-soft);
}

.palette-rail .e-symbolpalette .e-symbol-draggable {
  border-radius: var(--radius-sm);
  transition: background-color 120ms ease;
}

.palette-rail .e-symbolpalette .e-symbol-draggable:hover {
  background: var(--accent-soft);
}

.palette-rail .e-symbolpalette .e-symbol-description {
  font-family: inherit;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* Diagram context menu theming */

.e-contextmenu-wrapper ul,
.e-contextmenu-container ul {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif !important;
  font-size: 13px !important;
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 4px !important;
  min-width: 160px;
}

.e-contextmenu-wrapper ul .e-menu-item,
.e-contextmenu-container ul .e-menu-item {
  border-radius: var(--radius-sm);
  height: 34px;
  line-height: 34px;
  color: var(--ink);
}

.e-contextmenu-wrapper ul .e-menu-item.e-focused,
.e-contextmenu-container ul .e-menu-item.e-focused {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.e-contextmenu-wrapper ul .e-menu-item.e-separator,
.e-contextmenu-container ul .e-menu-item.e-separator {
  margin: 4px 6px;
  border-bottom-color: var(--border);
}

.e-contextmenu-wrapper ul .e-menu-item#cm-delete,
.e-contextmenu-container ul .e-menu-item#cm-delete {
  color: var(--danger);
  /* Visual separator ahead of the destructive action — the item-level
     `separator` property isn't reliable across Diagram versions, so this
     is done in CSS instead. */
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 4px;
}

.e-contextmenu-wrapper ul .e-menu-item#cm-delete.e-focused,
.e-contextmenu-container ul .e-menu-item#cm-delete.e-focused {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Rich text editor theming */

.modal-card.rte {
  width: min(680px, 94vw);
}

.e-richtexteditor {
  border-radius: var(--radius-sm) !important;
  border-color: var(--border) !important;
  font-family: inherit !important;
}

.e-richtexteditor .e-rte-content .e-content {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}

.e-richtexteditor .e-toolbar {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
  background: var(--grey-50) !important;
}

.palette-hint {
  padding: 10px 16px 14px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--grey-100);
  margin: 0;
}

/* Canvas */

.canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--grey-100);
}

#diagram {
  width: 100%;
  height: 100%;
}

.canvas-toolbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 10;
}

.canvas-toolbar button {
  background: transparent;
  color: var(--grey-700);
  padding: 7px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.canvas-toolbar button:hover {
  background: var(--grey-100);
  color: var(--ink);
}

.canvas-toolbar .tb-divider {
  width: 1px;
  align-self: stretch;
  margin: 4px 4px;
  background: var(--border);
}

/* JointJS diagram surface */

#diagram {
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: default;
}

#diagram .joint-element {
  cursor: move;
}

#diagram.panning,
#diagram.panning .joint-element {
  cursor: grabbing !important;
}

#diagram .joint-cell.is-selected [joint-selector="body"] {
  stroke: var(--blue-600) !important;
  stroke-width: 2.6 !important;
}

#diagram .joint-cell.is-selected [joint-selector="line"] {
  stroke: var(--blue-600) !important;
  stroke-width: 2.4 !important;
}

.joint-port circle {
  transition: opacity 120ms ease;
}

/* Shape palette tiles (left rail) */

#palette {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 12px;
}

.palette-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  color: var(--grey-700);
  transition: border-color 120ms ease, background-color 120ms ease;
}

.palette-tile:hover {
  border-color: var(--blue-500);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.palette-tile svg {
  width: 48px;
  height: 40px;
}

/* Diagram context menu */

.diagram-context-menu {
  position: fixed;
  z-index: 60;
  min-width: 150px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  display: flex;
  flex-direction: column;
}

.diagram-context-menu button {
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.diagram-context-menu button:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.diagram-context-menu button.danger {
  color: var(--danger);
}

.diagram-context-menu button.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Boundary box overlays: plain HTML, layered on top of the canvas rather
   than part of the JointJS SVG tree — see screenRectForCell in app.ts. */

.boundary-resize-handle {
  position: absolute;
  display: none;
  width: 14px;
  height: 14px;
  background: var(--surface);
  border: 1.5px solid var(--blue-600);
  border-radius: 3px;
  cursor: nwse-resize;
  z-index: 15;
}

.boundary-rename-input {
  position: absolute;
  display: none;
  z-index: 16;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--grey-700);
  background: var(--surface);
  border: 1px solid var(--blue-500);
  border-radius: 4px;
  padding: 3px 6px;
  box-shadow: 0 0 0 3px var(--blue-100);
}

/* Zoom control */

.zoom-control {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 10;
}

.zoom-control button {
  background: transparent;
  color: var(--grey-700);
  padding: 6px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  min-width: 34px;
}

.zoom-control button:hover {
  background: var(--grey-100);
  color: var(--ink);
}

#zoom-level {
  min-width: 52px;
  font-variant-numeric: tabular-nums;
}

/* Blue selection handles (replace the default Material pink) */

#diagram .e-diagram-resize-handle {
  fill: #ffffff;
  stroke: var(--blue-600);
}

#diagram .e-diagram-border {
  stroke: var(--blue-600);
}

#diagram .e-diagram-rotate-handle {
  fill: var(--blue-600);
  stroke: #ffffff;
}

#diagram .e-diagram-pivot-line {
  stroke: var(--blue-600);
}

#diagram .e-diagram-endpoint-handle {
  fill: #ffffff;
  stroke: var(--blue-600);
}

#diagram .e-diagram-endpoint-handle.e-connected {
  fill: var(--blue-600);
}

/* Right rail: document panel */

.doc-rail {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.doc-rail section {
  padding: 16px;
  border-bottom: 1px solid var(--grey-100);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-rail h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.section-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  font-weight: 400;
  white-space: normal;
}

.section-card:hover {
  border-color: var(--blue-500);
  box-shadow: var(--shadow-sm);
}

.section-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.section-card-preview {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.section-card-preview.empty {
  font-style: italic;
}

.outline {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.outline-item {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  align-items: baseline;
}

.outline-item:hover {
  background: var(--grey-100);
}

.outline-item .num {
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  min-width: 16px;
}

.outline-item .label {
  font-weight: 600;
  color: var(--ink);
}

.outline-item .req {
  color: var(--muted);
  display: block;
  font-size: 12.5px;
  margin-top: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.outline-item.pending .req {
  font-style: italic;
}

/* ------------------------------------------------------------
   Modals
   ------------------------------------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(22, 32, 43, 0.45);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  z-index: 50;
  padding: 20px;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(560px, 94vw);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card.wide {
  width: min(720px, 94vw);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.modal-header h3 {
  margin: 2px 0 0;
  font-size: 18px;
}

.modal-lead {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-footnote {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

/* Plan options inside the subscription modal */

.plan-options {
  display: grid;
  gap: 10px;
}

.plan-option {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.plan-option:hover {
  border-color: var(--blue-500);
}

.plan-option.selected {
  border-color: var(--blue-600);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--blue-600);
}

.plan-option input {
  margin-top: 4px;
  accent-color: var(--accent);
}

.plan-option-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.plan-option-name {
  font-weight: 700;
}

.plan-option-price {
  font-weight: 700;
}

.plan-option-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

/* ------------------------------------------------------------
   Motion
   ------------------------------------------------------------ */

@media (prefers-reduced-motion: no-preference) {
  /* Scroll-reveal: elements start hidden, .in-view (added by a tiny
     IntersectionObserver script) fades them up. Stagger via --reveal-delay. */
  .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 600ms ease, transform 600ms cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--reveal-delay, 0ms);
  }

  .reveal.in-view {
    opacity: 1;
    transform: translateY(0);
  }

  /* Hero preview: the selected node and its outline entry pulse in sync,
     hinting that the diagram and the document are the same thing. */
  .pv-node-box {
    animation: pv-node-pulse 2.6s ease-in-out infinite;
  }

  .pv-hl {
    animation: pv-outline-pulse 2.6s ease-in-out infinite;
  }

  /* Dashboard cards drop in on load. */
  .doc-card {
    animation: card-in 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .doc-card:nth-child(2) { animation-delay: 50ms; }
  .doc-card:nth-child(3) { animation-delay: 100ms; }
  .doc-card:nth-child(4) { animation-delay: 150ms; }
  .doc-card:nth-child(5) { animation-delay: 200ms; }
  .doc-card:nth-child(6) { animation-delay: 250ms; }
  .doc-card:nth-child(n + 7) { animation-delay: 300ms; }

  /* Modals scale in gently. */
  .modal .modal-card {
    transform: translateY(10px) scale(0.98);
    transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .modal.active .modal-card {
    transform: translateY(0) scale(1);
  }

  /* Editor rails ease in on load. */
  .palette-rail,
  .doc-rail {
    animation: rail-in 360ms ease-out both;
  }
}

@keyframes pv-node-pulse {
  0%, 100% { stroke: #2563eb; }
  50% { stroke: #93c5fd; }
}

@keyframes pv-outline-pulse {
  0%, 100% { fill: #eff6ff; }
  50% { fill: #dbeafe; }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rail-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

button:active,
.primary-button:active,
.ghost-button:active {
  transform: translateY(1px);
}

/* ------------------------------------------------------------
   Skeleton loading (dashboard)
   ------------------------------------------------------------ */

.skeleton-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 140px;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--grey-100) 25%, var(--grey-200) 50%, var(--grey-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w80 { width: 80%; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-line { animation: none; }
}

/* ------------------------------------------------------------
   Toasts
   ------------------------------------------------------------ */

.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
}

.toast {
  background: var(--grey-900);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 200ms ease-out;
  max-width: 360px;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */

@media (max-width: 1100px) {
  .editor-body {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .doc-rail {
    display: none;
  }

  .hero {
    padding: 40px 0 24px;
  }

  .hero-inner {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .section {
    padding: 56px 0;
  }
}

@media (max-width: 760px) {
  .editor-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .palette-rail {
    display: none;
  }

  .site-header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .site-nav {
    width: 100%;
  }

  .appbar {
    flex-wrap: wrap;
  }
}
