:root {
    --plum: #814586;
    --plum-dark: #673562;
    --indigo: #3a0062;
    --lilac: #f1e4f4;
    --lilac-mid: #d9bfdf;
    --paper: #fbf8fc;
    --ink: #2b2230;
    --muted: #6b5f70;
    --warn-bg: #fff1cc;
    --warn-ink: #6e4c00;
    --white: #fff;
    --heading: Fraunces, Georgia, serif;
    --body: "Nunito Sans", Arial, sans-serif;
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    font: 400 16px/1.5 var(--body);
}

h1, h2, h3 { font-family: var(--heading); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.25rem); color: var(--plum-dark); }
h2 { font-size: 1.35rem; }
a { color: var(--plum-dark); }
p { margin: 0 0 .75em; }
:focus-visible { outline: 3px solid var(--indigo); outline-offset: 2px; }

/* Header with a stitched seam */
.top {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 76px;
    padding: 6px 18px 10px 16px;
    background:
        repeating-linear-gradient(90deg, var(--lilac-mid) 0 7px, transparent 7px 13px) left 0 bottom 9px / 100% 1.5px no-repeat,
        linear-gradient(var(--plum-dark), var(--plum-dark)) bottom / 100% 4px no-repeat,
        var(--plum);
    color: var(--white);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--lilac); text-decoration: none; font-size: 14px; }
.brand img { width: 140px; height: auto; }

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 21px;
    color: var(--white);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.tabs { display: flex; gap: 8px; margin-inline: auto; }
.tab { background: var(--plum-dark); }
.pill:hover { background: var(--plum-dark); }
.pill:focus-visible { outline-color: var(--white); }
.pill[aria-current="page"] { background: var(--white); color: var(--plum-dark); }

.login {
    min-height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 10px;
    background: var(--indigo);
    color: var(--white);
    font: 700 14px var(--body);
    cursor: pointer;
}

/* Page frame */
.frame { flex: 1; margin: 16px 24px 8px; padding: clamp(16px, 3vw, 36px); border-radius: 14px; background: var(--lilac); }
.center { text-align: center; }
.bottom { padding: 8px 16px 12px; text-align: center; font-size: 13px; font-weight: 700; color: var(--plum-dark); }

.card { background: var(--white); border: 1.5px solid var(--lilac-mid); border-radius: 18px; padding: clamp(16px, 2.5vw, 32px); }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.full { grid-column: 1 / -1; }
.stack { display: grid; gap: 20px; max-width: 1200px; margin-inline: auto; }
.workspace { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.muted { color: var(--muted); font-size: 14px; }

/* Controls */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 22px;
    border: 1.5px solid var(--plum);
    border-radius: 10px;
    background: var(--white);
    color: var(--plum-dark);
    font: 700 14px var(--body);
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: var(--lilac); }
.button.primary { background: var(--plum); color: var(--white); }
.button.primary:hover { background: var(--plum-dark); }
.button.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px 20px;
    border: 2px dashed var(--plum);
    border-radius: 16px;
    background: var(--paper);
    text-align: center;
}
.drop h3 { margin: 0; color: var(--plum-dark); }

[hidden] { display: none !important; }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button.large { min-height: 56px; padding-inline: 40px; font-size: 16px; }
.center-actions { justify-content: center; }
.error { color: #a4161a; font-weight: 700; margin: 0; }
.error:empty { display: none; }
.kicker { margin: 0; font-size: 13px; font-weight: 700; color: var(--plum-dark); text-transform: uppercase; }

/* Front page */
.drop { min-height: 250px; justify-content: center; }
.drop.over { background: var(--lilac); border-style: solid; }
.drop-state { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drop-state.chosen { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 20px; text-align: left; overflow-wrap: anywhere; }
.chosen img { width: 150px; height: 150px; object-fit: cover; border-radius: 10px; }
.chosen p { margin: 0 0 6px; }
.file-icon { display: grid; place-items: center; width: 100px; height: 136px; border: 1.5px solid var(--plum); border-radius: 10px; background: var(--white); color: var(--plum-dark); font: 700 22px var(--heading); }
.working { width: min(100%, 720px); margin-inline: auto; }
.working ul { display: grid; gap: 20px; margin: 24px 0; padding: 0; list-style: none; text-align: left; }
.working li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; overflow-wrap: anywhere; }
.working li span { color: var(--plum-dark); font-weight: 700; text-align: right; }
progress { grid-column: 1 / -1; width: 100%; height: 14px; accent-color: var(--plum); }
.heading-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.heading-row h2 { margin: 0; }
.gallery { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.design { padding: 14px; }
.design img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; margin-bottom: 8px; border-radius: 10px; background: var(--paper); }
.design .button.primary { flex: 1; }
.film { width: 100%; border-radius: 16px; background: var(--indigo); }
.steps { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin: 0; padding: 0; list-style: none; counter-reset: step; text-align: center; }
.steps li { display: flex; flex-direction: column; align-items: center; counter-increment: step; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 8px; border-radius: 50%; background: var(--plum); color: var(--white); font: 700 18px var(--heading); }
.steps span { color: var(--muted); font-size: 13px; }
.qr-code { display: flex; justify-content: center; margin: 16px 0; }
.status { padding: 10px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); font-weight: 700; }
.dialog form.actions { justify-content: center; }

.logout { min-height: 42px; padding: 0 18px; border: 1.5px solid var(--white); border-radius: 10px; background: none; color: var(--white); font: 700 14px var(--body); cursor: pointer; }
.top form { margin: 0; }
.dialog .row { margin-block: 8px; }
.dialog > .wide { margin-top: 8px; }
.share .wide { margin-top: 8px; }

/* My files */
.pattern-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.pattern-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 18px; border: 1.5px solid var(--lilac-mid); border-radius: 12px; background: var(--paper); }
.pattern-list .name { flex: 1 1 220px; overflow-wrap: anywhere; }
.pattern-list .name span { display: block; color: var(--muted); font-size: 12px; }
.pattern-list .state { color: var(--plum-dark); font-size: 13px; font-weight: 700; }
.pattern-list li.soon-gone { border: 2.5px solid #a15c00; }
.button.danger { border-color: #a32035; background: #a32035; color: var(--white); }
.toast { position: fixed; inset: 84px auto auto 50%; z-index: 20; display: flex; align-items: center; gap: 16px; width: max-content; max-width: 94vw; padding: 10px 12px 10px 20px; border-radius: 14px; background: var(--indigo); color: var(--white); font-weight: 700; translate: -50% 0; }

/* On model */
.viewer { position: relative; display: grid; gap: 8px; min-width: 0; }
.viewer canvas { display: block; width: 100%; height: max(360px, calc(100vh - 300px)); border-radius: 14px; background: radial-gradient(ellipse 45% 7% at 50% 93%, var(--lilac-mid) 98%, transparent), var(--white); touch-action: none; outline: none; }
.viewer-status { position: absolute; top: 16px; left: 50%; margin: 0; font-weight: 700; color: var(--plum-dark); translate: -50% 0; }
.viewer-status:empty { display: none; }
.field input[type="range"] { min-height: 32px; padding: 0; border: 0; accent-color: var(--plum); }
.own-model { width: min(100%, 560px); margin-inline: auto; text-align: center; }
.progress-steps { display: grid; gap: 12px; padding: 0; list-style: none; counter-reset: step; text-align: left; }
.progress-steps li { display: flex; align-items: center; gap: 14px; counter-increment: step; color: var(--muted); }
.progress-steps li::before { content: "○"; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--lilac); color: var(--plum-dark); font-weight: 700; }
.progress-steps .active, .progress-steps .done { color: var(--ink); font-weight: 700; }
.progress-steps .done::before { content: "✓"; background: var(--plum); color: var(--white); }
.progress-steps .active::before { content: "…"; background: var(--plum); color: var(--white); }
@media (max-width: 800px) { .viewer canvas { height: 55vh; } }

/* Order */
.order, .about-grid { width: min(100%, 1300px); margin-inline: auto; }
.order-steps { display: grid; gap: 28px; padding: 0; list-style: none; counter-reset: step; }
.order-steps li { display: grid; grid-template-columns: 44px 1fr; column-gap: 18px; counter-increment: step; }
.order-steps li::before { content: counter(step); grid-row: span 2; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--plum); color: var(--white); font: 700 18px var(--heading); }
.order-steps span { color: var(--muted); font-size: 14px; }
.order-list { display: grid; grid-template-columns: auto 1fr; margin: 16px 0; }
.order-list dt, .order-list dd { margin: 0; padding: 12px 0; border-bottom: 1px dashed var(--lilac-mid); }
.order-list dt { color: var(--muted); }
.order-list dd { font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.mini-layout { display: block; width: min(100%, 320px); max-height: 480px; padding: 8px; border-radius: 10px; background: var(--lilac); }
.mini-layout .cloth { fill: var(--white); }
.mini-layout path { fill: var(--lilac-mid); stroke: var(--plum-dark); stroke-width: .6; }
.mini-layout .size-1 { fill: #c9bde6; }
.mini-layout .size-2 { fill: #cfe5d5; }
.mini-layout .size-3 { fill: #f4ddc4; }

/* About */
.about-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.about-grid > div { display: grid; gap: 20px; }
.sewing { padding: 20px 24px; border: 1.5px dashed var(--lilac-mid); border-radius: 14px; background: var(--paper); }
.placeholder { display: grid; place-items: center; min-height: 320px; padding: 20px; border: 1.5px dashed var(--plum); border-radius: 12px; background: var(--paper); }
@media (max-width: 800px) { .about-grid { grid-template-columns: minmax(0, 1fr); } }

/* Pattern layout */
.layout { display: grid; gap: 20px; grid-template-columns: 300px minmax(0, 1fr) 260px; align-items: start; }
.cutting h1 { font-size: 1.15rem; margin-bottom: 4px; }
.status-line { font-weight: 700; color: var(--plum-dark); }
.status-line:empty { display: none; }
.fabric-grid { display: grid; grid-template: 30px auto / 30px minmax(0, 1fr); gap: 6px; }
.fabric-grid .tape { margin: 0; min-width: 0; overflow: hidden; }
.fabric-grid .tape::before { display: none; }
.tape-top { grid-area: 1 / 2; }
.tape-down { grid-area: 2 / 1; }
.fabric { grid-area: 2 / 2; display: block; width: 100%; user-select: none; }
.layout.busy .fabric { opacity: .45; }
.fabric .cloth { fill: var(--white); }
.fabric .selvedge { fill: var(--lilac-mid); }
.fabric .stripe { stroke: var(--plum); stroke-width: .5; }
.fabric .piece { --edge: var(--plum); --tint: #e6cfeb; cursor: grab; touch-action: none; outline: none; }
.fabric .size-1 { --edge: var(--indigo); --tint: #c9bde6; }
.fabric .size-2 { --edge: #3f6f4c; --tint: #cfe5d5; }
.fabric .size-3 { --edge: #8a4a12; --tint: #f4ddc4; }
.fabric .allowance { fill: none; stroke: var(--tint); stroke-linejoin: round; }
.fabric .body { fill: var(--tint); stroke: var(--edge); stroke-width: .35; stroke-dasharray: 1.2 .8; }
.fabric .printed .body { stroke-width: .5; }
.fabric .selected .body, .fabric .piece:focus-visible .body { stroke: #a15c00; stroke-width: .9; }
.fabric text { fill: var(--ink); font: 700 2.6px var(--body); text-anchor: middle; pointer-events: none; }
.fabric .tag { font-weight: 400; }
.fabric .printed text { paint-order: stroke; stroke: var(--white); stroke-width: .9; }
.fabric .cross { cursor: pointer; }
.fabric .cross circle { fill: #a32035; stroke: var(--white); stroke-width: .4; }
.fabric .cross path { stroke: var(--white); stroke-width: .6; }
.fabric .cut { stroke: var(--indigo); stroke-width: .4; stroke-dasharray: 2 1.2; }
.fabric .cut-text { fill: var(--indigo); }
.pattern-box { display: grid; margin: 0; padding: 10px 14px; border: 1.5px dashed var(--plum); border-radius: 10px; background: var(--lilac); overflow-wrap: anywhere; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-width: 56px; min-height: 36px; padding: 0 12px; border: 1.5px solid var(--plum); border-radius: 18px; background: var(--white); color: var(--plum-dark); font: 700 13px var(--body); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--plum); color: var(--white); }
.quantity { display: grid; grid-template-columns: 1fr 44px 32px 44px; gap: 6px; align-items: center; margin-top: 6px; text-align: center; }
.quantity strong { text-align: left; }
.quantity .button, .button.small { padding: 0; min-width: 40px; min-height: 36px; flex: 0; }
.number-input { width: 120px; min-height: 44px; padding: 0 14px; border: 1.5px solid var(--plum); border-radius: 10px; font: 400 18px var(--body); }
.note { margin: 0; padding: 6px 12px; border-radius: 8px; background: var(--lilac); color: var(--plum-dark); font-size: 12px; font-weight: 700; }
.note:empty { display: none; }
.settings .muted, .results .muted { margin: 0; }
.results h2 { font-size: 1rem; margin: 0 0 4px; }
.results section > .button { margin-top: 8px; }
.total { margin: 4px 0 0; color: var(--plum); font: 700 40px var(--heading); }
.summary dl { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 16px 0; font-size: 13px; }
.summary dd { margin: 0; font-weight: 700; text-align: right; }
.summary .wide-cell { grid-column: 1 / -1; }
.removed { display: grid; gap: 6px; margin: 8px 0; padding: 0; list-style: none; }
.removed li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 1.5px solid var(--lilac-mid); border-radius: 10px; background: var(--white); font-size: 13px; }
button.link { padding: 0; border: 0; background: none; color: var(--plum-dark); font: 700 12px var(--body); cursor: pointer; }

@media (max-width: 1200px) {
    .layout { grid-template-columns: 280px minmax(0, 1fr); }
    .results { grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}

@media (max-width: 800px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .cutting { order: -1; }
}

/* Cutting board */
.board-area { display: grid; grid-template: minmax(0, 1fr) 30px / 30px minmax(0, 1fr); gap: 6px; height: max(360px, calc(100vh - 210px)); }
.board-surface { position: relative; grid-area: 1 / 2; overflow: hidden; border-radius: 2px; background-color: var(--white); background-repeat: repeat; cursor: grab; touch-action: none; user-select: none; }
.board-surface:active { cursor: grabbing; }
.board-report { position: absolute; border: 2.5px dashed var(--indigo); pointer-events: none; }
.board-report span { position: absolute; top: 8px; left: 8px; padding: 4px 12px; border-radius: 14px; background: var(--indigo); color: var(--white); font-size: 12px; font-weight: 700; white-space: nowrap; }
.board-area .tape { height: auto; margin: 0; min-width: 0; min-height: 0; overflow: hidden; }
.board-area .tape::before { display: none; }
.board-area .tape svg { position: absolute; inset: 0; }
.tape-left { grid-area: 1 / 1; }
.tape-bottom { grid-area: 2 / 2; }
.panel { display: grid; gap: 14px; align-content: start; }
.panel h2 { margin: 6px 0 0; font-size: 1.1rem; }
.value { margin: 0; padding: 14px; border-radius: 12px; background: var(--lilac); color: var(--plum-dark); font: 700 22px var(--heading); text-align: center; }
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.row .button { flex: 1; padding-inline: 6px; }
.switch { display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer; }
.switch input { appearance: none; position: relative; width: 44px; height: 24px; margin: 0; border-radius: 12px; background: #8d8191; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--white); transition: translate .15s; }
.switch input:checked { background: var(--plum); }
.switch input:checked::after { translate: 20px 0; }
.repeats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.repeats button { flex-direction: column; gap: 4px; padding: 8px; }
.repeats button[aria-pressed="true"] { border-width: 3px; background: var(--lilac); }
.field { display: grid; gap: 4px; margin-bottom: 12px; font-size: 13px; font-weight: 700; }
.field input { min-height: 46px; padding: 0 14px; border: 1.5px solid var(--plum); border-radius: 10px; font: 400 16px var(--body); }
.dialog form.share { text-align: left; }

@media (max-width: 800px) {
    .board-area { height: 60vh; }
}

/* Measuring tape, drawn by ts/tape.ts */
.tape { position: relative; height: 30px; margin: 12px 0 20px; background: var(--plum); border-radius: 2px; }
.tape::before {
    content: "";
    position: absolute;
    inset-block: -3px;
    left: -8px;
    width: 11px;
    border: 1px solid #7d7582;
    border-radius: 2px;
    background: radial-gradient(circle, #7d7582 2px, #b9b3bd 2.5px);
}
.tape svg { display: block; overflow: hidden; }
.tape line { stroke: var(--white); stroke-width: 1; }
.tape text { fill: var(--white); font: 700 10px var(--body); text-anchor: end; }

/* "*på gång*" notices */
.soon {
    margin: 8px 0;
    padding: 10px 14px;
    border: 1.5px dashed var(--warn-ink);
    border-radius: 10px;
    background: var(--warn-bg);
    color: var(--warn-ink);
    font-size: 14px;
    text-align: left;
}

.dialog { width: min(92vw, 520px); padding: 32px; border: 1.5px solid var(--plum); border-radius: 20px; color: var(--ink); }
.dialog::backdrop { background: rgb(58 0 98 / .55); }
.dialog h2 { color: var(--plum-dark); }
.dialog form { margin-top: 20px; text-align: right; }

/* Narrow screens: the steps move to a bar at the bottom */
@media (max-width: 1180px) {
    .top { flex-wrap: wrap; }
    .about { margin-left: auto; }
    .tabs { order: 1; width: 100%; justify-content: center; }
}

@media (max-width: 800px) {
    .brand img { width: 100px; }
    .brand span { display: none; }
    .top { gap: 2px; padding-inline: 10px; }
    .pill { padding: 0 10px; }
    .login { padding: 0 12px; font-size: 12px; }
    .frame { margin: 0; border-radius: 0; padding: 16px 12px; }
    .workspace { grid-template-columns: minmax(0, 1fr); }
    .bottom { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
    .tabs {
        position: fixed;
        inset: auto 0 0;
        z-index: 10;
        gap: 4px;
        padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
        background: var(--plum);
    }
    .tab { flex: 1; padding: 0 4px; font-size: 12px; white-space: normal; text-align: center; line-height: 1.2; }
}

/* ---------- Details from the sketches ---------- */

/* Header */
.tab.dashed { outline: 1.5px dashed var(--lilac-mid); outline-offset: -1.5px; }
.short, .narrow-only { display: none; }

/* Pages */
.frame.tool { padding: 0; background: none; }
.frame.tool > .stack { padding: 24px; border-radius: 14px; background: var(--lilac); }

/* Side panels: small headings with a stitched line */
.panel { border-radius: 16px; padding: 16px; }
.panel h2 { margin: 14px 0 0; padding-bottom: 6px; border-bottom: 1.5px dashed var(--lilac-mid); color: var(--plum-dark); font: 700 11px var(--body); letter-spacing: .04em; text-transform: uppercase; }
.panel > h2:first-child { margin-top: 0; }
.panel h2 label { font: inherit; }
.bottom-actions { display: grid; gap: 12px; margin-top: auto; padding-top: 16px; }
.workspace .panel { display: flex; flex-direction: column; align-self: stretch; }
.panel .switch { font-size: 14px; }

/* Dialogs */
.dialog { position: fixed; }
.dialog[open] { overflow: auto; }
.dialog > h2 { margin-right: 56px; font-size: 1.75rem; }
.dialog .close { position: absolute; top: 24px; right: 24px; min-width: 44px; padding: 0; font-size: 22px; }
.dialog form.share .actions { display: grid; }

/* Cutting board */
.frame.tool .board-area { padding: 16px 12px 12px; border-radius: 14px; background: var(--lilac); height: max(420px, calc(100vh - 110px)); }
.value { padding: 12px; font-size: 26px; }
.repeats .button { min-height: 94px; border-radius: 12px; font-size: 12px; color: var(--ink); }
.repeats .button[aria-pressed="true"] { border-width: 3px; background: var(--lilac); }
.repeat-icon { width: 56px; height: 50px; fill: var(--plum); }

/* Front page */
.upload-card { max-width: 1200px; margin-inline: auto; width: 100%; align-items: stretch; }
.upload-icon { width: 56px; height: 56px; }
.upload-icon circle { fill: var(--lilac); }
.upload-icon path { fill: none; stroke: var(--plum); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.drop h3 { font-size: 1.35rem; }
.waiting { margin: 0; display: grid; place-items: center; min-height: 56px; border-radius: 10px; background: var(--lilac); color: var(--muted); font-size: 14px; font-weight: 700; text-align: center; }
.button.create { width: min(100%, 560px); min-height: 60px; }
.soon-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.soon-list .soon { margin: 0; font-size: 12px; padding: 4px 10px; }
.stack > .tape { width: min(100%, 1000px); margin-inline: auto; }
.intro { grid-template-columns: minmax(0, 420fr) minmax(0, 760fr); align-items: stretch; }
.intro .film { height: 100%; object-fit: cover; }
.steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.steps li { position: relative; }
.steps li::before { position: relative; z-index: 1; }
.steps li:not(:last-child)::after { content: ""; position: absolute; top: 23px; left: calc(50% + 30px); width: calc(100% - 44px); border-top: 2px dashed var(--plum); }

/* My files and lists */
.full-card .title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 4px 0 10px; }
.full-card .title span { color: var(--muted); font-size: 12px; }
.full-card .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.full-card .actions .button { padding-inline: 8px; min-height: 40px; }
.full-card .actions .copy { grid-column: 1; }
.file-icon.small { width: 36px; height: 48px; font-size: 10px; border-radius: 5px; }

/* Pattern layout */
.cutting .heading-row h1 { margin: 0; }
.fabric-grid { padding: 14px 12px 12px; border-radius: 14px; background: var(--lilac); }
.cutting > .muted { margin-top: 8px; font-size: 12px; }
.quantity { grid-template-columns: 18px 1fr 44px 32px 44px; }
.swatch { width: 18px; height: 18px; border-radius: 4px; background: var(--plum); }
.swatch.size-1 { background: var(--indigo); }
.swatch.size-2 { background: #3f6f4c; }
.swatch.size-3 { background: #8a4a12; }
.summary { padding: 22px; outline: 1.5px dashed var(--lilac-mid); outline-offset: -12px; }

/* On model */
.stage { position: relative; display: grid; align-content: center; min-height: max(520px, calc(100vh - 110px)); padding: 20px; border-radius: 14px; background: var(--lilac); min-width: 0; }
.viewer canvas { height: max(360px, calc(100vh - 250px)); background: radial-gradient(ellipse 40% 5% at 50% 94%, var(--lilac-mid) 98%, transparent); }
.viewer .caption { margin: 0; color: var(--plum-dark); font-size: 13px; }
.hint { justify-self: center; margin: 0; padding: 6px 24px; border-radius: 17px; background: var(--white); font-size: 13px; text-align: center; }
.models { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.models .button { flex-direction: column; justify-content: flex-start; gap: 2px; min-height: 74px; padding: 10px 2px 6px; border-radius: 12px; color: var(--ink); font-size: 12px; line-height: 1.3; }
.models .button[aria-pressed="true"] { border-width: 3px; background: var(--lilac); }
.models small { color: var(--muted); font-weight: 400; font-size: 11px; }
.models [data-soon] { border-style: dashed; justify-content: center; }
.flower-icon { width: 24px; height: 24px; flex: none; fill: var(--plum); }
.flower-icon .eye { fill: #f4c95d; }
.panel [data-free], .panel [data-own] { display: grid; gap: 10px; }
.panel .field { margin: 0; }
.bottom-actions a[data-free], .bottom-actions a[data-own] { display: inline-flex; }
.add-pattern { display: grid; padding: 12px; border: 1.5px dashed var(--plum); border-radius: 12px; background: var(--paper); font-size: 13px; text-align: center; text-decoration: none; }
.add-pattern strong { color: var(--ink); }
.own-box { display: flex; align-items: center; gap: 12px; margin: 0; padding: 16px; border: 3px solid var(--plum); border-radius: 12px; background: var(--lilac); overflow-wrap: anywhere; }
.own-note { padding: 14px 16px; border-radius: 12px; background: var(--lilac); font-size: 12px; }
.panel .own-note strong { color: var(--plum-dark); font-size: 13px; }

/* Order */
.order-steps li:not(:last-child) { position: relative; }
.order-steps li:not(:last-child)::after { content: ""; position: absolute; left: 21px; top: 50px; bottom: -22px; border-left: 2px dashed var(--plum); }
.sewing h2 { font-size: 1rem; }
.order-columns { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.order-columns .order-list { flex: 1 1 240px; align-self: flex-start; }
.order-columns > div, .order-columns > p { flex: 0 1 300px; }
.order-columns h3 { font: 700 15px var(--body); }

@media (max-width: 800px) {
    /* The steps as a white bar with numbers, as in the mobile sketches */
    .tabs { gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-top: 1.5px solid var(--lilac-mid); background: var(--white); counter-reset: tab; }
    .tab { flex-direction: column; gap: 2px; min-height: 56px; border-radius: 14px; background: none; color: var(--muted); counter-increment: tab; }
    .tab::before { content: counter(tab); display: grid; place-items: center; width: 22px; height: 22px; border: 1.5px solid var(--plum); border-radius: 50%; color: var(--plum-dark); font-size: 11px; }
    .tab:hover { background: var(--lilac); }
    .tab[aria-current="page"] { background: var(--lilac); color: var(--plum-dark); }
    .tab[aria-current="page"]::before { background: var(--plum); color: var(--white); }
    .tab.dashed { outline-color: var(--plum); }
    .long, .about, .logout-form { display: none; }
    .short { display: inline; }
    .narrow-only { display: inline; }
    .brand img { width: 110px; }
    .files { margin-left: auto; background: var(--plum-dark); border-radius: 10px; }
    .login { min-height: 44px; font-size: 12px; }
    .frame.tool { padding: 8px; }
    .frame.tool .board-area { height: 62vh; padding: 8px 6px 6px; }
    .stage { min-height: 0; padding: 12px; }
        .viewer canvas { height: 52vh; }
    .intro, .steps { grid-template-columns: minmax(0, 1fr); }
    .steps li:not(:last-child)::after { display: none; }
}

/* ---------- Corrections after comparing screenshots with the sketches ---------- */
.button { text-align: center; }

@media (min-width: 1280px) {
    .tab { min-width: 110px; }
    .tab[data-tab="board"] { min-width: 140px; }
    .tab[data-tab="layout"] { min-width: 190px; }
    .tab[data-tab="model"] { min-width: 150px; }
}

/* Front page: two columns, and everything a little tighter */
.upload-card { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 20px; column-gap: 40px; padding: 24px 40px; }
#front > .center h1 { margin-bottom: 4px; }
#front > .center p { margin: 0; }
#front > .tape { margin-block: 0; }
#front { gap: 14px; }

/* Layout: white settings column along the left edge */
.layout { grid-template-columns: 320px minmax(0, 1fr) 240px; gap: 28px; padding-right: 24px; }
.layout .settings { display: flex; flex-direction: column; gap: 10px; align-self: stretch; padding: 20px 24px; border: 0; border-right: 1.5px solid var(--lilac-mid); border-radius: 0; }
.layout .settings .row { justify-content: flex-start; }
.layout .settings .row > span:first-child { margin-right: auto; }
.layout .button.small { width: 36px; flex: none; }
.unit-input { display: flex; align-items: center; gap: 8px; width: 120px; min-height: 44px; padding: 0 14px; border: 1.5px solid var(--plum); border-radius: 10px; color: var(--muted); font-size: 13px; }
.unit-input input { width: 100%; min-width: 0; border: 0; color: var(--ink); font: 700 18px var(--body); }
.cutting { padding-top: 14px; }
.fabric-grid { gap: 2px; }
.results { display: grid; gap: 20px; align-content: start; padding-top: 20px; }
.results h2 { font: 700 14px var(--body); }
.summary progress { appearance: none; height: 10px; border: 0; border-radius: 5px; overflow: hidden; background: var(--lilac); }
.summary progress::-webkit-progress-bar { background: var(--lilac); }
.summary progress::-webkit-progress-value { background: var(--plum); }
.summary progress::-moz-progress-bar { background: var(--plum); }

/* On model: fits the window */
#model .workspace { grid-template-columns: minmax(0, 1fr) 300px; }
.stage { min-height: max(520px, calc(100vh - 110px)); padding-block: 12px; }
.viewer canvas { height: max(340px, calc(100vh - 220px)); }
#model .panel { gap: 10px; }
.panel input[type="range"] { appearance: none; width: 100%; height: 24px; min-height: 24px; background: none; }
.panel input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--lilac-mid); }
.panel input[type="range"]::-webkit-slider-thumb { appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: var(--plum); }
.panel input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--lilac-mid); }
.panel input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: var(--plum); }

/* Order */
.order { align-items: stretch; }
.order h1, .order h2:not(.sewing h2) { font-size: 1.75rem; }
.order > .card { display: flex; flex-direction: column; gap: 14px; }
.order-steps { gap: 40px; margin-block: 8px 24px; }
.order-steps li:not(:last-child)::after { bottom: -34px; }
.order .sewing h2 { font-size: 1rem; }
.order .soon, .order p { margin-block: 0; }
.order .sewing .soon { margin-top: 8px; font-size: 13px; }
.order-columns { align-items: flex-start; }
.order-columns > div, .order-columns > p { flex: 1 1 220px; max-width: 300px; min-width: 0; }
.order-columns .board-preview { width: 100%; }
.order .actions { gap: 10px; }

@media (max-width: 1200px) {
    .layout { grid-template-columns: 280px minmax(0, 1fr); }
}

@media (max-width: 800px) {
    .upload-card { grid-template-columns: minmax(0, 1fr); padding: 16px; }
    .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; padding-right: 0; }
    .layout .settings { order: 1; border: 1.5px solid var(--lilac-mid); border-radius: 16px; }
    .cutting { order: -1; padding-top: 0; }
    .cutting > .heading-row h1 { font-size: 1rem; }
    .results { grid-column: auto; padding-top: 0; }
    .fabric .piece text { display: none; }
    .fabric .selected text { display: block; }
    /* Cutting board: the controls sit directly under the board */
    #board { gap: 8px; }
    #board .panel { padding: 4px; border: 0; background: none; gap: 10px; }
    #board .panel h2 { border: 0; padding: 0; font: 700 14px var(--body); text-transform: none; color: var(--ink); }
    #board .value { padding: 0; margin-top: -34px; background: none; text-align: right; font-size: 22px; }
    .frame.tool .board-area { height: max(300px, calc(100vh - 360px)); }
    #model .workspace { grid-template-columns: minmax(0, 1fr); }
}

.panel .button.large { min-height: 52px; padding-inline: 10px; font-size: 14px; }

/* My files */
#files { max-width: 1320px; }
#files h1, #files .heading-row .muted { margin: 0; }
#files .card { display: grid; gap: 14px; padding-block: 20px; }
.signed-in { display: grid; margin: 0 8px 0 0; align-content: center; color: var(--muted); font-size: 12px; text-align: right; }
.signed-in strong { color: var(--ink); font-size: 14px; }
.soon-list.start { justify-content: flex-start; }
#files .full-card { display: block; padding: 12px; background: var(--paper); }
.full-card .actions { grid-template-columns: repeat(4, 1fr); }
.full-card .actions > * { grid-column: span 2; }
.full-card .actions .copy { grid-column: span 3; }
.full-card .actions [data-delete] { grid-column: span 1; }
#files .pattern-list .name { flex: 0 1 440px; }
#files .pattern-list .state { flex: 1 1 160px; }

@media (max-width: 800px) {
    .signed-in { text-align: left; width: 100%; }
    #files .pattern-list .name { flex: 1 1 200px; }
    /* The main button comes right after the size buttons, visible without scrolling */
    #board .panel > * { order: 2; }
    #board .panel > h2:first-child, #board .value, #board .value + .row { order: 0; }
    #board .bottom-actions { order: 1; margin: 0; padding: 0; }
    .frame.tool .board-area { height: max(260px, calc(100vh - 440px)); }
}

/* Forms in dialogs read from the left; only the button rows are centred */
.dialog form { text-align: left; }
.dialog form.actions { justify-content: center; }
.about-grid .card h2 { margin-top: 16px; }
.about-grid .sewing h2, .about-grid > div .card h2 { margin-top: 0; }

/* ---------- Narrow screens as in the mobile sketches ---------- */
.mobile-only { display: none !important; }
.group { display: contents; }
.dialog.sheet > h2 { font-size: 1.4rem; }

@media (max-width: 800px) {
    .mobile-only { display: flex !important; }
    .mobile-only[hidden] { display: none !important; }
    .wide-only, .narrow-hidden { display: none !important; }
    .group { display: grid; gap: 10px; }

    /* Every dialog is a sheet from the bottom */
    .dialog { inset: auto 0 0; width: 100%; max-width: 100%; max-height: 88vh; margin: 0; padding: 30px 20px calc(20px + env(safe-area-inset-bottom)); border-width: 0; border-radius: 22px 22px 0 0; }
    .dialog::before { content: ""; position: absolute; top: 12px; left: 50%; width: 60px; height: 5px; border-radius: 3px; background: var(--lilac-mid); translate: -50% 0; }
    .dialog > h2 { font-size: 1.35rem; }
    .dialog .close { top: 26px; right: 20px; }
    .dialog form.actions { display: grid; grid-template-columns: 1fr 1fr; }

    /* Cutting board */
    #board { display: flex; flex-direction: column; align-items: stretch; }
    .board-top { align-items: center; gap: 12px; order: -1; padding: 4px; color: var(--plum-dark); font-weight: 700; font-size: 14px; }
    .board-top > span { margin-right: auto; }
    .board-top .button { width: auto; min-height: 40px; padding-inline: 14px; order: 1; }
    .board-top .switch { order: 2; gap: 8px; color: var(--ink); font-size: 0; }
    .board-top .switch::before { content: "Visa"; font-size: 13px; font-weight: 400; }
    /* Leaves room for the size buttons and the main button above the step bar */
    .frame.tool .board-area { height: max(260px, calc(100vh - 430px)); }
    #board .board-top { padding-block: 0; }
    #board .panel .value + .row .button { min-height: 44px; }
    #board .panel .bottom-actions { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 5fr); }
    #board .bottom-actions .button { min-height: 56px; padding-inline: 8px; }
    #board-sheet-body { display: grid; gap: 12px; padding: 0 0 16px; }

    /* Pattern layout */
    .summary { padding: 16px; outline: 0; }
    .summary dl { margin: 8px 0; }
    .summary .total { font-size: 34px; }
    .summary .muted { display: none; }
    .summary [data-save-state] { display: block; }
    .summary [data-save-state]:empty { display: none; }
    .summary-actions { display: flex; gap: 10px; }
    .summary-actions > * { flex: 1; }
    .summary-actions .button { min-height: 52px; }
    .summary > .button { margin-top: 10px; }
    .selected-name { margin: 0; align-items: center; font-weight: 700; }
    /* The chosen piece and its buttons come first, right under the fabric */
    .results .move-tools { order: -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .results .move-tools:not(:has(> :not([hidden], :disabled, .wide-only))) { display: none; }
    .results .move-tools > .button { margin: 0; padding-inline: 8px; }
    .move-tools [data-remove-piece], .move-tools .selected-name, .move-tools [data-manual] { grid-column: 1 / -1; }
    .move-tools [data-undo]:disabled, .move-tools [data-optimal]:disabled { display: none; }
    #settings-sheet-body .settings { display: flex; padding: 0 0 16px; border: 0; }
    #removed-sheet-body section { display: grid; gap: 8px; }
    .removed li { align-items: center; padding-block: 12px; font-size: 14px; }

    /* On model */
    #model .workspace { gap: 10px; }
    #model .stage { min-height: 0; }
    .model-top { flex-direction: column; gap: 8px; }
    .model-top .actions { display: grid; grid-template-columns: 1fr 1fr; }
    .model-top .kicker { display: none; }
    .model-top .add-pattern { display: flex; justify-content: center; gap: 6px; border-style: solid; background: var(--white); }
    .model-top [hidden] { display: none; }
    .viewer canvas { height: max(220px, calc(100vh - 560px)); }
    .stage .hint, #model .panel .free-info { display: none; }
    #model .panel [data-pattern-notice] { order: 9; }
    #model .panel h2 { border: 0; padding: 0; margin: 4px 0 0; color: var(--ink); font: 700 14px var(--body); text-transform: none; }
    #model .panel { padding: 4px; border: 0; background: none; }
    #model .panel [data-free] > .muted, #model .panel > [data-free] > h2:first-child + .muted { display: none; }
    #model .panel .field { grid-template-columns: 80px 1fr; align-items: center; font-weight: 400; }
    #model .bottom-actions { display: flex; flex-direction: row; gap: 10px; padding: 0; }
    #model .bottom-actions > * { flex: 1; min-height: 48px; padding-inline: 8px; }
    #model-sheet-body { padding: 0; border: 0; }

    /* My files */
    .section-tabs { gap: 10px; }
    .section-tabs .chip { flex: 1; min-height: 42px; }
}

@media (max-width: 800px) {
    /* The button that closes a long sheet is always in reach */
    .dialog.sheet > form { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); margin: 0 -20px calc(-20px - env(safe-area-inset-bottom)); padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); background: var(--white); }
}

@media (max-width: 800px) {
    #model-actions [data-centre] { order: -1; }
}

/* A darker stage, so that light fabrics stand out; own loading notice for the 3D model */
.stage { background: radial-gradient(ellipse at 50% 40%, #9a88a3, #685670); }
.stage .viewer canvas { background: radial-gradient(ellipse 40% 5% at 50% 94%, rgb(35 20 45 / .35) 98%, transparent); }
.stage .viewer .caption { color: var(--white); font-size: 14px; }
.viewer-status:not(:empty) { top: 45%; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 12px; width: max-content; max-width: 90%; padding: 20px 28px; border-radius: 16px; background: var(--white); box-shadow: 0 8px 30px rgb(35 20 45 / .25); text-align: center; translate: -50% -50%; }
.viewer-status.loading::before { content: ""; width: 40px; height: 40px; border: 5px solid var(--lilac); border-top-color: var(--plum); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { rotate: 1turn; } }
@media (prefers-reduced-motion: reduce) { .viewer-status.loading::before { animation-duration: 3s; } }

/* The button where the tapes meet */
.tape-corner { display: grid; place-items: center; }
.tape-corner svg { width: 30px; height: 30px; }
.tape-corner circle { fill: var(--plum); stroke: var(--white); stroke-width: 2; }
.tape-corner .rim { fill: none; stroke: var(--lilac-mid); stroke-width: 1; }
.tape-corner .hole { fill: var(--white); stroke: none; }
.board-area .tape-corner { grid-area: 2 / 1; }
.fabric-grid .tape-corner { grid-area: 1 / 1; }
.board-area .tape-bottom::before, .board-area .tape-left::before { display: none; }

/* Layout without a pattern: an invitation to upload one */
.layout.no-pattern > :not(.promo, dialog) { display: none !important; }
.promo { grid-column: 1 / -1; width: min(100%, 860px); margin: 24px auto; }
.promo h1 { margin-bottom: 8px; }
.promo-points { display: grid; gap: 10px; margin: 20px 0; padding: 0; list-style: none; }
.promo-points li { display: flex; gap: 12px; align-items: baseline; }
.promo-points li::before { content: "✂"; color: var(--plum); font-weight: 700; }
.promo .drop { min-height: 0; margin-block: 16px; }
.promo h2 { margin-top: 24px; font-size: 1.15rem; }
@media (max-width: 800px) { .promo { margin: 8px 0; padding: 18px; } }

/* Several fabrics */
.fabric-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.fabric-lengths { display: grid; gap: 4px; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px dashed var(--lilac-mid); list-style: none; font-size: 13px; }
.fabric-lengths li { display: flex; justify-content: space-between; gap: 8px; }
.fabric-choice { display: grid; gap: 8px; }
.fabric-choice .field { margin: 0; }
.fabric-choice select { min-height: 44px; padding: 0 10px; border: 1.5px solid var(--plum); border-radius: 10px; background: var(--white); font: 400 15px var(--body); }
.fabric-choice .muted { font-size: 12px; }

.other-fabrics { flex: 1 1 100%; }
.other-fabrics ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.other-fabrics li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 14px; border: 1.5px solid var(--lilac-mid); border-radius: 12px; }
.other-fabrics li span { color: var(--muted); font-size: 13px; margin-right: auto; }
.other-fabrics .soon { flex-basis: 100%; margin: 0; }
