  :root {
    --accent: #2f6fed;
    --accent-ink: #1c4bb8;
    --ink: #1f2430;
    --graphite: #4a4f58;
    --gray: #8890a0;
    --border: #d8dce3;
    --panel-bg: #f6f7f9;
    --canvas-bg: #fbfbfc;
    --grid-line: #e7e9ee;
    --note-bg: #fff6c9;
    --danger: #c0392b;
    --speaking: #8b5cf6;
    --muted-ink: #5b6170;
    --surface: #ffffff;
    --accent-soft: #e3f3fc;
    --mark-empty: #c3c8d1;
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
  }
  #app { display: flex; flex-direction: column; height: 100vh; }

  /* Topbar */
  #topbar {
    flex: 0 0 52px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
  }
  #topbar .brand { font-weight: 600; font-size: 13px; color: var(--graphite); white-space: nowrap; }
  .board-logo { display: flex; align-items: center; flex: none; }
  .header-link { color: var(--graphite); text-decoration: none; font-size: 13px; white-space: nowrap; padding: 6px; border-radius: 6px; }
  .header-link:hover { background: var(--panel-bg); color: var(--ink); }
  .account-initial { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; text-decoration: none; }
  .topic-caption { font-weight: 600; font-size: 14px; padding: 6px 8px; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
  .topic-caption:empty { display: none; }
  #topbar .spacer { flex: 1; }
  #new-btn { padding: 6px 12px; border-radius: 6px; }
  button {
    font-family: inherit;
    font-size: 13px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
  }
  button:hover { border-color: var(--gray); }
  button:disabled { opacity: 0.45; cursor: not-allowed; }
  button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  button.primary:hover { background: var(--accent-ink); }
  button.danger-text { color: var(--danger); }


  /* Login page */
  .login-body { background: var(--panel-bg); display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; }
  .login-card { width: 340px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
  .login-card h1 { font-size: 18px; margin: 0; }
  .login-providers { display: flex; flex-direction: column; gap: 8px; }
  .login-provider { display: block; text-align: center; padding: 8px; border: 1px solid var(--border); border-radius: 4px; color: var(--ink); text-decoration: none; font-size: 13px; }
  .login-provider:hover { border-color: var(--gray); }
  .login-or { text-align: center; font-size: 12px; color: var(--gray); }
  .login-form { display: flex; flex-direction: column; gap: 8px; }
  .login-form label { font-size: 12.5px; color: var(--graphite); }
  .login-form input { border: 1px solid var(--border); border-radius: 4px; padding: 8px; font-size: 14px; font-family: inherit; }
  .login-note { margin: 0; font-size: 12.5px; color: var(--graphite); }
  .login-link { background: none; border: none; color: var(--accent); padding: 4px 0; font-size: 12.5px; cursor: pointer; }
  .login-link:hover { border: none; text-decoration: underline; }
  .login-error { color: var(--danger); font-size: 12.5px; }
  .login-lang { display: flex; gap: 10px; justify-content: flex-end; }
  .legal-page { max-width: 720px; margin: 40px auto; padding: 0 20px; font-size: 14px; line-height: 1.5; }

  /* Main layout */
  #main { flex: 1; display: flex; min-height: 0; position: relative; }

  /* Start form over the board */
  #main.form-open #sidebar-right { visibility: hidden; }
  .start-overlay { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(31, 36, 48, 0.28); overflow-y: auto; }
  .start-form { width: 100%; max-width: 560px; margin: auto; background: #fff; border-radius: 16px; box-shadow: 0 12px 40px rgba(31, 36, 48, 0.2); padding: 32px; display: flex; flex-direction: column; gap: 18px; }
  .start-form h2 { margin: 0; font-size: 24px; font-weight: 800; }
  .form-fields { display: flex; flex-direction: column; gap: 18px; }
  .form-field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; min-width: 0; }
  .topic-picker { position: relative; }
  .topic-field { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 46px; border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; font: inherit; font-weight: 400; background: #fff; color: var(--ink); text-align: left; cursor: pointer; }
  .topic-field:disabled { cursor: default; color: var(--gray); }
  .topic-field[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px #dfe8fd; }
  .topic-field-name { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topic-field-name.placeholder { color: var(--muted-ink); }
  .topic-chevron { flex: none; fill: none; stroke: var(--graphite); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .topic-field[aria-expanded="true"] .topic-chevron { transform: rotate(180deg); }
  .topic-panel { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 36px rgba(31, 36, 48, 0.22); overflow: hidden; font-weight: 400; }
  .topic-search-row { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 12px; border-bottom: 1px solid var(--grid-line); }
  .topic-search-icon { flex: none; fill: none; stroke: var(--muted-ink); stroke-width: 2; stroke-linecap: round; }
  .topic-search { flex: 1 1 auto; min-width: 0; border: 0; padding: 0; font: inherit; font-size: 14px; color: var(--ink); background: transparent; }
  .topic-search:focus { outline: none; }
  .topic-clear { flex: none; width: 28px; height: 28px; border: 0; border-radius: 6px; padding: 0; background: var(--panel-bg); color: var(--graphite); display: flex; align-items: center; justify-content: center; }
  .topic-clear svg { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
  .topic-cols { display: flex; height: min(388px, 55vh); }
  .topic-domains { position: relative; flex: none; width: 176px; padding: 6px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; background: var(--panel-bg); border-right: 1px solid var(--grid-line); }
  .topic-domain { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-size: 13.5px; line-height: 1.25; text-align: left; color: var(--graphite); cursor: pointer; }
  .topic-domain.current { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(31, 36, 48, 0.12); }
  .topic-domain:disabled { cursor: default; }
  .topic-domain-name { flex: 1 1 auto; min-width: 0; }
  .topic-domain-count { flex: none; font-size: 12px; font-weight: 600; color: var(--muted-ink); }
  .topic-domain.current .topic-domain-count { color: var(--accent-ink); }
  .topic-right { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
  .topic-found { margin: 0; padding: 12px 16px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--graphite); }
  .topic-list { position: relative; flex: 1 1 auto; overflow-y: auto; padding: 6px; }
  .topic-option { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 10px; border-radius: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
  .topic-option.active { background: var(--accent-soft); }
  .topic-option[aria-selected="true"] { font-weight: 600; }
  .topic-option-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
  .topic-option-domains { font-size: 12px; font-weight: 400; color: var(--muted-ink); }
  .topic-option mark { background: none; color: var(--accent-ink); font-weight: 700; }
  .topic-check { flex: none; visibility: hidden; fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
  .topic-option[aria-selected="true"] .topic-check { visibility: visible; }
  .topic-empty { margin: 0; padding: 28px 12px 24px; text-align: center; font-size: 14px; color: var(--muted-ink); }
  @media (max-width: 559px) {
    .topic-cols { flex-direction: column; height: auto; }
    .topic-domains { width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--grid-line); }
    .topic-domain { flex: none; white-space: nowrap; min-height: 36px; }
    .topic-list { max-height: 50vh; }
  }
  .form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
  .segmented { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 4px; background: var(--panel-bg); border-radius: 10px; padding: 4px; }
  .segmented button { border: 0; background: transparent; border-radius: 8px; padding: 10px; font-size: 14px; color: var(--graphite); }
  .segmented button.selected { background: #fff; box-shadow: 0 1px 3px rgba(31, 36, 48, 0.12); font-weight: 600; color: var(--ink); }
  .form-duration { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--graphite); }
  .form-duration-icon { flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .form-hint { margin: 0; font-size: 13px; font-weight: 400; line-height: 1.45; color: #5b6170; }
  button.form-start { font-size: 16px; font-weight: 600; padding: 13px; border-radius: 10px; }
  .form-credits { margin: -8px 0 0; font-size: 13px; color: #5b6170; text-align: center; }
  button.form-buy { border: 0; background: none; color: var(--accent-ink); padding: 0 2px; font: inherit; font-weight: 600; }
  button.form-buy:hover { text-decoration: underline; }
  .form-error { margin: -8px 0 0; color: var(--danger); font-size: 13px; }
  .form-error.form-topics-failed { margin: 0; font-size: 14px; }
  .sidebar {
    flex: 0 0 200px;
    width: 200px;
    font-size: 13px;
    background: var(--panel-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
  #sidebar-right {
    flex: 0 0 400px;
    width: 400px;
    background: #fff;
    border-right: none;
    border-left: 1px solid var(--border);
  }
  .sidebar button { border-radius: 6px; }
  #sidebar-right button { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #sidebar-right button:disabled:not(.loading) { opacity: 1; background: var(--panel-bg); border-color: var(--grid-line); color: var(--gray); }
  #sidebar-right .side-section { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
  #sidebar-right .side-label { margin-bottom: 0; }
  #sidebar-right .side-divider { background: var(--grid-line); margin: 0 16px; }
  #stage-progress.hidden + .side-divider { display: none; }
  .side-section { padding: 12px; }
  .side-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--gray);
    text-transform: uppercase;
    margin-bottom: 8px;
  }
  .palette-grid { display: flex; flex-direction: column; gap: 4px; }
  .palette-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    justify-content: flex-start;
    padding: 7px 10px;
  }
  .palette-btn .glyph { flex: none; color: var(--graphite); fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .palette-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .palette-btn.active .glyph { color: #fff; }
  .palette-btn:disabled { opacity: 1; background: var(--panel-bg); border-color: var(--grid-line); color: var(--gray); }
  .palette-btn:disabled .glyph { color: var(--gray); }
  .side-divider { height: 1px; background: var(--border); margin: 0 12px; }

  #properties { display: flex; flex-direction: column; gap: 10px; }
  .props-section:has(#properties:empty), .props-divider:has(+ .props-section #properties:empty) { display: none; }
  #properties label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: block;
    margin-bottom: 4px;
  }
  #properties textarea,
  #properties input[type="text"] {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    background: #fff;
  }
  #properties textarea { min-height: 56px; }
  .field { margin-bottom: 2px; }
  .toggle-row { display: flex; gap: 6px; }
  .toggle-row button { flex: 1; }
  .toggle-row button.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
  .hint { font-size: 12px; color: var(--gray); line-height: 1.4; }
  .empty-hint { font-size: 12px; color: var(--gray); padding: 4px 0; }

  /* Canvas */
  #canvas-wrap { flex: 1; position: relative; background: var(--canvas-bg); overflow: hidden; }
  /* Dragging a shape shouldn't leave a browser text-selection highlight
     smeared across whatever labels/notes the cursor passed over. The active
     inline editor opts back into normal selection so you can still
     select/copy/cut the text you're typing. */
  svg#canvas { width: 100%; height: 100%; display: block; user-select: none; }
  svg#canvas .edit-div, svg#canvas .edit-div * { user-select: text; }
  svg#canvas.mode-arrow { cursor: crosshair; }
  svg#canvas.mode-pan { cursor: grab; }
  svg#canvas.panning { cursor: grabbing; }

  .node-shape { fill: #fff; stroke: var(--graphite); stroke-width: 1.5; cursor: grab; }
  .node-shape.selected { stroke: var(--accent); stroke-width: 2; }
  .node-shape:active { cursor: grabbing; }
  /* Text field: free-floating label, no visible box — like Miro's text tool.
     A thin accent outline still shows while selected, so it stays findable
     and resizable even with nothing typed into it yet. */
  .node-shape.text-shape { fill: none; stroke: none; }
  .node-shape.text-shape.selected { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 3; }
  .node-label-div {
    width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: 14px; line-height: 1.25; text-align: center;
    color: var(--ink); padding: 4px 8px; white-space: pre-wrap; word-break: break-word;
    pointer-events: none; overflow: hidden;
  }
  /* Text tool blocks read like a document, not a labeled shape — anchor to
     the top-left instead of centering. */
  .node-label-div.text-label-div { align-items: flex-start; justify-content: flex-start; text-align: left; }
  /* Text block lists (diagram-board «Список в текстовом блоке»): a marker column, a gap above each item; layout.TextNodeHeightFor mirrors these numbers. */
  .text-label-div .tb-para, .text-label-div .tb-item { width: 100%; }
  .text-label-div .tb-item { display: flex; align-items: flex-start; margin-top: 4px; }
  .text-label-div .tb-marker { flex: 0 0 18px; }
  .text-label-div .tb-text { flex: 1 1 auto; min-width: 0; }
  .edit-toolbar { display: flex; gap: 4px; }
  .edit-toolbar button { font-size: 12px; padding: 2px 8px; }
  .resize-handle { fill: #fff; stroke: var(--accent); stroke-width: 1.5; cursor: nwse-resize; }
  .waypoint-handle { fill: #fff; stroke: var(--accent); stroke-width: 1.5; cursor: grab; }
  .waypoint-handle:active { cursor: grabbing; }
  .port-dot { fill: #fff; stroke: var(--accent); stroke-width: 1.5; cursor: crosshair; }
  .port-dot:hover { fill: var(--accent); }
  .port-dot.snap-target { fill: var(--accent); stroke: var(--accent); opacity: 0.35; pointer-events: none; }
  /* Ports shown only because the arrow tool is armed (not because the node
     itself is selected) stay invisible until the pointer is over the shape. */
  .port-dot-hover { opacity: 0; transition: opacity 0.1s; }
  g:hover .port-dot-hover { opacity: 1; }

  /* Non-interactive: it sits visually on top of .edge-hit but must never
     steal the hover/click hit-test away from the wide invisible target. */
  .edge-line { stroke: var(--graphite); stroke-width: 1.5; fill: none; stroke-linejoin: round; pointer-events: none; }
  .edge-line.dashed { stroke-dasharray: 5 4; }
  .edge-hit { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
  .edge-line.selected { stroke: var(--accent); }
  /* Extra soft halo behind the line, revealed on hover — distinct from the
     stronger accent-colored line used for the selected state. */
  .edge-halo { stroke: var(--accent); stroke-width: 5; fill: none; stroke-linejoin: round; opacity: 0; transition: opacity 0.1s; pointer-events: none; }
  .edge-hit:hover ~ .edge-halo { opacity: 0.3; }
  .edge-label-bg { fill: #fff; }
  .edge-label-text { font-size: 12px; fill: var(--ink); }

  .note-box { fill: var(--note-bg); stroke: #d9c14a; stroke-width: 1; }
  .note-box.selected { stroke: var(--accent); stroke-width: 1.5; }
  .note-text-div {
    width: 100%; height: 100%; padding: 6px 8px; font-size: 12px; line-height: 1.3;
    white-space: pre-wrap; word-break: break-word; color: #55501f; pointer-events: none; overflow: hidden;
  }
  .note-link { stroke: var(--gray); stroke-width: 1; stroke-dasharray: 3 3; fill: none; }

  .preview-line { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 3; fill: none; }
  .align-guide { stroke: #f472b6; stroke-width: 1; stroke-dasharray: 5 4; pointer-events: none; }

  /* Box decoration (size/padding/outline/background) lives separately from
     the contentEditable text element itself. A contentEditable that is
     ITSELF a flex container is unreliable about painting a visible caret
     when it's empty/near-empty in some browsers — so centering is done by
     an ordinary (non-editable) flex wrapper around a plain-block editor,
     never by making the editable element flex. */
  .edit-box {
    width: 100%; height: 100%; box-sizing: border-box;
    padding: 4px 8px;
    background: rgba(255,255,255,0.9);
    /* Shapes never resize to fit text (matches Miro) — overflow is simply
       clipped rather than spilling past the shape's edge. */
    overflow: hidden;
  }
  /* Clips the edit overlay to match a circle node, so the background
     doesn't bleed square into the shape's rounded-off corners. */
  .edit-box.round { border-radius: 50%; }
  /* Chrome won't paint a native caret while the field holds only invisible
     placeholder content — this synthetic one (positioned in JS) stands in
     until real text exists, at which point the native caret takes over. */
  .fake-caret {
    position: absolute;
    width: 1px;
    background: var(--ink);
    pointer-events: none;
    animation: fake-caret-blink 1s step-end infinite;
  }
  @keyframes fake-caret-blink {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
  }
  .edit-center-wrap {
    width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
  }
  .edit-div {
    font-size: 14px; line-height: 1.25; font-family: inherit; color: var(--ink);
    text-align: center; white-space: pre-wrap; word-break: break-word;
    /* contentEditable gets a default browser focus ring on click, not just
       keyboard focus — the edit box itself already shows what's editable. */
    outline: none;
  }
  .note-edit-div {
    text-align: left; font-size: 12px; line-height: 1.3;
    padding: 6px 8px; color: #55501f; background: var(--note-bg);
  }
  .text-edit-div { text-align: left; }
  .edge-edit-div {
    font-size: 12px; padding: 3px 6px; background: #fff;
    white-space: pre; /* the label's own line breaks show while editing; lines never wrap on their own */
  }

  /* Zoom controls */
  #zoom-controls {
    position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 6px;
    background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px;
    font-size: 12px; color: var(--graphite);
  }
  #zoom-controls button { padding: 3px 8px; font-size: 12px; }
  #zoom-label { min-width: 36px; text-align: center; font-variant-numeric: tabular-nums; }

  /* Modals */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(20,22,28,0.35);
    display: flex; align-items: center; justify-content: center; z-index: 50;
  }
  .modal-overlay.hidden { display: none; }
  .modal {
    background: #fff; border-radius: 8px; width: 720px; max-width: 92vw; max-height: 86vh;
    display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  }
  .modal-header { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); gap: 8px; }
  .modal-header h2 { font-size: 15px; margin: 0; flex: 1; }
  .modal-body { flex: 1; overflow: auto; padding: 0; }
  .modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
  .close-x { border: none; background: none; font-size: 16px; color: var(--gray); padding: 2px 6px; }

  /* Hint popup — deliberately large/roomy (near full-screen, margin kept from the viewport edges via width/height < 100%) rather than a tight dialog. Overrides .modal's own max-width/max-height (92vw/86vh), which would otherwise silently clip these below their intended size on every viewport. */
  .hint-modal { width: min(860px, 92vw); height: min(720px, 88vh); max-width: 92vw; max-height: 88vh; }
  .hint-modal.with-diagram { width: min(1560px, 96vw); max-width: 96vw; }
  .hint-modal-body { display: flex; align-items: stretch; }
  .hint-diagram-pane {
    position: relative; flex: 1 1 55%; border-right: 1px solid var(--border); background: #fafafa;
    padding: 20px 32px 32px; box-sizing: border-box; display: flex; flex-direction: column;
  }
  .hint-diagram-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; font-size: 12px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.04em; }
  .hint-diagram-head button { text-transform: none; letter-spacing: normal; }
  .hint-diagram-pane.hidden { display: none; }
  .hint-diagram-svg { width: 100%; flex: 1 1 auto; min-height: 0; display: block; }
  .hint-diagram-svg.hidden { display: none; }
  .hint-diagram-svg .node-shape, .hint-diagram-svg .edge-line { cursor: default; }
  .hint-text-pane {
    flex: 1 1 45%; padding: 20px 36px 32px; font-size: 15px; line-height: 1.7; color: var(--ink);
    display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
  }
  .hint-text-pane.hidden { display: none; }
  .hint-text-head { display: flex; justify-content: space-between; align-items: center; min-height: 28px; padding-bottom: 12px; font-size: 12px; line-height: 1.4; color: var(--gray); text-transform: uppercase; letter-spacing: 0.04em; }
  .hint-spinner-sm {
    width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: hint-spin 0.8s linear infinite; display: inline-block;
  }
  .hint-spinner-sm.hidden { display: none; }
  .hint-text-head button { text-transform: none; letter-spacing: normal; }
  .hint-text-body { flex: 0 0 auto; }
  .hint-text-body.hidden, .hint-extras.hidden { display: none; }
  .hint-extras { flex: 1 0 auto; font-size: 14px; }
  .hint-extras-title { font-weight: 400; margin: 24px 0 12px; color: var(--gray); font-size: 12px; line-height: 1.4; text-transform: uppercase; letter-spacing: 0.04em; }
  .hint-concepts ul { margin: 0; padding-left: 20px; }
  .hint-concepts li { margin-bottom: 6px; }
  .hint-uncovered { margin-top: 14px; font-size: 12px; color: var(--gray); }
  .hint-solution-body { font-size: 14px; }
  .hint-solution-body.hidden { display: none; }
  .hint-solution-body p { margin: 0 0 6px; }
  .hint-solution-more { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
  .hint-solution-more summary { cursor: pointer; color: var(--gray); }
  .hint-solution-body ul, .hint-solution-body ol { margin: 0 0 14px; padding-left: 20px; }
  .hint-text-body p { margin: 0 0 14px; }
  .hint-text-body p:last-child { margin-bottom: 0; }
  .hint-text-body ul, .hint-text-body ol { margin: 0 0 14px; padding-left: 20px; }
  .hint-text-body ul li, .hint-text-body ol li { margin-bottom: 6px; }
  .hint-text-body ul:last-child, .hint-text-body ol:last-child { margin-bottom: 0; }

  /* Hint loader — full-body before the first delta (hint-popup.js). */
  .hint-loading {
    flex: 1 1 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px; color: var(--gray);
  }
  .hint-loading.hidden { display: none; }
  .hint-loading-label { font-size: 14px; letter-spacing: 0.02em; animation: hint-pulse 1.6s ease-in-out infinite; }
  .hint-spinner-lg {
    width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: hint-spin 0.8s linear infinite; display: inline-block;
  }
  @keyframes hint-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }


  /* Hint request button loading spinner */
  #hint-request-btn { position: relative; }
  #hint-request-btn.loading { color: transparent; }
  #hint-request-btn.loading::after {
    content: ""; position: absolute; top: 50%; left: 50%;
    width: 12px; height: 12px; margin: -7px 0 0 -7px;
    border: 2px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: hint-spin 0.6s linear infinite;
  }
  @keyframes hint-spin { to { transform: rotate(360deg); } }

  /* Interview voice panel (right sidebar) */
  .voice-row { display: flex; gap: 6px; }
  .voice-row > button { flex: 1; min-width: 0; padding: 7px 10px; }
  .hint-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .voice-row:not(:has(> :not(.hidden))) { display: none; }
  #voice-toggle-btn { padding: 8px 10px; font-weight: 600; }
  .voice-row > .mic-btn { flex: none; display: inline-flex; align-items: center; padding: 0 10px; line-height: 0; }
  .mic-btn.muted { background: var(--danger); border-color: var(--danger); color: #fff; }
  /* Один глиф на оба состояния: линия перечёркивания скрыта, пока микрофон включён. */
  .mic-glyph { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mic-glyph .mic-slash, .mic-glyph .mic-slash-bg { display: none; }
  .mic-btn.muted .mic-slash { display: inline; }
  .mic-btn.muted .mic-slash-bg { display: inline; stroke: var(--danger); stroke-width: 4.5; }
  .voice-status {
    align-self: flex-start;
    font-size: 12px;
    color: var(--gray);
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
  }
  .voice-status.listening { color: var(--accent); border-color: var(--accent); }
  .voice-status.error { color: var(--danger); border-color: var(--danger); }

  .voice-live-status {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 18px 16px;
    border-top: 1px solid var(--border);
    background: var(--panel-bg);
    font-size: 16px;
    font-weight: 600;
    color: var(--gray);
  }
  /* Scale is driven live from actual mic/output level (voice.js's tickLevelMeter), not a fixed keyframe — the transition just smooths between animation-frame updates. */
  .voice-live-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--gray); flex-shrink: 0; transition: transform 80ms linear; }
  .voice-live-status.listening { color: var(--accent); }
  .voice-live-status.listening .voice-live-dot { background: var(--accent); }
  .voice-live-status.speaking { color: var(--speaking); }
  .voice-live-status.speaking .voice-live-dot { background: var(--speaking); }
  .voice-live-status.working { color: var(--muted-ink); }
  .voice-live-status.working .voice-live-dot { background: var(--muted-ink); }
  .voice-live-status.paused { opacity: 0.55; }

  .hidden { display: none !important; }

  /* Stage progress (Hints mode, right sidebar) */
  #stage-progress { gap: 3px; }
  #stage-progress .side-label { margin-bottom: 5px; }
  .stage-checklist { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
  .stage-item { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: var(--gray); }
  .stage-mark { flex: none; display: flex; width: 14px; height: 14px; }
  .stage-mark .mark-accent { stroke: var(--accent); }
  .stage-mark .mark-fill { fill: var(--accent-soft); }
  .stage-mark .mark-bg { fill: var(--surface); }
  .stage-mark .mark-dot { fill: var(--accent); }
  .stage-mark .mark-empty { stroke: var(--mark-empty); }
  .stage-mark .mark-skip { stroke: var(--gray); }
  .stage-item.done { color: var(--muted-ink); }
  #sidebar-right .stage-jump { width: 100%; border: 0; border-radius: 6px; background: none; font: inherit; text-align: left; cursor: pointer; }
  #sidebar-right .stage-jump:hover { color: var(--ink); text-decoration: underline; }
  #sidebar-right .stage-jump:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  #sidebar-right .stage-link { color: var(--ink); text-decoration: none; }
  #sidebar-right .stage-link:hover { text-decoration: underline; }
  #sidebar-right .stage-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  .stage-item.active { margin: 0 -8px; padding: 4px 8px; border-radius: 6px; background: var(--panel-bg); color: var(--ink); font-weight: 600; }
  .stage-timer { margin-top: 8px; display: flex; align-items: center; gap: 8px; }
  .stage-timer-track {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: var(--grid-line);
    overflow: hidden;
  }
  .stage-timer-bar { height: 100%; background: var(--accent); transition: width 1s linear; }
  .stage-timer-label { font-size: 12px; color: var(--muted-ink); font-variant-numeric: tabular-nums; }
  .line.interviewer { position: relative; }
  .line.interviewer.has-judge-badge { padding-right: 34px; padding-bottom: 8px; }
  .judge-badge {
    position: absolute;
    right: 7px;
    bottom: 6px;
    width: 18px;
    height: 18px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    transition: filter 0.12s ease;
  }
  .judge-badge:hover { filter: brightness(0.94); }
  .judge-badge.amber { background: #fbe9c4; border-color: #f0cd7f; color: #8a5a00; }
  .judge-badge.green { background: #d6f0e0; border-color: #9fd9b7; color: #1d6b3f; }
  .judge-badge.grey { background: #e6e8ee; border-color: #cfd3dc; color: #5b6170; }
  .judge-badge[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--accent); }
  #transcript.judge-badges-off .judge-badge { display: none; }
  .judge-popup {
    position: fixed;
    width: 360px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--ink);
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .judge-popup.hidden { display: none; }
  .judge-popup-header { display: flex; align-items: center; justify-content: space-between; }
  .judge-popup-title { font-weight: 600; }
  .judge-popup-close { padding: 0 6px; font-size: 12px; background: transparent; border: 1px solid transparent; color: var(--muted-ink); cursor: pointer; }
  .judge-popup-close:hover { border-color: var(--border); }
  .judge-popup-reason { color: var(--muted-ink); }
  .judge-popup-label { font-weight: 600; margin-top: 2px; }
  .judge-popup-list { margin: 0; padding-left: 16px; }

  .voice-transcript-section { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  #transcript {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 2px;
  }
  #transcript > :first-child { margin-top: auto; }
  .line { max-width: 88%; padding: 7px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.4; }
  .line.interviewer { align-self: flex-start; background: #eef2ff; }
  .line.candidate { align-self: flex-end; background: #eef7ee; text-align: right; }
  .line.system { align-self: center; padding: 0 10px; color: var(--gray); font-size: 11px; text-align: center; }
  .line-label { display: block; margin-bottom: 2px; color: var(--gray); font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
  .line.pending { opacity: 0.65; }
  .line.pending::after { content: "▍"; opacity: 0.6; }
  .line.candidate.pending:empty { background: transparent; padding: 2px 10px; }
  .chat-form { display: flex; gap: 6px; }
  .chat-form button { padding: 7px 12px; }
  .chat-form input {
    flex: 1; min-width: 0; padding: 7px 8px; font-size: 12.5px;
    border: 1px solid var(--border); border-radius: 6px; background: #fff;
  }
  .chat-form input:disabled { background: transparent; color: var(--gray); }

  /* Итоговый фидбек (feedback.html): документ, а не холст — страница скроллится целиком, разделы — карточки. */
  body.fb-doc { height: auto; min-height: 100%; background: #fff; }
  .fb-page { width: 100%; max-width: 1168px; margin: 0 auto; padding: 40px 24px 64px; display: flex; flex-direction: column; gap: 24px; }
  .fb-back { align-self: flex-start; font-size: 14px; color: var(--graphite); text-decoration: none; }
  .fb-back:hover { color: var(--ink); text-decoration: underline; }
  .fb-title-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-top: -8px; }
  .fb-title { display: flex; flex-direction: column; gap: 6px; }
  .fb-title h1 { margin: 0; font-size: 36px; font-weight: 800; letter-spacing: -0.02em; }
  .fb-card { border: 1px solid var(--border); border-radius: 16px; padding: 28px; background: #fff; min-width: 0; }
  .fb-label { margin: 0 0 8px; font-size: 20px; font-weight: 700; letter-spacing: 0; }
  .fb-label-hint { font-size: 14px; font-weight: 400; color: var(--gray); }
  /* Ошибка до первых данных сборки: пустым разделам нечего показать. */
  .fb-page.fb-no-data > .fb-block, .fb-page.fb-no-data > .fb-columns { display: none; }
  .fb-hero { display: flex; flex-direction: column; gap: 8px; }
  .fb-columns { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
  .fb-col-report { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
  .fb-col-evidence { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
  .fb-board-frame {
    position: relative; aspect-ratio: 4 / 3; margin-top: 4px; border: 1px solid var(--grid-line); border-radius: 12px; overflow: hidden;
    background-color: var(--canvas-bg); background-size: 8px 8px;
    background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  }
  .fb-board-frame.zoomable { cursor: zoom-in; }
  .fb-board-frame.zoomable:hover { border-color: var(--gray); }
  /* Кольцо фокуса — только для клавиатуры: после клика мышью оно читается как «выделено». */
  .fb-board-frame:focus { outline: none; }
  .fb-board-frame:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .fb-board-frame.empty { background: var(--panel-bg); }
  .fb-board-modal {
    position: fixed; inset: 0; z-index: 20; background: rgba(31, 36, 48, 0.55);
    display: flex; align-items: center; justify-content: center; padding: 40px;
  }
  .fb-board-modal.hidden { display: none; }
  #feedback-board-full {
    width: 100%; height: 100%; max-width: 1400px; background: #fff;
    border-radius: 10px; padding: 16px;
  }
  .fb-board-close {
    position: absolute; top: 16px; right: 20px; width: 32px; height: 32px; border-radius: 6px;
    border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 14px; line-height: 1;
  }
  #feedback-board { width: 100%; height: 100%; }
  .svg-defs { position: absolute; width: 0; height: 0; }
  .feedback-empty {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: var(--gray);
  }

  .feedback-topic { font-size: 15px; color: #5b6170; }

  /* Ожидание: что произошло, сколько обычно ждать, сколько уже идёт. */
  .feedback-building-title { font-size: 20px; font-weight: 700; }
  .feedback-building-note { margin-top: 4px; font-size: 15px; color: var(--graphite); line-height: 1.5; }
  .feedback-building-bar {
    margin-top: 12px; max-width: 320px; height: 3px; border-radius: 2px; background: #e9ecf1; overflow: hidden;
  }
  /* Бегущая полоса, а не проценты: сколько осталось, мы честно не знаем. */
  .feedback-building-fill {
    width: 35%; height: 100%; border-radius: 2px; background: var(--accent);
    animation: feedback-indeterminate 1.6s ease-in-out infinite;
  }
  @keyframes feedback-indeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(320%); }
  }
  .feedback-elapsed { margin-top: 6px; font-size: 13px; color: var(--gray); font-variant-numeric: tabular-nums; }
  .feedback-error {
    padding: 12px 14px; border-radius: 10px; background: #fdf0ee; max-width: 80ch;
    font-size: 15px; line-height: 1.5; color: var(--danger);
  }

  .skeleton {
    position: relative; overflow: hidden; border-radius: 4px; background: #e9ecf1; color: transparent;
  }
  .skeleton::after {
    content: ""; position: absolute; inset: 0; transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
    animation: feedback-shimmer 1.4s infinite;
  }
  @keyframes feedback-shimmer { 100% { transform: translateX(100%); } }
  .skeleton-line { height: 14px; margin: 8px 0; }
  .skeleton-line:last-child { width: 70%; }
  .skeleton-card { height: 86px; margin: 12px 0; }
  .skeleton-score { display: inline-block; width: 40px; height: 15px; justify-self: end; }

  .feedback-verdict { display: flex; flex-direction: column; gap: 8px; }
  .feedback-verdict-level { font-size: 44px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
  .feedback-verdict-reason { max-width: 80ch; font-size: 16px; line-height: 1.5; color: var(--graphite); }

  /* Ось — строка: название, полоса, балл, под ними комментарий. */
  .feedback-axis {
    display: grid; grid-template-columns: 240px 1fr 56px; gap: 6px 20px; align-items: center;
    padding: 12px 0; border-top: 1px solid var(--grid-line);
  }
  .feedback-axis-name { font-size: 15px; font-weight: 600; }
  .feedback-axis-track { height: 6px; border-radius: 3px; background: #f0f1f4; overflow: hidden; }
  .feedback-axis-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.4s ease; }
  .feedback-axis-score { font-size: 15px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
  .feedback-axis.no-data .feedback-axis-score { grid-column: 2 / -1; text-align: left; font-size: 14px; font-weight: 400; color: var(--gray); }
  .feedback-axis-comment { grid-column: 2 / -1; font-size: 14px; line-height: 1.45; color: #5b6170; }
  .feedback-axis-comment:empty { display: none; }

  /* Ход интервью: доступен сразу и объясняет ось «нет данных» — видно, где интервью остановилось. */
  .feedback-stage {
    display: grid; grid-template-columns: 16px 1fr auto; align-items: baseline; gap: 2px 10px;
    padding: 7px 0; font-size: 14px;
  }
  .feedback-stage-mark { color: var(--gray); font-weight: 700; }
  .feedback-stage-mark.passed, .feedback-stage-mark.forced { color: var(--accent); }
  .feedback-stage-time { font-size: 13px; color: #5b6170; font-variant-numeric: tabular-nums; }
  .feedback-stage-time.over { color: var(--danger); font-weight: 600; }
  .feedback-stage-note { grid-column: 2 / -1; font-size: 13px; color: var(--gray); }
  .feedback-stage.unreached { opacity: 0.5; }

  .feedback-failure {
    display: flex; flex-direction: column; gap: 6px; padding: 16px 0; border-top: 1px solid var(--grid-line);
    font-size: 15px; line-height: 1.5;
  }
  .feedback-failure:last-child { padding-bottom: 0; }
  .feedback-failure-stage { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gray); }
  .feedback-failure-stage:empty { display: none; }
  .feedback-failure-quote { font-style: italic; color: var(--graphite); }
  .feedback-failure-better { color: var(--accent-ink); }
  .feedback-strength { margin-top: 4px; font-size: 15px; line-height: 1.55; }

  #feedback-uncovered ul, #feedback-decisions ul { margin: 0; padding: 0; list-style: none; font-size: 15px; line-height: 1.5; }
  #feedback-uncovered li, #feedback-decisions li { padding: 10px 0; border-top: 1px solid var(--grid-line); }
  #feedback-uncovered li:last-child, #feedback-decisions li:last-child { padding-bottom: 0; }
  #feedback-uncovered li { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: space-between; }
  .feedback-task-stage { font-size: 13px; color: var(--gray); }

  @media (max-width: 720px) {
    .fb-page { padding: 32px 16px 48px; }
    .fb-title h1 { font-size: 28px; }
    .fb-card { padding: 20px; }
    .feedback-verdict-level { font-size: 36px; }
    .feedback-axis { grid-template-columns: 1fr auto; }
    .feedback-axis-track { grid-column: 1 / -1; grid-row: 2; }
    .feedback-axis-comment { grid-column: 1 / -1; }
    .feedback-axis.no-data .feedback-axis-score { grid-column: 2; text-align: right; }
  }
