:root {
    --bg: #060708;
    --bg-2: #0b0d10;
    --panel: rgba(16, 18, 22, 0.72);
    --panel-solid: #101318;
    --line: rgba(212, 177, 90, 0.14);
    --line-strong: rgba(232, 228, 216, 0.12);
    --gold: #d4b15a;
    --gold-2: #f0d48a;
    --gold-dim: rgba(212, 177, 90, 0.16);
    --mist: #9aa7a8;
    --text: #ece8dc;
    --muted: #8b8678;
    --danger: #c45c4a;
    --ok: #6faf7a;
    --warn: #c9a15b;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    --radius: 18px;
    --radius-sm: 10px;
    --blur: 22px;
    --font: "Manrope", system-ui, sans-serif;
    --display: "Syne", sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
    --sidebar: 248px;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    letter-spacing: 0.01em;
}

button, input, select, textarea {
    font-family: inherit;
    color: inherit;
}

button { cursor: pointer; }

.app {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
}

.app.visible { display: flex; }

.city-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(1200px 600px at 12% -10%, rgba(212, 177, 90, 0.08), transparent 55%),
        radial-gradient(900px 500px at 90% 110%, rgba(90, 140, 150, 0.08), transparent 50%),
        linear-gradient(180deg, #07080a 0%, #0a0c10 100%);
    z-index: 0;
}

.city-bg::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(212, 177, 90, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(212, 177, 90, 0.035) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: radial-gradient(ellipse at center, black 35%, transparent 80%);
    pointer-events: none;
}

.city-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 40%, rgba(212, 177, 90, 0.03) 50%, transparent 60%);
    animation: sweep 14s ease-in-out infinite;
    pointer-events: none;
}

@keyframes sweep {
    0%, 100% { transform: translateX(-12%); opacity: 0.3; }
    50% { transform: translateX(12%); opacity: 0.7; }
}

.shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
    width: min(1440px, calc(100% - 48px));
    height: min(900px, calc(100% - 48px));
    margin: auto;
    border: 1px solid var(--line);
    border-radius: 28px;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(12, 14, 18, 0.88), rgba(8, 9, 12, 0.92));
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(var(--blur));
}

.sidebar {
    border-right: 1px solid var(--line);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(16, 18, 22, 0.55), rgba(8, 9, 11, 0.2));
}

.brand {
    padding: 6px 10px 22px;
}

.brand-kicker {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.32em;
    color: var(--gold);
}

.brand h1 {
    font-family: var(--display);
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1;
    margin-top: 6px;
}

.brand h1 span {
    color: var(--gold-2);
}

.brand p {
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow: auto;
}

.nav button {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
    text-align: left;
    padding: 10px 12px;
    border-radius: 12px;
    transition: 180ms ease;
}

.nav button:hover,
.nav button.active {
    color: var(--text);
    background: var(--gold-dim);
    border-color: var(--line);
}

.nav .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 10px currentColor;
    opacity: 0.7;
}

.side-foot {
    padding-top: 12px;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 6px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 11px;
    font-family: var(--mono);
}

.workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    border-bottom: 1px solid var(--line);
}

.crumbs {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.crumbs strong { color: var(--text); font-weight: 600; }

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

.icon-btn, .btn {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    border-radius: 11px;
    padding: 8px 12px;
    transition: 160ms ease;
}

.icon-btn:hover, .btn:hover {
    border-color: var(--gold);
    color: var(--gold-2);
}

.btn.gold {
    background: linear-gradient(180deg, #e0c36e, #b8903a);
    color: #1a1408;
    border: none;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(196, 92, 74, 0.4); color: #e7b2a8; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.view {
    display: none;
    flex: 1;
    overflow: auto;
    padding: 22px;
}

.view.active { display: block; animation: rise 280ms ease; }

@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.hero {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 18px;
    margin-bottom: 18px;
}

.glass {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hero h2 {
    font-family: var(--display);
    font-size: 42px;
    letter-spacing: 0.04em;
    line-height: 0.95;
}

.hero h2 em {
    font-style: normal;
    color: var(--gold);
    display: block;
    font-size: 18px;
    letter-spacing: 0.28em;
    margin-bottom: 8px;
}

.hero .tagline {
    margin-top: 12px;
    color: var(--muted);
}

.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.status-card {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.2);
}

.status-card span {
    display: block;
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--muted);
    text-transform: uppercase;
}

.status-card strong {
    font-family: var(--display);
    font-size: 20px;
    margin-top: 6px;
    display: block;
}

.constellation {
    position: relative;
    height: 280px;
    margin: 10px 0 22px;
}

.constellation svg {
    width: 100%;
    height: 100%;
}

.node {
    position: absolute;
    transform: translate(-50%, -50%);
    min-width: 118px;
    text-align: center;
    padding: 12px 10px 10px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(10, 12, 16, 0.82);
    backdrop-filter: blur(12px);
    transition: 200ms ease;
}

.node:hover {
    border-color: var(--gold);
    transform: translate(-50%, -54%);
    box-shadow: 0 10px 30px rgba(212, 177, 90, 0.12);
}

.node b {
    display: block;
    font-family: var(--display);
    font-size: 13px;
    letter-spacing: 0.12em;
}

.node small {
    color: var(--muted);
    font-size: 10px;
}

.modules {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.mod-card {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
    min-height: 118px;
    text-align: left;
    transition: 180ms ease;
}

.mod-card:hover {
    border-color: var(--gold);
    background: var(--gold-dim);
}

.mod-card span {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--gold);
}

.mod-card h3 {
    font-family: var(--display);
    margin: 8px 0 6px;
    letter-spacing: 0.08em;
}

.mod-card p { color: var(--muted); font-size: 12px; }

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
}

.search {
    flex: 1;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    outline: none;
}

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

.card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
}

.card h3 { font-family: var(--display); font-size: 18px; }
.card .muted { color: var(--muted); font-size: 12px; margin: 6px 0 12px; }
.card .row { display: flex; gap: 6px; flex-wrap: wrap; }

.form {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 16px;
}

.fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label {
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.field input, .field select, .field textarea {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 11px;
    outline: none;
}

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

.coord-box {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.actions-col { display: flex; flex-wrap: wrap; gap: 8px; }

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

.ing {
    display: grid;
    grid-template-columns: 1fr 90px 36px;
    gap: 8px;
    align-items: center;
}

.flow {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.chip {
    border: 1px solid var(--line);
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 11px;
    letter-spacing: 0.12em;
}

.chip.gold { color: #1a1408; background: var(--gold); border: none; }

.code {
    font-family: var(--mono);
    font-size: 12px;
    background: #07080a;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    white-space: pre-wrap;
    min-height: 280px;
    color: #d7d0be;
}

.map-wrap {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 14px;
    height: calc(100% - 8px);
}

.map-canvas {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 18px;
    min-height: 520px;
    overflow: hidden;
    background:
        radial-gradient(circle at 30% 40%, rgba(212, 177, 90, 0.08), transparent 30%),
        linear-gradient(#0c1014, #08090c);
}

.map-point {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid #111;
    box-shadow: 0 0 16px currentColor;
    cursor: pointer;
}

.map-legend button {
    width: 100%;
    margin-bottom: 6px;
    justify-content: flex-start;
}

.modal-layer, .palette-layer, .confirm-layer {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    z-index: 8;
}

.modal-layer.show, .palette-layer.show, .confirm-layer.show { display: flex; }

.modal, .palette, .confirm {
    width: min(720px, 92%);
    background: #101318;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.palette { width: min(560px, 92%); padding: 0; overflow: hidden; }
.palette input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 16px 18px;
    outline: none;
    font-size: 16px;
}
.palette-list { max-height: 320px; overflow: auto; border-top: 1px solid var(--line); }
.palette-list button {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 12px 18px;
    color: var(--text);
}
.palette-list button:hover, .palette-list button.active { background: var(--gold-dim); }

.toasts {
    position: absolute;
    right: 28px;
    bottom: 28px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 12;
}

.toast {
    min-width: 240px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(16, 18, 22, 0.92);
    animation: rise 200ms ease;
}

.toast.error { border-color: rgba(196, 92, 74, 0.5); }
.toast.ok { border-color: rgba(111, 175, 122, 0.5); }

.devbar {
    position: absolute;
    left: 28px;
    bottom: 28px;
    display: none;
    z-index: 10;
    font-family: var(--mono);
    font-size: 11px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(8, 9, 12, 0.86);
    min-width: 240px;
}

.devbar.show { display: block; }

.loading {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 20;
    align-items: center;
    justify-content: center;
    background: rgba(6, 7, 8, 0.45);
    letter-spacing: 0.28em;
    text-transform: uppercase;
    font-size: 12px;
    color: var(--gold);
}
.loading.show { display: flex; }

[title] { cursor: pointer; }

.hidden { display: none !important; }

.empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
}

.rank-list, .step-list { display: flex; flex-direction: column; gap: 8px; }

.rank {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    grid-template-columns: 1.2fr 0.6fr 1.6fr 32px;
    gap: 8px;
    align-items: center;
}

.perms {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.perms label {
    font-size: 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 8px;
    color: var(--muted);
}

.perms input { margin-right: 4px; }

@media (max-width: 1100px) {
    .hero, .form, .modules { grid-template-columns: 1fr; }
    .shell { grid-template-columns: 88px 1fr; }
    .nav button span.label, .brand p, .brand-kicker { display: none; }
}
