/* Procavio design system. Dark chrome, light paper canvas, industrial accent. */

:root {
    --accent: #e8862e;
    --accent-soft: rgba(232, 134, 46, 0.14);
    --paper: #fafaf7;
    --paper-dot: #d9d9d2;
    --radius: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html[data-theme='dark'] {
    --bg: #15171b;
    --panel: #1c1f25;
    --panel-2: #22262e;
    --border: #2e333d;
    --text: #e9ebef;
    --muted: #8b93a1;
    --hover: rgba(255, 255, 255, 0.06);
}

html[data-theme='light'] {
    --bg: #f2f2ee;
    --panel: #ffffff;
    --panel-2: #f6f6f3;
    --border: #ddddd6;
    --text: #1d2129;
    --muted: #6b7280;
    --hover: rgba(0, 0, 0, 0.05);
    --shadow: 0 8px 28px rgba(30, 30, 20, 0.12);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: var(--font);
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---- Top bar ---- */

.topbar {
    height: 52px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 14px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    user-select: none;
}

.brand-mark {
    width: 22px;
    height: 22px;
}

.brand-mark rect { fill: var(--accent); }
.brand-mark .stroke { stroke: var(--accent); stroke-width: 2; fill: none; }

.brand-name {
    font-size: 15px;
    font-weight: 650;
    letter-spacing: 0.01em;
}

.doc-meta {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.doc-title {
    font: 500 14px var(--font);
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 5px 8px;
    min-width: 60px;
    max-width: 46vw;
    width: 100%;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.doc-title:hover { background: var(--hover); }
.doc-title:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--panel-2);
}

.save-state {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    transition: color 0.2s;
}

.save-state[data-state='saving'] { color: var(--accent); }

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

.btn {
    font: 500 12.5px var(--font);
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 7px 13px;
    cursor: pointer;
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
}

.btn:hover { background: var(--hover); border-color: var(--muted); }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #171310;
    font-weight: 600;
}

.btn-primary:hover { background: #f09542; border-color: #f09542; }

.btn-icon {
    padding: 6px;
    display: inline-flex;
    line-height: 1;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--muted);
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
}

html[data-theme='dark'] .icon-moon { display: none; }
html[data-theme='light'] .icon-sun { display: none; }

/* ---- Export menu ---- */

.menu-wrap { position: relative; }

.menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 5px;
    min-width: 190px;
    z-index: 60;
}

.menu button {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 18px;
    width: 100%;
    text-align: left;
    font: 500 12.5px var(--font);
    color: var(--text);
    background: none;
    border: 0;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
}

.menu button:hover { background: var(--hover); }
.menu button span { color: var(--muted); font-size: 11px; }

/* ---- Workspace ---- */

.workspace {
    flex: 1;
    display: flex;
    min-height: 0;
}

.library {
    flex: 0 0 236px;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-right: 1px solid var(--border);
}

.library-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 14px 14px 8px;
}

.library-head h2 {
    margin: 0;
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
}

.library-count { font-size: 11px; color: var(--muted); }

.library-list {
    list-style: none;
    margin: 0;
    padding: 4px 8px;
    overflow-y: auto;
    flex: 1;
}

.library-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius);
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.12s var(--ease);
}

.library-list li:hover { background: var(--hover); }
.library-list li.active {
    background: var(--accent-soft);
}

.library-list .li-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.library-list li.active .li-name { color: var(--accent); }

.library-list .li-date {
    font-size: 10.5px;
    color: var(--muted);
    white-space: nowrap;
}

.li-actions {
    display: none;
    gap: 2px;
}

.library-list li:hover .li-actions { display: inline-flex; }
.library-list li:hover .li-date { display: none; }

.li-actions button {
    font-size: 11px;
    border: 0;
    background: none;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
}

.li-actions button:hover { color: var(--text); background: var(--hover); }

.library-foot {
    padding: 10px 14px 12px;
    border-top: 1px solid var(--border);
}

.library-foot p {
    margin: 0;
    font-size: 11px;
    line-height: 1.5;
    color: var(--muted);
}

/* ---- Stage / canvas ---- */

.stage {
    flex: 1;
    position: relative;
    min-width: 0;
}

.canvas {
    position: absolute;
    inset: 0;
    background-color: var(--paper);
    background-image: radial-gradient(var(--paper-dot) 1px, transparent 1px);
    background-size: 20px 20px;
}

.drop-hint {
    position: absolute;
    inset: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--accent);
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 15px;
    font-weight: 600;
    pointer-events: none;
    z-index: 50;
}

.zoombar {
    position: absolute;
    right: 108px;
    bottom: 16px;
    display: flex;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 40;
}

.zbtn {
    font: 500 13px var(--font);
    color: var(--text);
    background: none;
    border: 0;
    padding: 7px 11px;
    cursor: pointer;
}

.zbtn:hover { background: var(--hover); }
.zpct { min-width: 52px; font-size: 11.5px; color: var(--muted); }
.zfit { border-left: 1px solid var(--border); font-size: 11.5px; }

/* ---- Properties panel ---- */

.props {
    flex: 0 0 264px;
    background: var(--panel);
    border-left: 1px solid var(--border);
    padding: 14px;
    overflow-y: auto;
}

.props-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.props-head h2 {
    margin: 0;
    font-size: 12px;
    font-weight: 650;
}

.field {
    display: block;
    margin-bottom: 14px;
}

.field span {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 5px;
}

.field input,
.field textarea {
    width: 100%;
    font: 400 12.5px var(--font);
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 9px;
    resize: vertical;
}

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

.props-id {
    font-size: 10.5px;
    color: var(--muted);
    word-break: break-all;
}

/* ---- Status bar ---- */

.statusbar {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 14px;
    font-size: 11px;
    color: var(--muted);
    background: var(--panel);
    border-top: 1px solid var(--border);
}

/* ---- alignment toolbar ---- */

.alignbar {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 4px;
    z-index: 45;
}

.alignbar button {
    font-size: 14px;
    color: var(--text);
    background: none;
    border: 0;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
}

.alignbar button:hover { background: var(--hover); }
.alignbar button:disabled { opacity: 0.35; cursor: default; }
.alignbar-sep { width: 1px; height: 16px; background: var(--border); margin: 0 3px; }

/* ---- color swatches ---- */

.swatches { display: flex; gap: 6px; }

.swatch {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid;
    cursor: pointer;
    padding: 0;
    transition: transform 0.1s var(--ease);
}

.swatch:hover { transform: scale(1.15); }

.swatch-clear {
    background:
        linear-gradient(to top right, transparent 44%, #c33 46%, #c33 54%, transparent 56%),
        var(--panel-2) !important;
}

/* ---- XML drawer ---- */

.drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 46vh;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 34px rgba(0, 0, 0, 0.3);
    z-index: 70;
}

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
}

.drawer-head h2 { margin: 0; font-size: 13px; }
.drawer-actions { display: flex; gap: 8px; }

#xml-text {
    flex: 1;
    margin: 0 14px 14px;
    font: 12px/1.5 ui-monospace, 'SF Mono', Menlo, monospace;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    resize: none;
    white-space: pre;
}

#xml-text:focus { outline: none; border-color: var(--accent); }

/* ---- shortcuts modal ---- */

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    z-index: 80;
}

.modal-card {
    width: 340px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 6px 14px 14px;
}

.kbd-table { width: 100%; border-collapse: collapse; }
.kbd-table td { padding: 5px 4px; font-size: 12px; }
.kbd-table td:first-child { width: 45%; color: var(--muted); }

kbd {
    font: 11px var(--font);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 5px;
}

.linklike {
    font: inherit;
    color: var(--muted);
    background: none;
    border: 0;
    cursor: pointer;
    padding: 0;
    margin-right: 14px;
}

.linklike:hover { color: var(--text); }

.statusbar-right { display: inline-flex; align-items: center; }

/* ---- bpmn-js chrome fit ---- */

.djs-palette {
    background: #ffffff;
    border: 1px solid #ddddd6 !important;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(30, 30, 20, 0.1);
    top: 16px;
    left: 16px;
}

.djs-context-pad .entry,
.djs-palette .entry { color: #333; }

.bjs-powered-by { opacity: 0.55; }

.djs-minimap {
    border: 1px solid #ddddd6;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(30, 30, 20, 0.1);
    overflow: hidden;
    top: 16px;
    right: 16px;
}

.djs-minimap .toggle {
    font: 500 11.5px var(--font);
    color: #555;
    padding: 6px 10px;
}

.bjsl-button {
    font-family: var(--font);
    font-size: 12px;
    border-radius: 8px;
    bottom: 16px;
    left: 16px;
    transform: none;
}

/* ---- Small screens ---- */

@media (max-width: 860px) {
    .library { display: none; }
    .props { position: absolute; right: 0; top: 52px; bottom: 30px; z-index: 55; }
    .statusbar span:first-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
