/* ─── Design tokens ──────────────────────────────────────────────────
 * All colours, sizes, and timings live as CSS variables on :root.
 * Pages reference these by name; the constants below are the only
 * place the palette is defined.
 */

:root {
    --bg-color: #0d0d12;
    --pane-bg: #16161e;
    --border-color: #2a2a35;
    --text-primary: #e0e0e6;
    --text-secondary: #8c8c9e;
    --accent-color: #4f4f66;
    --accent-hover: #5f5f7a;
    --drawer-width: 22rem;
    --source-pane-width: 28rem;
    --source-pane-min: 18rem;
    --source-pane-max: 48rem;
    --action-primary: #f2b84b;
    --action-primary-hover: #ffc861;
    --action-blue: #4d83c6;
    --action-blue-hover: #5c93d7;
    --action-danger: #b85b5b;
    --action-danger-hover: #c86b6b;
    --focus-ring: rgba(255, 255, 255, 0.1);
    --font-family: 'Inter', sans-serif;
}

/* ─── Reset & base ─────────────────────────────────────────────────── */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    height: 100vh;
    overflow: hidden;
}

/* ─── App shell (Account / Subscription pages) ─────────────────────── */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-header {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--pane-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
}

.header-brand {
    min-width: 0;
}

.brand-link {
    text-decoration: none;
    color: inherit;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-icon {
    width: 3rem;
    height: 3rem;
    display: inline-block;
    flex-shrink: 0;
}

.brand-icon--lg {
    width: 3.8rem;
    height: 3.8rem;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.nav-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: #1a1a24;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    text-decoration: none;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.nav-chip:hover {
    color: var(--text-primary);
    border-color: var(--accent-hover);
    background: #222230;
}

.nav-chip--button {
    cursor: pointer;
}

.page-main {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1.5rem;
}

.page-card {
    width: 100%;
    max-width: 420px;
    background: var(--pane-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-card h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.page-hint {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.page-status {
    margin-top: 1rem;
    max-width: 420px;
    width: 100%;
}

.button-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.button-row .inline-primary,
.button-row .secondary-btn {
    flex: 1;
    min-width: 7rem;
}

.full-width {
    width: 100%;
}

.ghost-btn {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
}

.ghost-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-hover);
}

.text-link {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.hidden {
    display: none !important;
}

.ghost-btn.is-disabled,
.ghost-btn[disabled],
.primary-btn[disabled],
.secondary-btn[disabled] {
    color: #5d5d68;
    cursor: not-allowed;
    opacity: 0.55;
}

.ghost-btn.is-disabled:hover,
.ghost-btn[disabled]:hover,
.primary-btn[disabled]:hover,
.secondary-btn[disabled]:hover {
    background: transparent;
    border-color: var(--border-color);
}

.auth-pane {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-toggle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

.text-link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    font: inherit;
}

.text-link-btn:hover {
    color: var(--accent-hover);
}

/* ─── Workspace shell (Extractor page) ───────────────────────────────
 * The Extractor uses a 3-pane layout: command bar, source editor,
 * graph canvas, with the evidence drawer overlay positioned
 * absolutely on the right. The classes below are the contract
 * that `extractor.js` mutates at runtime (e.g. `is-inspector-open`).
 */

.split-pane {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.left-pane {
    width: 32%;
    min-width: 280px;
    max-width: 380px;
    border-right: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: var(--bg-color);
    overflow-y: auto;
}

.right-pane {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    grid-template-rows: auto minmax(0, 1fr);
    background-color: var(--pane-bg);
    position: relative;
    min-width: 0;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flex-fill {
    flex: 1;
}

label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="url"],
input[type="email"],
input[type="text"],
input[type="password"],
select,
input[type="file"],
textarea {
    background-color: #1a1a24;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 0.75rem;
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

input[type="file"] {
    padding: 0.5rem;
    font-size: 0.85rem;
}

textarea {
    resize: none;
    flex: 1;
    min-height: 150px;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-hover);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.url-bar {
    display: flex;
    gap: 0.5rem;
}

.url-bar input {
    flex: 1;
}

button {
    background-color: var(--accent-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

button:hover {
    background-color: var(--accent-hover);
}

button:active {
    transform: scale(0.98);
}

.primary-btn {
    background-color: #2b2b36;
    border-color: #3b3b4a;
    width: 100%;
    margin-top: auto;
}

.inline-primary {
    width: auto;
    margin-top: 0;
}

.button-row .primary-btn,
.button-row .secondary-btn {
    margin-top: 0;
}

.primary-btn:hover {
    background-color: #3b3b4a;
}

.secondary-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    background-color: transparent;
}

.status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    min-height: 1.2em;
}

.graph-toolbar {
    grid-column: 1 / -1;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(22, 22, 30, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10;
}

.graph-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

#graph-container {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    width: 100%;
    position: relative;
    outline: none;
}

#graph-container .vis-network {
    width: 100%;
    height: 100%;
    outline: none;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 0;
}

.inspector-muted {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
}

/* review-list / review-item removed — graph editor no longer surfaces
 * low-confidence review rows. Inspector is now a pure action panel. */

/* ─── Command bar ──────────────────────────────────────────────────── */

.workspace-shell {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #0f0f12;
    color: var(--text-primary);
}

.command-bar {
    height: 3.45rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid #303035;
    background: #202020;
}

.workspace-brand {
    color: #f0f0f2;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.workspace-menus,
.workspace-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.menu-shell {
    position: relative;
}

.menu-trigger,
.menu-item,
.command-primary,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.menu-trigger {
    height: 2rem;
    padding: 0 0.65rem;
    color: #c5c5cb;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
}

.menu-trigger:hover,
.menu-trigger.is-active {
    color: #f2f2f5;
    background: #2a2a2f;
    border-color: #393941;
}

.menu-trigger svg,
.menu-item svg,
.command-primary svg,
.icon-btn svg {
    width: 1rem;
    height: 1rem;
    stroke-width: 2;
}

.menu-popover {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    z-index: 40;
    width: 17rem;
    padding: 0.45rem;
    border: 1px solid #34343a;
    border-radius: 8px;
    background: #1d1d22;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
}

.menu-item {
    width: 100%;
    min-height: 2.15rem;
    padding: 0.45rem 0.55rem;
    justify-content: flex-start;
    color: #dedee4;
    background: transparent;
    border-color: transparent;
    border-radius: 6px;
    font-size: 0.82rem;
}

.menu-item:hover {
    background: #2a2a30;
}

.menu-item.is-disabled,
.menu-item[disabled] {
    color: #5d5d68;
    cursor: not-allowed;
    opacity: 0.55;
}

.menu-item.is-disabled:hover,
.menu-item[disabled]:hover {
    background: transparent;
}

.menu-item .menu-item-label {
    flex: 1;
    text-align: left;
}

.menu-item-tag {
    margin-left: auto;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: rgba(77, 131, 198, 0.18);
    color: #6f9ad4;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.menu-fields {
    display: grid;
    gap: 0.4rem;
    padding: 0.45rem 0.2rem;
    border-top: 1px solid #303038;
    border-bottom: 1px solid #303038;
    margin: 0.35rem 0;
}

.menu-fields label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.menu-fields input {
    width: 100%;
    height: 2.1rem;
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
}

.menu-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
}

.menu-actions--stack {
    grid-template-columns: 1fr;
}

.menu-divider {
    height: 1px;
    margin: 0.4rem 0.2rem;
    background: #34343a;
}

.menu-item-shell {
    position: relative;
    min-width: 0;
}

.menu-item--with-popover {
    width: 100%;
    min-height: 2.15rem;
    padding-right: 0.55rem;
}

.menu-item-chevron {
    margin-left: 0.35rem;
    width: 0.85rem;
    height: 0.85rem;
    color: #8f8f98;
}

.menu-item--with-popover[aria-expanded="true"] {
    background: #2a2a30;
    color: #f2f2f5;
}

/* Right-anchored submenu that opens when the user hovers/clicks
 * the Load button. Positioned relative to the menu-item-shell so
 * the arrow on the left edge of the popover can point back at the
 * trigger row. The :not([hidden]) gate keeps the `display: flex`
 * layout from overriding the `hidden` attribute — without it the
 * popover shell would render as an empty box every time the
 * File menu is opened, occluding the View trigger and the
 * source-pane resizer. */
.menu-popover--right:not([hidden]) {
    position: absolute;
    top: 0;
    left: calc(100% + 6px);
    width: 18rem;
    z-index: 45;
    padding: 0.45rem;
    border: 1px solid #34343a;
    border-radius: 8px;
    background: #1d1d22;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.menu-popover--right::before {
    content: "";
    position: absolute;
    top: 0.85rem;
    left: -6px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid #34343a;
}

.menu-popover--right::after {
    content: "";
    position: absolute;
    top: 0.88rem;
    left: -5px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid #1d1d22;
}

.popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.15rem 0.25rem 0.25rem;
    border-bottom: 1px solid #303038;
    margin-bottom: 0.15rem;
}

.popover-kicker {
    color: #b5b5bc;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.popover-header .icon-btn {
    width: 1.6rem;
    height: 1.6rem;
}

.popover-search {
    width: 100%;
    height: 1.95rem;
    padding: 0.35rem 0.55rem;
    border-radius: 5px;
    border-color: #34343a;
    background: #151519;
    color: #f0f0f4;
    font-size: 0.82rem;
}

.popover-search::placeholder {
    color: #777780;
}

.popover-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 16rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.popover-row {
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.55rem;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: #dedee4;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.82rem;
    line-height: 1.25;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.popover-row:hover,
.popover-row:focus-visible {
    background: rgba(77, 131, 198, 0.16);
    border-color: var(--action-blue);
    color: #ffffff;
    outline: none;
}

.popover-row-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popover-row-meta {
    font-size: 0.7rem;
    color: #8c8c9e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popover-row:hover .popover-row-meta,
.popover-row:focus-visible .popover-row-meta {
    color: #c2d2e6;
}

.popover-empty,
.popover-status {
    padding: 0.5rem 0.55rem;
    font-size: 0.78rem;
    color: #8c8c9e;
}

.popover-status[data-state="error"] {
    color: #ff8d8d;
}

.command-spacer {
    flex: 1;
}

.command-primary {
    height: 2.15rem;
    padding: 0 0.85rem;
    border-color: #ffd47a;
    color: #101014;
    background: var(--action-primary);
    border-radius: 6px;
    font-weight: 700;
}

.command-primary:hover {
    background: var(--action-primary-hover);
    border-color: #ffdd91;
}

.command-primary:disabled {
    color: #4a4030;
    cursor: not-allowed;
    opacity: 0.78;
    background: #3a3022;
    border-color: #4a4030;
}

.command-primary-tag {
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: rgba(16, 16, 20, 0.25);
    color: inherit;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.command-primary:disabled .command-primary-tag {
    background: rgba(242, 184, 75, 0.15);
    color: #b58a4a;
}

.command-bar .nav-chip {
    height: 2.15rem;
    padding: 0 0.85rem;
    border-radius: 999px;
    background: #1b1b21;
}

.nav-chip--upgrade {
    position: relative;
    background-image: linear-gradient(90deg, rgba(255, 0, 128, 0.08), rgba(255, 153, 0, 0.08), rgba(51, 204, 51, 0.08), rgba(0, 153, 255, 0.08), rgba(153, 51, 255, 0.08)) !important;
    border: 1px solid transparent !important;
    color: rgba(224, 224, 230, 0.55) !important;
    opacity: 0.5;
    cursor: not-allowed !important;
    gap: 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-chip--upgrade::before {
    content: "";
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background-image: linear-gradient(90deg, #ff007f, #ffaa00, #00ff66, #00aaff, #aa00ff);
    border-radius: 999px;
    z-index: -1;
    opacity: 0.45;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: xor;
    padding: 1px;
}

.nav-chip-tag {
    margin-left: 0.35rem;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1;
}

.upgrade-icon {
    display: inline-block;
    flex-shrink: 0;
    opacity: 0.8;
}

.popover-row-container {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
    padding: 0 0.25rem;
}

.popover-row-container .popover-row {
    flex: 1;
    min-width: 0;
}

.popover-row-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    padding: 0;
    border-radius: 4px;
    border: 1px solid transparent;
    background: transparent;
    color: #8c8c9e;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.popover-row-action:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.popover-row-action--danger:hover {
    color: #ff8d8d;
    background: rgba(184, 91, 91, 0.15);
    border-color: rgba(184, 91, 91, 0.25);
}


.workspace-main {
    position: relative;
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: clamp(var(--source-pane-min), var(--source-pane-width), var(--source-pane-max)) minmax(0, 1fr);
    overflow: hidden;
    transition: grid-template-columns 0.18s ease;
}

.source-pane {
    min-width: 0;
    min-height: 0;
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border-right: 1px solid #303035;
    background: #202020;
}

.source-pane .resizer {
    position: absolute;
    top: 0;
    right: -3px;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 5;
    background: transparent;
    transition: background 0.15s ease;
}

.source-pane .resizer::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: transparent;
    transition: background 0.15s ease;
}

.source-pane .resizer:hover::after,
.source-pane .resizer.is-dragging::after {
    background: var(--action-blue);
}

.workspace-main.is-resizing {
    cursor: col-resize;
    user-select: none;
}

.source-toolbar {
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid #303035;
}

.panel-kicker,
.source-mode {
    color: #b5b5bc;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.source-mode {
    color: #8f8f98;
}

.source-pane .source-editor:disabled {
    color: #9a9aa4;
    background: #1d1d1d;
    cursor: not-allowed;
}

.source-pane .source-editor:disabled::placeholder {
    color: #b58a4a;
    font-style: italic;
}

.source-editor-wrap {
    min-height: 0;
    display: grid;
    grid-template-columns: 3rem minmax(0, 1fr);
    overflow: hidden;
    background: #1f1f1f;
}

.line-numbers,
.source-editor {
    margin: 0;
    border: 0;
    border-radius: 0;
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: 0.94rem;
    line-height: 1.55;
}

.line-numbers {
    padding: 0.85rem 0.7rem;
    color: #8e8e94;
    text-align: right;
    background: #1b1b1d;
    border-right: 1px solid #34343a;
    overflow: hidden;
    user-select: none;
}

.source-editor {
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0.85rem 1rem;
    resize: none;
    color: #f0f0f4;
    background: #1f1f1f;
    outline: none;
    box-shadow: none;
}

.source-editor:focus {
    border-color: transparent;
    box-shadow: none;
}

.source-editor::placeholder {
    color: #777780;
}

.editor-status-bar {
    min-height: 2.15rem;
    display: flex;
    align-items: center;
    padding: 0.45rem 1rem;
    border-top: 1px solid #303035;
    background: #202020;
}

.editor-status-bar .status {
    min-height: 0;
    color: #b5b5c4;
    text-align: left;
    line-height: 1.35;
}

.canvas-pane {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background-color: #111113;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 128px 128px, 128px 128px, 32px 32px, 32px 32px;
}

.graph-canvas {
    width: 100%;
    height: 100%;
    position: relative;
    outline: none;
}

.graph-canvas .vis-network {
    width: 100%;
    height: 100%;
    outline: none;
}

.canvas-pane .empty-state {
    color: #8e8e98;
}

/* ─── Floating graph toolbar ─────────────────────────────────────────
 * Anchored bottom-centre over the canvas. Shifts left by half the
 * drawer width when the inspector is open; the `transition: left`
 * matches the drawer's `transition: transform`.
 */

.floating-graph-toolbar {
    position: absolute;
    left: 50%;
    bottom: 1rem;
    z-index: 20;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.35rem;
    padding: 0.45rem;
    border: 1px solid #34343a;
    border-radius: 8px;
    background: rgba(29, 29, 34, 0.94);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
    transition: left 0.18s ease;
    max-width: calc(100% - 1.5rem);
    overflow-x: auto;
    scrollbar-width: none;
}
.floating-graph-toolbar::-webkit-scrollbar {
    display: none;
}

.workspace-main.is-inspector-open .floating-graph-toolbar {
    left: calc(50% - (var(--drawer-width) / 2));
}

.icon-btn {
    width: 2.15rem;
    height: 2.15rem;
    padding: 0;
    color: #d5d5dc;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    flex-shrink: 0;
}

.icon-btn:hover {
    color: #ffffff;
    background: #2b2b31;
    border-color: rgba(255, 255, 255, 0.12);
}

.tool-btn {
    height: 2.15rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0 0.65rem;
    color: #dedee4;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 650;
    white-space: nowrap;
    flex-shrink: 0;
}

.tool-btn svg {
    width: 1rem;
    height: 1rem;
    stroke-width: 2;
}

.tool-btn--edit {
    color: #dbe8f7;
}

.tool-btn--edit:hover {
    color: #ffffff;
    background: rgba(77, 131, 198, 0.18);
    border-color: var(--action-blue);
}

.tool-btn--danger {
    color: #f0d5d5;
}

.tool-btn--danger:hover {
    color: #ffffff;
    background: rgba(184, 91, 91, 0.2);
    border-color: var(--action-danger);
}

.tool-btn:disabled,
.tool-btn[disabled] {
    color: #5d5d68;
    cursor: not-allowed;
    opacity: 0.55;
}

.tool-btn:disabled:hover,
.tool-btn[disabled]:hover {
    color: #5d5d68;
    background: transparent;
    border-color: transparent;
}

.floating-graph-toolbar[data-armed="edit"] #btn-edit-selected,
.floating-graph-toolbar[data-armed="delete"] #btn-delete-selected {
    color: #ffffff;
    background: rgba(242, 184, 75, 0.22);
    border-color: var(--action-primary);
    box-shadow: 0 0 0 2px rgba(242, 184, 75, 0.35);
}

.canvas-pane.is-edit-armed .vis-network,
.canvas-pane.is-edit-armed .vis-overlay {
    cursor: crosshair;
}

.canvas-pane.is-delete-armed .vis-network,
.canvas-pane.is-delete-armed .vis-overlay {
    cursor: not-allowed;
}

.edge-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    margin-left: -9px;
    margin-top: -9px;
    border-radius: 50%;
    border: 1px solid var(--action-blue);
    background: #1d1d22;
    color: var(--action-blue);
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    cursor: crosshair;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.edge-handle:hover,
.edge-handle:focus-visible {
    background: var(--action-blue);
    color: #ffffff;
    transform: scale(1.15);
    outline: none;
}

.edge-handle[hidden] {
    display: none;
}

.edge-ghost {
    position: absolute;
    pointer-events: none;
    z-index: 15;
    overflow: visible;
}

.edge-ghost[hidden] {
    display: none;
}

.canvas-pane.is-connecting {
    cursor: crosshair;
}

.toast-stack {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    z-index: 80;
    pointer-events: none;
}

.toast {
    min-width: 12rem;
    max-width: 22rem;
    padding: 0.55rem 0.85rem;
    background: #2b2b36;
    color: #f2f2f5;
    border: 1px solid #4f4f66;
    border-radius: 8px;
    font-size: 0.82rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(8px);
    animation: toast-in 180ms ease-out forwards, toast-out 220ms ease-in 2.28s forwards;
    pointer-events: auto;
}

.toast[data-state="error"] {
    border-color: var(--action-danger);
    color: #ffd9d9;
}

.toast[data-state="success"] {
    border-color: #5fb37a;
    color: #d6f3df;
}

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

@keyframes toast-out {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-4px); }
}

.empty-state-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% + 3rem));
    color: #a8a8b2;
    font-size: 0.95rem;
    text-align: center;
    pointer-events: none;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    animation: empty-hint-fade 600ms ease-out;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.empty-state-hint kbd {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    margin: 0 0.15rem;
    background: #2b2b36;
    border: 1px solid #4f4f66;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.78rem;
    color: #dedee4;
}

@keyframes empty-hint-fade {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.toolbar-divider {
    width: 1px;
    height: 1.45rem;
    margin: 0 0.25rem;
    background: #3a3a42;
    flex-shrink: 0;
}

.graph-search {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.55rem;
    height: 1.75rem;
    background: #1f1f29;
    border: 1px solid #2f2f3a;
    border-radius: 0.5rem;
    color: #8c8c9e;
    transition: border-color 120ms ease;
    flex-shrink: 0;
}
.graph-search:focus-within {
    border-color: #6f6f8a;
}
.graph-search input {
    border: 0;
    outline: 0;
    background: transparent;
    color: #e0e0e6;
    font: inherit;
    font-size: 0.8rem;
    width: 11rem;
}
.graph-search input::placeholder {
    color: #6c6c7a;
}
.graph-search input::-webkit-search-cancel-button {
    filter: invert(0.7);
    cursor: pointer;
}

.context-menu {
    position: absolute;
    min-width: 11rem;
    background: #23232e;
    border: 1px solid #3a3a42;
    border-radius: 0.5rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    padding: 0.3rem;
    z-index: 9999;
    font-size: 0.85rem;
    color: #e0e0e6;
    user-select: none;
}
.context-menu[hidden] {
    display: none;
}
.context-menu button {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: 0;
    border-radius: 0.4rem;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.context-menu button:hover:not([disabled]) {
    background: #2f2f3a;
}
.context-menu button[disabled] {
    color: #6c6c7a;
    cursor: not-allowed;
}
.context-menu .context-divider {
    height: 1px;
    margin: 0.3rem 0.2rem;
    background: #3a3a42;
}
.context-menu .context-danger {
    color: #f87171;
}

/* ─── Inspector pane ─────────────────────────────────────────────────
 * Hidden by default (`is-collapsed` class). `extractor.js` toggles
 * the class and updates `aria-hidden` on the host element.
 */

.inspector-pane {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    width: min(var(--drawer-width), calc(100vw - 4rem));
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border-left: 1px solid #34343a;
    background: rgba(20, 20, 24, 0.98);
    box-shadow: -16px 0 34px rgba(0, 0, 0, 0.35);
    transform: translateX(0);
    transition: transform 0.18s ease;
}

.inspector-pane.is-collapsed {
    pointer-events: none;
    transform: translateX(calc(100% + 1px));
}

.workspace-main.is-source-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
}

.source-pane.is-collapsed {
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid #303038;
    margin-bottom: 0.85rem;
}

.drawer-header h2 {
    margin-top: 0.15rem;
    font-size: 1rem;
    font-weight: 650;
}

.drawer-section {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding-bottom: 0.85rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid #303038;
}

.drawer-section:last-child {
    border-bottom: 0;
    margin-bottom: 0;
    padding-bottom: 0;
    flex: 1;
    min-height: 0;
}

.drawer-section-label {
    color: #8c8c9e;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.drawer-stats {
    color: #d5d5dc;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.drawer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.drawer-actions--stack {
    flex-direction: column;
    align-items: stretch;
}

.drawer-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    height: 2rem;
    padding: 0 0.6rem;
    color: #dbe8f7;
    background: rgba(77, 131, 198, 0.12);
    border: 1px solid rgba(77, 131, 198, 0.4);
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.drawer-action:hover {
    color: #ffffff;
    background: rgba(77, 131, 198, 0.25);
    border-color: var(--action-blue);
}

.drawer-action:disabled,
.drawer-action[disabled] {
    color: #4d4d57;
    background: transparent;
    border-color: #2a2a35;
    cursor: not-allowed;
    opacity: 0.6;
}

.drawer-action--danger {
    color: #f0d5d5;
    background: rgba(184, 91, 91, 0.12);
    border-color: rgba(184, 91, 91, 0.4);
}

.drawer-action--danger:hover {
    color: #ffffff;
    background: rgba(184, 91, 91, 0.25);
    border-color: var(--action-danger);
}

.drawer-action svg {
    width: 0.95rem;
    height: 0.95rem;
    stroke-width: 2;
}

/* ─── Graph edit modal ─────────────────────────────────────────────── */

.graph-modal-backdrop {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(5, 5, 7, 0.52);
}

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

.graph-modal {
    width: min(28rem, 100%);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid #3a3a42;
    border-radius: 8px;
    background: #1d1d22;
    box-shadow: 0 20px 44px rgba(0, 0, 0, 0.42);
}

.graph-modal-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid #303038;
}

.graph-modal h2 {
    margin-top: 0.15rem;
    font-size: 1rem;
    font-weight: 650;
}

.graph-modal label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.graph-modal input {
    height: 2.45rem;
    border-color: #4b4b55;
    background: #151519;
}

.graph-modal input:focus {
    border-color: var(--action-blue);
    box-shadow: 0 0 0 2px rgba(77, 131, 198, 0.25);
}

.modal-helper {
    min-height: 1.1rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.graph-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0.35rem;
}

.modal-btn {
    height: 2.2rem;
    padding: 0 0.85rem;
    color: #dedee4;
    background: #27272d;
    border-color: #3a3a42;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 650;
}

.modal-btn:hover {
    color: #ffffff;
    background: #313139;
}

.modal-btn--primary {
    color: #101014;
    background: var(--action-primary);
    border-color: #ffd47a;
}

.modal-btn--primary:hover {
    background: var(--action-primary-hover);
    border-color: #ffdd91;
}

/* ─── Graph edit modal unified body ──────────────────────────────────── */

.graph-modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 45vh;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.graph-modal-body::-webkit-scrollbar {
    width: 6px;
}

.graph-modal-body::-webkit-scrollbar-track {
    background: #151519;
    border-radius: 3px;
}

.graph-modal-body::-webkit-scrollbar-thumb {
    background: #3a3a42;
    border-radius: 3px;
}

.style-section {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
}

.style-section:not([hidden]) {
    display: flex;
}

.style-fieldset {
    border: 1px solid #303038;
    border-radius: 6px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.style-fieldset legend {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    padding: 0 0.35rem;
}

.style-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.style-row label {
    min-width: 3.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: 0;
}

.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
}

.edge-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 0.5rem 0.4rem;
    background: #1c1c24;
    border: 1px dashed #3a3a42;
    border-radius: 6px;
}

.node-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    background: #1c1c24;
    border: 1px dashed #3a3a42;
    border-radius: 6px;
}

.node-preview-box {
    display: inline-block;
    min-width: 3.5rem;
    padding: 0.45rem 0.8rem;
    background: #2b2b36;
    border: 2px solid #4f4f66;
    border-radius: 4px;
    color: var(--text-primary, #e0e0e6);
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
}

.edge-preview-line {
    width: 80%;
    height: 0;
    border-top: 1.5px solid #4f4f66;
    position: relative;
}

.edge-preview-line::after {
    content: "";
    position: absolute;
    right: -1px;
    top: -4px;
    width: 0;
    height: 0;
    border-left: 6px solid #4f4f66;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}

.edge-preview-label {
    font-size: 0.7rem;
    color: #e0e0e6;
    letter-spacing: 0.02em;
}

.color-input-wrap input[type="color"] {
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid #3a3a42;
    border-radius: 4px;
    padding: 0;
    background: none;
    cursor: pointer;
}

.color-input-wrap input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input-wrap input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

.color-hex {
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 4.5rem;
    text-align: left;
}

.style-row input[type="range"] {
    flex: 1;
    height: 1.5rem;
    accent-color: var(--action-blue);
}

.size-value {
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 2.5rem;
    text-align: right;
}

.style-presets {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
}

.style-presets:not([hidden]) {
    display: flex;
}

.presets-label {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.preset-swatches {
    display: none;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.preset-swatches:not([hidden]) {
    display: flex;
}

.preset-swatch {
    width: 2rem;
    height: 2rem;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease;
    background-size: cover;
    background-position: center;
}

.preset-swatch:hover {
    transform: scale(1.1);
    border-color: var(--action-blue);
    z-index: 1;
}

.preset-swatch:focus-visible {
    outline: none;
    border-color: var(--action-blue);
    box-shadow: 0 0 0 2px rgba(77, 131, 198, 0.4);
}

/* ─── Responsive ─────────────────────────────────────────────────────
 * Single breakpoint at 900px collapses the 2-column workspace
 * into a stacked layout and hides the workspace link cluster to
 * make room for the command bar.
 */

@media (max-width: 900px) {
    .command-bar {
        gap: 0.5rem;
        padding: 0 0.75rem;
    }

    .workspace-main {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(13rem, 36vh) minmax(0, 1fr);
    }

    .source-pane {
        border-right: 0;
        border-bottom: 1px solid #303035;
    }

    .source-pane .resizer {
        display: none;
    }

    .menu-popover--right {
        display: none;
    }

    .workspace-links {
        display: none;
    }

    .floating-graph-toolbar {
        bottom: 0.75rem;
    }

    .workspace-main.is-inspector-open .floating-graph-toolbar {
        left: 50%;
    }
}
