:root {
    --paper: #F6F4F0;
    --ink: #1a1a1a;
    --muted: #5c564e;
    --line: #d9d3c8;
    --panel: #fff;
    --accent: #5c4a3a;
    --soft: #f3efe8;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, sans-serif;
    font-size: 14px;
}

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

button {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
}

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

button:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn--solid {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

[hidden] { display: none !important; }

/* ---------- Velkomst og adgangskode ---------- */

.welcome {
    min-height: 100%;
    display: grid;
    grid-template-columns: 1.4fr 1fr;
}

.welcome__hero {
    width: 100%;
    height: 100vh;
    object-fit: cover;
}

.welcome__card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 3.5rem;
    background: var(--paper);
}

.welcome__logo {
    width: 180px;
    height: auto;
    margin-bottom: 2rem;
}

.welcome__card h1 {
    font-family: Jost, sans-serif;
    font-weight: 500;
    font-size: 3rem;
    margin: 0 0 0.75rem;
}

.welcome__card p {
    max-width: 36rem;
    line-height: 1.5;
    color: var(--muted);
}

.welcome__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.5rem;
}

.gate__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: 16rem;
    font-size: 13px;
    color: var(--muted);
}

.gate__field input {
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.55rem 0.7rem;
    font-size: 1.2rem;
    letter-spacing: 0.3em;
    background: #fff;
}

.gate__field input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.gate__error { color: #9a3b2e; }

.steps-intro {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
    line-height: 1.7;
    color: var(--muted);
}

.steps-intro strong { color: var(--ink); }

/* ---------- Program ---------- */

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

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.8rem;
    padding: 0.45rem 0.8rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar__brand img {
    height: 28px;
    width: auto;
}

.topbar__title {
    font-family: Jost, sans-serif;
    font-size: 1.15rem;
    font-weight: 500;
    margin: 0;
}

.steps {
    display: flex;
    margin-left: 0.6rem;
}

.steps button {
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.8rem;
}

.steps button + button { margin-left: -1px; }
.steps button:first-child { border-radius: 4px 0 0 4px; }
.steps button:last-child { border-radius: 0 4px 4px 0; }

.steps button span {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-size: 11px;
}

.steps button.is-on {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.steps button.is-done span {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.topbar__tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-left: 0.4rem;
}

.viewtoggle {
    margin-left: auto;
    display: flex;
}

.viewtoggle button { border-radius: 0; }
.viewtoggle button:first-child { border-radius: 4px 0 0 4px; }
.viewtoggle button + button { margin-left: -1px; }
.viewtoggle button:last-child { border-radius: 0 4px 4px 0; }
.viewtoggle button.is-on {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 290px 1fr 280px;
}

.catalog, .side {
    background: var(--panel);
    overflow: auto;
    padding: 0.8rem;
}

.catalog { border-right: 1px solid var(--line); }
.side { border-left: 1px solid var(--line); }

.stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    background:
        linear-gradient(#efeae2 1px, transparent 1px),
        linear-gradient(90deg, #efeae2 1px, transparent 1px);
    background-size: 24px 24px;
}

.stage.is-3d { background: #e9e4dc; }

#board {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

.stage.is-3d #board { cursor: grab; }
.stage.is-3d #board:active { cursor: grabbing; }

.stage__hint {
    position: absolute;
    left: 12px;
    bottom: 10px;
    margin: 0;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--muted);
    font-size: 12px;
    max-width: calc(100% - 24px);
}

/* ---------- Katalogtræ ---------- */

.catalog h2 {
    font-family: Jost, sans-serif;
    font-size: 1rem;
    font-weight: 500;
    margin: 0 0 0.3rem;
}

.catalog .hint, .side .hint {
    color: var(--muted);
    font-size: 12px;
    margin: 0 0 0.6rem;
    line-height: 1.45;
}

.tree { margin: 0 0 0.6rem; }

.node { border-top: 1px solid var(--line); }

.node--root { border-top: 0; }

.node > .node__title {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 0.42rem 0.1rem;
    border-radius: 0;
}

.node > .node__title::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 5px solid var(--muted);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    flex: 0 0 auto;
    transition: transform 0.12s;
}

.node.is-open > .node__title::before { transform: rotate(90deg); }

.node--line > .node__title { font-weight: 600; }
.node--line > .node__title small {
    font-weight: 400;
    color: var(--muted);
    margin-left: auto;
    font-size: 11px;
}

.node__children { padding-left: 0.85rem; }

.node--leaf > .node__title { font-weight: 500; }

.pick { padding: 0.2rem 0 0.6rem; }

.pick__label {
    font-size: 11px;
    color: var(--muted);
    margin: 0.2rem 0 0.2rem;
}

.heights, .chips, .room-tools, .viewcams, .colors {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.heights { margin-bottom: 0.3rem; }
.chips { margin-bottom: 0.2rem; }

.heights button, .chips button { padding: 0.22rem 0.45rem; font-size: 12px; }

.heights button.is-on {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.chips button.is-armed,
.room-tools button.is-armed {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.room-tools { margin: 0.2rem 0 0.6rem; }

/* ---------- Højre panel ---------- */

.side h2 {
    font-family: Jost, sans-serif;
    font-size: 1rem;
    font-weight: 500;
    margin: 0.2rem 0 0.7rem;
}

.side h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 1rem 0 0.5rem;
    font-weight: 600;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 0.65rem;
    font-size: 12px;
}

.field input, .field select {
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.35rem 0.45rem;
    background: #fff;
}

.field--row {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}

.field--row input { width: 6.5rem; }

.two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.colors label, .viewcams {
    font-size: 12px;
    color: var(--muted);
}

.colors input[type="color"] {
    display: block;
    width: 64px;
    height: 28px;
    padding: 2px;
    margin-top: 0.15rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
}

.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin: 0.2rem 0 0.7rem;
}

.swatches button {
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 50%;
}

.swatches button.is-on { outline: 2px solid var(--ink); outline-offset: 1px; }

.measures {
    margin: 0 0 0.7rem;
    padding-left: 1rem;
    color: var(--muted);
}

.measures strong { color: var(--ink); }

.list {
    margin-top: 1rem;
    border-top: 1px solid var(--line);
    padding-top: 0.7rem;
}

.list table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.list th, .list td {
    text-align: left;
    padding: 0.2rem 0;
    vertical-align: top;
}

.list tr[data-pick] { cursor: pointer; }
.list tr.is-sel td { font-weight: 600; }

.next {
    width: 100%;
    margin-top: 1rem;
}

#printSheet { display: none; }

@media (max-width: 980px) {
    .welcome { grid-template-columns: 1fr; }
    .welcome__hero { height: 42vh; }
    .welcome__card { padding: 1.5rem; }
    .workspace { grid-template-columns: 1fr; grid-template-rows: 240px 1fr auto; }
    .catalog, .side { border: 0; }
    .stage { min-height: 420px; }
}

@media print {
    @page { size: A3 landscape; margin: 12mm; }
    body { background: #fff; }
    .welcome, .app { display: none !important; }
    #printSheet { display: block; }
    .print-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        margin-bottom: 8mm;
    }
    .print-head img { height: 12mm; width: auto; }
    .print-head h1 {
        font-family: Jost, sans-serif;
        font-size: 18pt;
        font-weight: 500;
        margin: 0;
    }
    .print-head p { margin: 0; font-size: 10pt; }
    .print-sheet svg { width: 100%; height: auto; }
    .print-table { width: 100%; border-collapse: collapse; margin-top: 6mm; font-size: 9pt; }
    .print-table th, .print-table td { border-bottom: 0.2mm solid #ccc; text-align: left; padding: 1mm 2mm; }
}
