:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #141820;
  --muted: #626b7a;
  --line: #d9deea;
  --accent: #1f5eff;
  --accent-dark: #1645bd;
  --soft: #eef3ff;
  --warn-bg: #fff6dc;
  --warn-line: #e7bd4b;
  --danger: #b33a3a;
  --shadow: 0 18px 45px rgba(31, 44, 71, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #ffffff 0, var(--bg) 46%, #edf2ff 100%);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(31, 94, 255, 0.22);
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
}

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

button.secondary {
  background: #f2f5fb;
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--line);
}

button.secondary:hover:not(:disabled) {
  background: #e8eef9;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  padding: 11px 18px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(31, 94, 255, 0.22);
}

.link-button:hover {
  background: var(--accent-dark);
}

.link-button.secondary {
  background: #f2f5fb;
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--line);
}

.link-button.secondary:hover {
  background: #e8eef9;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(28px, 4vw, 48px);
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

.status-pill {
  white-space: nowrap;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid #d7e2ff;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.status-pill.error {
  color: var(--danger);
  background: #fff0f0;
  border-color: #ffd4d4;
}

/* ===== Full-screen generator layout ===== */
.generator-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 12px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.topbar-brand h1 {
  margin: 0;
  font-size: clamp(18px, 2vw, 24px);
  letter-spacing: -0.03em;
}

.topbar-brand .eyebrow {
  margin-bottom: 2px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid var(--line);
}

.topbar-actions select {
  width: auto;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(217, 222, 234, 0.85);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 16px;
  min-height: 0;
  padding: 16px clamp(16px, 3vw, 32px);
}

.input-panel,
.result-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.input-panel textarea {
  flex: 1;
  min-height: 0;
}

.result-panel .diagram-scroll {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.panel-title-row p {
  color: var(--muted);
  margin-bottom: 0;
}

textarea {
  width: 100%;
  min-height: 440px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  color: #10141d;
  background: #fbfcff;
  font-family: Consolas, Monaco, Menlo, monospace;
  line-height: 1.45;
  tab-size: 4;
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 94, 255, 0.12);
}

.action-row,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.action-row {
  margin-top: 14px;
}

.compact button {
  padding: 9px 12px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

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

label {
  display: grid;
  gap: 6px;
  color: #313846;
  font-size: 13px;
  font-weight: 700;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  background: #fbfcff;
  color: var(--text);
  outline: none;
}

input[type="range"] {
  width: 150px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  font-weight: 700;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 12px;
}

.tab-button {
  border: 1px solid var(--line);
  background: #f6f8fd;
  color: var(--text);
  box-shadow: none;
  padding: 9px 12px;
  border-radius: 999px;
  font-size: 14px;
}

.tab-button.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.diagram-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: repeating-linear-gradient(0deg, #ffffff, #ffffff 23px, #f8faff 24px), repeating-linear-gradient(90deg, #ffffff, #ffffff 23px, #f8faff 24px);
  min-height: 520px;
  max-height: 78vh;
}

.diagram-canvas {
  min-width: 100%;
  min-height: 520px;
  padding: 18px;
  transform-origin: top left;
}

.diagram-canvas svg {
  display: block;
  max-width: none;
}

.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .generator-page {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .input-panel textarea {
    min-height: 320px;
  }

  .result-panel .diagram-scroll {
    min-height: 420px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

/* The editor's final geometry lives in the "Full-screen overlay editor layout"
   section below — the old grid-era duplicates that this file accumulated were
   fully overridden there and have been merged away. */

.palette-item:hover {
  background: var(--soft);
}

.palette-terminator {
  border-radius: 999px;
}

.palette-decision {
  transform: rotate(45deg) scale(0.75);
}

.palette-for {
  clip-path: polygon(14% 0, 86% 0, 100% 50%, 86% 100%, 14% 100%, 0 50%);
}

.palette-io {
  transform: skewX(-18deg);
}

.palette-arrow {
  border: none;
  background: center / 30px 14px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 14'%3E%3Cline x1='1' y1='7' x2='23' y2='7' stroke='%23111' stroke-width='2'/%3E%3Cpath d='M21 2 L29 7 L21 12 Z' fill='%23111'/%3E%3C/svg%3E");
}

.palette-label {
  border: none;
  background: center / 30px 20px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 20'%3E%3Ctext x='15' y='15' text-anchor='middle' font-family='Arial, sans-serif' font-size='15' font-weight='700' fill='%23111'%3ET%3C/text%3E%3C/svg%3E");
}

.editor-edge-tail-handle {
  fill: #fff;
}


.editor-node {
  cursor: grab;
}

.editor-node:active {
  cursor: grabbing;
}

.editor-canvas:focus {
  box-shadow: inset 0 0 0 2px rgba(31, 94, 255, 0.10);
}

.editor-canvas.edge-drafting {
  cursor: crosshair;
}

.editor-canvas.node-drafting {
  cursor: copy;
}

.editor-canvas.node-drafting .editor-node,
.editor-canvas.node-drafting .editor-edge,
.editor-canvas.node-drafting .editor-edge-create-handle {
  pointer-events: none;
}

.editor-node-draft {
  opacity: 0.58;
  pointer-events: none;
}

.editor-node-draft .editor-node-shape {
  stroke: var(--accent);
  stroke-dasharray: 7 5;
  stroke-width: 2.2;
  fill: rgba(255, 255, 255, 0.82);
}

.editor-edge-create-handle {
  cursor: pointer;
}

.editor-edge-create-handle rect {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 2;
  filter: drop-shadow(0 5px 10px rgba(31, 94, 255, 0.22));
}

.editor-edge-create-handle path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.editor-edge-create-handle:hover rect {
  fill: var(--soft);
}

/* Corner resize handles on the selected block */
.editor-resize-handle rect {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 2;
}

.editor-resize-handle:hover rect {
  fill: var(--accent);
}

/* In-place text editing inside a block / on an edge label (fixed HTML overlay) */
.editor-text-edit {
  position: fixed;
  z-index: 1000;
  box-sizing: border-box;
  min-height: 0;
  max-height: none;
  border: 1.6px solid var(--accent);
  border-radius: 6px;
  background: #ffffff;
  color: #111;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.2;
  text-align: center;
  padding: 2px 4px;
  resize: none;
  outline: none;
  box-shadow: 0 4px 14px rgba(31, 94, 255, 0.22);
}

/* Left-click block type submenu (replaces the inspector type selector) */
.editor-type-menu {
  position: fixed;
  z-index: 1000;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 150px;
  max-height: 70vh;
  overflow: auto;
}

.editor-type-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  color: #1f2937;
  cursor: pointer;
  text-align: left;
}

.editor-type-menu-item:hover {
  background: var(--soft);
}

.editor-type-menu-item.active {
  background: var(--soft);
  font-weight: 600;
}

.editor-type-menu-item .palette-icon {
  width: 24px;
  height: 18px;
  flex: 0 0 auto;
}

.editor-edge-draft {
  pointer-events: none;
}

.editor-edge-draft polyline {
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-dasharray: 7 5;
}

.editor-edge-draft circle {
  fill: var(--accent);
}

.editor-edge-draft-snap {
  fill: #fff !important;
  stroke: var(--accent);
  stroke-width: 2.2;
}

.editor-node-shape {
  fill: #fff;
  stroke: #111;
  stroke-width: 1.8;
}

.editor-node.selected .editor-node-shape {
  stroke: var(--accent);
  stroke-width: 3;
  filter: drop-shadow(0 4px 8px rgba(31, 94, 255, 0.18));
}

/* Text label: invisible box normally, a dashed outline when selected. */
.editor-label-shape {
  fill: transparent;
  stroke: none;
}

.editor-node.selected .editor-label-shape {
  fill: transparent;
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-dasharray: 4 3;
  filter: none;
}

.editor-predefined-line {
  stroke: #111;
  stroke-width: 1.8;
}

.editor-node-text {
  fill: #111;
  font-family: Arial, Helvetica, sans-serif;
  pointer-events: none;
  user-select: none;
}

.editor-edge polyline {
  stroke: #111;
  stroke-width: 1.8;
  cursor: pointer;
}

.editor-edge-hit-body {
  stroke: transparent;
  stroke-width: 16;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  pointer-events: stroke;
  cursor: move;
}

.editor-edge-mid-handle {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 2;
  opacity: 0;
  pointer-events: all;
}

.editor-edge:hover .editor-edge-mid-handle,
.editor-edge.selected .editor-edge-mid-handle {
  opacity: 1;
}

.editor-edge-mid-handle.horizontal {
  cursor: ns-resize;
}

.editor-edge-mid-handle.vertical {
  cursor: ew-resize;
}

.editor-edge-mid-handle.free {
  cursor: move;
}

.editor-edge-head-handle {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 2;
  cursor: grab;
  opacity: 0;
  pointer-events: all;
}

.editor-edge:hover .editor-edge-head-handle,
.editor-edge.selected .editor-edge-head-handle {
  opacity: 1;
}

.editor-edge-head-handle:active {
  cursor: grabbing;
}

.editor-edge.selected polyline {
  stroke: var(--accent);
  stroke-width: 3;
}

.editor-edge-label-bg {
  fill: #fff;
  opacity: 0.9;
  pointer-events: none;
}

.editor-edge-label {
  fill: #111;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  pointer-events: none;
}

.editor-page-fallback {
  max-width: 760px;
  margin: 64px auto;
}

/* Full-screen overlay editor layout */
html,
body {
  height: 100%;
}

.standalone-editor-page {
  min-height: 100vh;
  overflow: hidden;
}

.standalone-editor-shell {
  display: block;
  width: 100vw;
  height: 100vh;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.editor-shell {
  margin-top: 12px;
}

.editor-card {
  position: relative;
  min-height: calc(100vh - 24px);
  padding: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(217, 222, 234, 0.95);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.standalone-editor-shell .editor-card {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.editor-body,
.standalone-editor-shell .editor-body {
  position: absolute;
  inset: 0;
  display: block;
  min-height: 0;
}

.editor-workspace-wrap,
.standalone-editor-shell .editor-workspace-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  min-height: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: #ffffff;
}

.editor-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  cursor: grab;
  outline: none;
  touch-action: none;
}

.editor-canvas.is-panning {
  cursor: grabbing;
}

.editor-canvas-bg {
  pointer-events: all;
}

.editor-grid-line {
  stroke: #edf1f8;
  stroke-width: 1;
}

.editor-header {
  position: absolute;
  top: 12px;
  left: 172px;
  right: 268px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 7px 8px;
  border: 1px solid rgba(217, 222, 234, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(31, 44, 71, 0.12);
  backdrop-filter: blur(12px);
}

.editor-header .eyebrow,
.editor-header h2 {
  display: none;
}

.editor-header #editorSubtitle {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer; /* click renames the diagram */
}

/* Inline rename input shown in place of the subtitle */
.editor-name-input {
  min-width: 180px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 12px;
  outline: none;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  flex: 0 0 auto;
  gap: 6px;
}

.editor-toolbar button {
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.1;
}

.editor-zoom {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #313846;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.editor-zoom input {
  width: 86px;
}

.editor-palette {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  width: 148px;
  max-height: calc(100vh - 24px);
  padding: 8px;
  overflow: auto;
  border: 1px solid rgba(217, 222, 234, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 12px 30px rgba(31, 44, 71, 0.12);
  backdrop-filter: blur(12px);
}

.editor-palette h3 {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1.15;
}

.editor-palette .muted {
  display: none;
}

.palette-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
}

.palette-item {
  display: grid;
  justify-items: center;
  align-items: center;
  gap: 3px;
  width: 100%;
  min-height: 50px;
  padding: 5px 3px;
  text-align: center;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: none;
}

.palette-title {
  color: #313846;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.palette-icon {
  display: block;
  width: 27px;
  height: 19px;
  border: 1.5px solid #111;
  background: #fff;
}

.palette-page_connector {
  border-radius: 50%;
  width: 22px;
  height: 22px;
}

.palette-predefined {
  background:
    linear-gradient(to right, transparent 5px, #111 5px, #111 6.5px, transparent 6.5px),
    linear-gradient(to left, transparent 5px, #111 5px, #111 6.5px, transparent 6.5px),
    #fff;
}

@media (max-width: 980px) {
  .standalone-editor-page {
    overflow: auto;
  }

  .standalone-editor-shell {
    min-width: 760px;
    min-height: 620px;
  }

  .editor-card,
  .standalone-editor-shell .editor-card {
    min-width: 760px;
  }

  .editor-header {
    left: 12px;
    right: 12px;
    top: 12px;
  }

  .editor-palette {
    top: 66px;
  }
}

.editor-canvas.is-selecting {
  cursor: crosshair;
}

.editor-selection-box-layer {
  pointer-events: none;
}

.editor-selection-box {
  fill: rgba(31, 94, 255, 0.09);
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-dasharray: 8 5;
}

.editor-edge.selected .editor-edge-label-bg {
  stroke: var(--accent);
  stroke-width: 1.4;
  opacity: 1;
}

.editor-history-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  border: 1px solid rgba(217, 222, 234, 0.8);
  border-radius: 12px;
  background: rgba(248, 250, 255, 0.86);
}

.editor-toolbar .editor-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  padding: 0;
}

.editor-icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.editor-icon-button:disabled {
  cursor: default;
  opacity: 0.42;
}

/* ===== About modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 24, 32, 0.45);
  backdrop-filter: blur(3px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--panel);
  border-radius: 22px;
  box-shadow: 0 30px 70px rgba(20, 28, 48, 0.35);
  padding: 26px;
}

.modal-card h2 {
  margin-bottom: 12px;
  font-size: 22px;
}

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

.settings-modal-card {
  width: min(680px, 100%);
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--soft);
  border: 1px solid #c3d2f5;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  user-select: none;
  flex: 0 0 auto;
}

.info:hover {
  background: #dbe6ff;
}

.info-tooltip {
  position: fixed;
  z-index: 200;
  max-width: 280px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(20, 28, 48, 0.96);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 12px 30px rgba(20, 28, 48, 0.3);
  pointer-events: none;
}

.info-tooltip[hidden] {
  display: none;
}

/* Grouped settings sections */
.settings-group {
  margin-top: 6px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.settings-group:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.settings-group > summary {
  cursor: pointer;
  list-style: none;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.settings-group > summary::-webkit-details-marker {
  display: none;
}

.settings-group > summary::before {
  content: '▸ ';
}

.settings-group[open] > summary::before {
  content: '▾ ';
}

.settings-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.size-table {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 9px 10px;
  align-items: center;
}

.size-table input[type="number"] {
  width: 100%;
}

.size-col {
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.size-rowlabel {
  font-size: 13px;
  font-weight: 700;
  color: #313846;
}

/* ===== Toast notification ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 120;
  transform: translateX(-50%) translateY(12px);
  max-width: min(640px, calc(100vw - 32px));
  padding: 12px 20px;
  border-radius: 14px;
  background: rgba(20, 28, 48, 0.92);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  /* Multi-line messages (e.g. the warnings toast) keep their line breaks. */
  white-space: pre-line;
  box-shadow: 0 16px 40px rgba(20, 28, 48, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast[hidden] {
  display: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

/* Result panel: only switchers + the viewer, nothing else */
.result-panel .tabs {
  margin: 0 0 10px;
}

.result-panel .tabs:empty {
  display: none;
}

/* ===== Scrollable function tabs (many functions) ===== */
.tabs.scrollable {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.tabs.scrollable .tab-button {
  flex: 0 0 auto;
}

/* ===== Home button (generator topbar + editor) ===== */
.home-btn {
  font-size: 13px;
  padding: 8px 14px;
  white-space: nowrap;
}

/* ===== Balance display (generator) ===== */
.balance-display {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-dark);
  background: var(--soft);
  border: 1px solid #d7e2ff;
  border-radius: 999px;
  padding: 6px 14px;
  white-space: nowrap;
  cursor: default;
}

/* ===== Balance insufficient modal ===== */
.balance-detail-rows {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.balance-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
}

.balance-detail-row:last-child {
  border-bottom: none;
}

.balance-deficit-row {
  background: #fff6dc;
}

.balance-deficit-amount {
  color: var(--danger);
  font-size: 16px;
}

/* ===== Landing page ===== */
.landing-page {
  background: #f8faff;
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
}

.landing-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 60px);
}

/* Nav */
.landing-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.landing-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}

.landing-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.landing-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 900;
}

/* Hero */
.landing-hero {
  padding: clamp(60px, 10vw, 120px) 0 clamp(50px, 8vw, 90px);
  text-align: center;
}

.landing-h1 {
  font-size: clamp(36px, 6vw, 70px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1.08;
  margin-bottom: 20px;
}

.landing-accent {
  color: var(--accent);
}

.landing-lead {
  font-size: clamp(16px, 2.2vw, 20px);
  color: var(--muted);
  max-width: 680px;
  margin: 0 auto 36px;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 36px;
}

.hero-cta {
  font-size: 16px;
  padding: 14px 28px;
  border-radius: 14px;
}

.hero-badges {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-badge {
  display: inline-block;
  background: var(--soft);
  border: 1px solid #d0dcff;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
}

/* Section headings */
.landing-h2 {
  font-size: clamp(24px, 4vw, 38px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
  text-align: center;
}

.landing-section-lead {
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  max-width: 600px;
  margin: 0 auto 40px;
}

/* Try section */
.landing-try {
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: clamp(50px, 7vw, 90px) 0;
}

.try-panel {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}

.try-lang-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 0;
}

.try-lang-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.try-lang-select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 14px;
  background: var(--panel);
}

.try-textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 16px 18px;
  font-family: monospace;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

.try-textarea:focus {
  outline: none;
  background: #fff;
}

.try-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.try-cost-label {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.try-vat {
  font-weight: 400;
  color: var(--muted);
  font-size: 13px;
}

.try-generate-btn {
  padding: 10px 24px;
  border-radius: 12px;
  font-size: 15px;
}

.try-hint {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 16px auto 0;
  max-width: 800px;
}

/* Comparison table */
.landing-compare {
  padding: clamp(50px, 7vw, 90px) 0;
}

.compare-table-wrap {
  overflow-x: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  font-size: 15px;
}

.compare-table th,
.compare-table td {
  padding: 14px 20px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.compare-table th {
  background: var(--bg);
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
}

.compare-table .compare-feature-col {
  text-align: left;
  font-weight: 600;
  color: var(--text);
}

.compare-table td.compare-feature-col {
  font-weight: 500;
  color: var(--text);
  text-align: left;
}

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

.compare-table tbody tr:hover {
  background: var(--soft);
}

.compare-table .our-col {
  background: #f0f5ff;
  font-weight: 700;
}

.compare-table th.our-col {
  background: var(--soft);
  color: var(--accent-dark);
}

.our-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  padding: 2px 8px;
  font-weight: 700;
  margin-top: 4px;
  white-space: nowrap;
}

.compare-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  display: block;
}

.cmp-check { color: #1a8a3a; font-weight: 700; }
.cmp-cross { color: var(--danger); font-weight: 700; }
.cmp-partial { color: #a06000; font-weight: 600; font-size: 13px; }
.cmp-neutral { color: var(--muted); }
.cmp-speed-win { color: #1a8a3a; font-weight: 700; }
.cmp-speed-mid { color: #a06000; font-weight: 600; }
.cmp-speed-lose { color: var(--danger); }

/* Features */
.landing-features {
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: clamp(50px, 7vw, 90px) 0;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 24px;
  margin-top: 10px;
}

.feature-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
}

.feature-icon {
  font-size: 36px;
  margin-bottom: 14px;
}

.feature-card h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 10px;
}

.feature-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
}

/* Pricing */
.landing-pricing {
  padding: clamp(50px, 7vw, 90px) 0;
}

.pricing-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  max-width: 840px;
  margin: 0 auto;
}

@media (max-width: 600px) {
  .pricing-wrap { grid-template-columns: 1fr; }
}

.pricing-card,
.pricing-calc-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 30px 26px;
  box-shadow: var(--shadow);
}

.pricing-card {
  text-align: center;
  border: 2px solid var(--accent);
}

.pricing-amount {
  margin-bottom: 8px;
}

.pricing-num {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--accent);
}

.pricing-rub {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
}

.pricing-per {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 4px;
}

.pricing-vat-note {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  margin: 4px 0 20px;
}

.pricing-includes {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  text-align: left;
}

.pricing-includes li {
  padding: 6px 0;
  font-size: 14px;
  color: #1a8a3a;
  font-weight: 600;
}

.pricing-cta {
  display: block;
  text-align: center;
  font-size: 15px;
  padding: 12px 20px;
}

.pricing-calc-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 20px;
}

.pricing-calc-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.pricing-calc-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.calc-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 15px;
  background: var(--bg);
}

.pricing-calc-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--soft);
  border: 1px solid #d0dcff;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  font-size: 15px;
}

.pricing-calc-result strong {
  font-size: 22px;
  color: var(--accent);
}

.pricing-calc-hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 12px 0 0;
}

/* Auth modal */
.auth-modal-card {
  position: relative;
}

.modal-close-x {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  padding: 0;
}

.modal-close-x:hover {
  background: #e8eef9;
  color: var(--text);
}

.auth-cost-preview {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-dark);
  margin: 0 0 4px;
}

.auth-modal-actions {
  justify-content: flex-start;
  gap: 12px;
}

/* Footer */
.landing-footer {
  background: #1a2035;
  color: #c8d0e0;
  padding: clamp(50px, 7vw, 80px) 0 0;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 2fr;
  gap: 40px;
  padding-bottom: 50px;
}

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

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

.footer-logo {
  color: #fff;
  margin-bottom: 14px;
  display: inline-flex;
}

.footer-tagline {
  font-size: 14px;
  color: #8897b3;
  line-height: 1.55;
  margin-bottom: 18px;
}

.footer-col-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8897b3;
  margin: 0 0 14px;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 10px;
}

.footer-links a {
  color: #c8d0e0;
  text-decoration: none;
  font-size: 14px;
}

.footer-links a:hover {
  color: #fff;
}

/* Contact form */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-input,
.contact-textarea {
  border: 1px solid #2e3a52;
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 14px;
  background: #232d42;
  color: #e0e8f8;
  font-family: inherit;
  transition: border-color 0.15s;
}

.contact-input::placeholder,
.contact-textarea::placeholder {
  color: #5a6a82;
}

.contact-input:focus,
.contact-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.contact-textarea {
  resize: vertical;
  min-height: 90px;
}

.contact-submit {
  align-self: flex-start;
  padding: 9px 22px;
  font-size: 14px;
  border-radius: 10px;
}

.contact-sent {
  color: #4cd97b;
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.contact-error {
  color: #ff5c5c;
  font-size: 13px;
  margin: 0;
}

.footer-contacts-note {
  color: #8897b3;
  font-size: 14px;
  line-height: 1.6;
  margin: 4px 0 0;
}

/* ---- Legal pages (privacy / offer) ---- */
.legal-page {
  background: #f4f6fb;
  color: #1a2233;
}

.legal-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 44px 20px 88px;
}

.legal-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.legal-meta {
  color: #8897b3;
  font-size: 14px;
  margin: 0 0 30px;
}

.legal-back {
  display: inline-block;
  margin-bottom: 22px;
  color: #1f5eff;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.legal-back:hover {
  text-decoration: underline;
}

.legal-toc {
  background: #fff;
  border: 1px solid #e3e8f2;
  border-radius: 12px;
  padding: 16px 24px;
  margin: 0 0 34px;
}

.legal-toc ol {
  margin: 0;
  padding-left: 20px;
  color: #56627d;
  font-size: 14px;
  line-height: 1.9;
}

.legal-wrap h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 34px 0 12px;
  color: #141c2e;
}

.legal-wrap p,
.legal-wrap li {
  line-height: 1.7;
  color: #38435c;
  font-size: 15px;
}

.legal-wrap ul,
.legal-wrap ol {
  padding-left: 22px;
  margin: 10px 0;
}

.legal-wrap li {
  margin-bottom: 6px;
}

.legal-wrap a {
  color: #1f5eff;
}

.legal-fill {
  background: #fff3cd;
  border: 1px dashed #e0b800;
  border-radius: 4px;
  padding: 0 6px;
  font-weight: 600;
  color: #7a5b00;
  white-space: nowrap;
}

/* ---- Registration consent checkbox ---- */
.auth-consent {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 4px 0 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #56627d;
  cursor: pointer;
}

.auth-consent input[type="checkbox"] {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  margin: 1px 0 0;
  cursor: pointer;
  accent-color: #1f5eff;
}

.auth-consent a {
  color: #1f5eff;
}

/* ---- Cookie consent banner ---- */
.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  background: #1b2335;
  color: #e7ecf6;
  border: 1px solid #2e3a52;
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 12px 44px rgba(10, 16, 30, 0.4);
  font-size: 14px;
  line-height: 1.5;
  animation: cookie-rise 0.35s ease;
}

@keyframes cookie-rise {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.cookie-banner-text {
  flex: 1;
}

.cookie-banner-text a {
  color: #6f9bff;
}

.cookie-banner-btn {
  flex-shrink: 0;
  background: #1f5eff;
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 10px 22px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.cookie-banner-btn:hover {
  background: #1a4fd6;
}

.cookie-banner-hide {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

@media (max-width: 560px) {
  .cookie-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
}

/* ---- Free editor promo (landing) ---- */
.landing-nav-link {
  color: #38435c;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 6px;
  white-space: nowrap;
}

.landing-nav-link:hover {
  color: #1f5eff;
}

.landing-editor {
  padding: 72px 0;
  background: #ffffff;
}

.editor-promo {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 48px;
  align-items: center;
}

.editor-promo-badge {
  display: inline-block;
  background: #eaf7ee;
  color: #1a8a3a;
  font-weight: 700;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.editor-promo-list {
  list-style: none;
  padding: 0;
  margin: 20px 0 28px;
  display: grid;
  gap: 10px;
}

.editor-promo-list li {
  position: relative;
  padding-left: 28px;
  color: #38435c;
  font-size: 15px;
  line-height: 1.5;
}

.editor-promo-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: #1a8a3a;
  font-weight: 700;
}

.editor-promo-visual {
  display: flex;
  justify-content: center;
}

.editor-promo-visual svg {
  width: 100%;
  max-width: 280px;
  height: auto;
  filter: drop-shadow(0 12px 30px rgba(31, 94, 255, 0.12));
}

@media (max-width: 760px) {
  .editor-promo {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .editor-promo-visual {
    order: -1;
  }
}

/* ---- FAQ (landing) ---- */
.landing-faq {
  padding: 72px 0;
  background: #f4f6fb;
}

.faq-list {
  max-width: 820px;
  margin: 28px auto 0;
  display: grid;
  gap: 12px;
}

.faq-item {
  background: #ffffff;
  border: 1px solid #e3e8f2;
  border-radius: 12px;
  padding: 4px 22px;
}

.faq-item summary {
  cursor: pointer;
  list-style: none;
  padding: 18px 28px 18px 0;
  font-weight: 600;
  font-size: 17px;
  color: #141c2e;
  position: relative;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
  font-weight: 400;
  color: #1f5eff;
  line-height: 1;
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item p {
  margin: 0 0 18px;
  color: #38435c;
  line-height: 1.7;
  font-size: 15px;
}

.footer-bottom {
  border-top: 1px solid #2e3a52;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-copy {
  font-size: 13px;
  color: #5a6a82;
  margin: 0;
}

/* ===== Editor toolbar home button (injected via editor-page.js) ===== */
.editor-home-toolbar-btn {
  margin-right: 4px;
}

/* ===== Profile page ===== */
.profile-page {
  background: #f8faff;
  min-height: 100vh;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
}

.profile-main {
  padding-top: 40px;
  padding-bottom: 60px;
  max-width: 860px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 36px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-name {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 4px;
}

.profile-since {
  margin: 0;
  font-size: 14px;
}

/* Stat cards */
.profile-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 40px;
}

@media (max-width: 640px) {
  .profile-cards { grid-template-columns: 1fr; }
}

.profile-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 20px;
  box-shadow: 0 4px 18px rgba(31,44,71,0.07);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-card-balance {
  border: 2px solid var(--accent);
}

.pc-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.pc-value {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.pc-bonus {
  color: #1a8a3a;
}

.pc-action {
  font-size: 13px;
  padding: 8px 14px;
  margin-top: 4px;
  align-self: flex-start;
}

.pc-status {
  font-size: 13px;
  color: var(--muted);
}

.pc-sub {
  font-size: 13px;
  color: var(--muted);
}

/* Sections */
.profile-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 18px rgba(31,44,71,0.06);
}

.profile-section-title {
  font-size: 17px;
  font-weight: 800;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
}

/* Referral */
.referral-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.referral-desc {
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 14px;
  line-height: 1.55;
}

.referral-link-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.referral-link-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
}

.referral-link-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 14px;
  background: var(--bg);
  color: var(--accent-dark);
  font-weight: 600;
}

.ref-copy-btn {
  white-space: nowrap;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px;
}

.referral-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 14px;
}

.ref-stat strong {
  color: var(--text);
  font-weight: 700;
}

.ref-stat-sep {
  color: var(--muted);
}

/* Profile tables */
.payments-wrap,
.referral-table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.profile-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.profile-table th,
.profile-table td {
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.profile-table th {
  background: var(--bg);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

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

.profile-table tbody tr:hover {
  background: var(--soft);
}

.amount-positive {
  color: #1a8a3a;
  font-weight: 700;
}

.amount-negative {
  color: var(--danger);
  font-weight: 700;
}

.payment-date {
  white-space: nowrap;
  color: var(--muted);
}

.table-empty {
  text-align: center;
  color: var(--muted);
  padding: 28px !important;
  font-style: italic;
}

.receipt-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

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

/* Danger zone */
.danger-zone {
  border-color: #ffd4d4;
}

.danger-title {
  color: var(--danger);
}

.danger-panel {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.danger-desc {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
  max-width: 500px;
  line-height: 1.55;
}

.danger-btn {
  background: var(--danger);
  box-shadow: none;
  font-size: 14px;
  padding: 10px 20px;
  white-space: nowrap;
}

.danger-btn:hover:not(:disabled) {
  background: #8f2a2a;
}

/* Delete confirm input */
.delete-confirm-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 15px;
  background: var(--bg);
  margin: 8px 0 0;
}

/* The toast component is defined once (see "Toast notification" above): this
   second, conflicting .toast definition left the profile page's toast at the
   shared opacity:0 base state — i.e. invisible — because it never added .show. */

/* ===== Auth pages (login, register, verify) ===== */
.auth-page {
  background: #f8faff;
  min-height: 100vh;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
}

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 65px);
  padding: 40px 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 36px 32px;
  box-shadow: 0 8px 40px rgba(31,44,71,0.10);
}

.auth-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}

.auth-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 24px;
  line-height: 1.55;
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}

.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31,94,255,0.12);
  outline: none;
}

.auth-optional {
  font-weight: 400;
  color: var(--muted);
}

.auth-submit {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  border-radius: 12px;
  margin-top: 8px;
}

.auth-error {
  background: #fff0f0;
  border: 1px solid #ffd4d4;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--danger);
  margin-bottom: 12px;
  /* A 422 can carry several validation messages joined with line breaks. */
  white-space: pre-line;
}

.auth-switch {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin: 16px 0 0;
}

.auth-switch a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

/* Password rules */
.pw-rules {
  list-style: none;
  padding: 8px 0 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pw-rules li {
  font-size: 12px;
  color: var(--muted);
  padding-left: 18px;
  position: relative;
}

.pw-rules li::before {
  content: "○";
  position: absolute;
  left: 0;
  font-size: 10px;
}

.pw-rules li.pw-ok {
  color: #1a8a3a;
}

.pw-rules li.pw-ok::before {
  content: "✓";
}

.pw-rules li.pw-fail {
  color: var(--danger);
}

.pw-rules li.pw-fail::before {
  content: "✗";
}

/* Yandex button */
.yandex-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: none;
  cursor: pointer;
  margin-bottom: 6px;
  transition: background 0.15s;
}

.yandex-btn:hover {
  background: #f4f4f4;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* Verify email page */
.verify-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: 16px;
}

.verify-email-display {
  font-weight: 700;
  color: var(--accent-dark);
  text-align: center;
  font-size: 15px;
  margin: 0 0 12px;
}

.verify-hint {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin: 0 0 20px;
}
