/* TrailKeeps Hosted Studio — Dark Gallery Theme
   Aesthetic aligned with https://trailkeeps.com/#gallery
   Palette: Rich midnight slate (#090D16 / #0F1626) with signature trail orange (#FF6A00)
   Modern typography, gentle warm ambient gradients, sleek rounded cards, pill ribbons.
*/

:root {
    /* Base canvas & dark surfaces matching trailkeeps.com */
    --background: #090D16;
    --background-deep: #060910;
    --card: #0F1626;
    --card-surface: #131B2E;
    --card-hover: #18233A;
    --popover: #0C121E;
    --secondary: #19212F;
    --secondary-hover: #222D3E;

    /* Text hierarchy — balanced, readable, non-glaring contrast */
    --foreground: #F4F6FA;
    --foreground-soft: #CBD5E1;
    --foreground-muted: #94A3B8;
    --foreground-subtle: #64748B;

    /* Signature TrailKeeps brand accents */
    --primary: #FF6A00;
    --primary-glow: #FF8533;
    --primary-soft: rgba(255, 106, 0, 0.12);
    --primary-subtle: rgba(255, 106, 0, 0.05);

    /* Cool blue accent for geographic highlights */
    --accent: #0077FF;
    --accent-glow: #4DD2FF;
    --accent-soft: rgba(0, 119, 255, 0.12);

    /* Functional states */
    --success: #10B981;
    --success-soft: rgba(16, 185, 129, 0.14);
    --warning: #F59E0B;
    --warning-soft: rgba(245, 158, 11, 0.14);
    --danger: #EF4444;
    --danger-soft: rgba(239, 68, 68, 0.14);

    /* Subtle slate borders */
    --border: #1E293B;
    --border-strong: #334155;
    --border-subtle: rgba(255, 255, 255, 0.06);

    /* Focus & interaction */
    --focus: #FF6A00;
    --focus-ring: rgba(255, 106, 0, 0.35);

    /* Legacy semantic variable aliases */
    --paper: var(--background);
    --paper-deep: var(--card);
    --surface: var(--card);
    --ink: var(--foreground);
    --ink-soft: var(--foreground-soft);
    --muted: var(--foreground-muted);
    --rule: var(--border);
    --rule-strong: var(--border-strong);
    --mauve: var(--primary);
    --mauve-soft: var(--primary-soft);
    --pink: var(--accent);
    --pink-soft: var(--accent-soft);
    --mint: var(--success);
    --mint-soft: var(--success-soft);
    --sage: var(--warning);
    --sage-soft: var(--warning-soft);

    /* Gradients */
    --gradient-sunrise: linear-gradient(135deg, #FF6A00 0%, #FF8533 100%);
    --gradient-card: linear-gradient(145deg, #131B2E 0%, #0F1626 100%);
    --gradient-card-subtle: linear-gradient(145deg, rgba(19, 27, 46, 0.6) 0%, rgba(15, 22, 38, 0.6) 100%);
    --gradient-card-elevated: linear-gradient(145deg, rgba(25, 36, 60, 0.7) 0%, rgba(16, 23, 38, 0.8) 100%);
    --gradient-dark: linear-gradient(180deg, #0C121E 0%, #060910 100%);

    /* Elevation shadows */
    --shadow-soft: 0 4px 20px -4px rgba(0, 0, 0, 0.35);
    --shadow-medium: 0 8px 30px -8px rgba(0, 0, 0, 0.5);
    --shadow-strong: 0 20px 50px -15px rgba(0, 0, 0, 0.65);
    --shadow-glow: 0 4px 20px -2px rgba(255, 106, 0, 0.4);
    --shadow-glow-subtle: 0 0 16px rgba(255, 106, 0, 0.2);

    /* Typography */
    --font-display: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-ui: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;

    --top-bar-height: 68px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
    background-color: var(--background);
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    background-color: var(--background);
    background-image: 
        radial-gradient(ellipse 700px 400px at 20% 12%, rgba(255, 106, 0, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse 800px 500px at 85% 88%, rgba(0, 119, 255, 0.04) 0%, transparent 60%);
    background-attachment: fixed;
    color: var(--foreground-soft);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body.projects-open {
    overflow: hidden;
}

h1,
h2,
h3,
p,
dl,
dd,
dt,
figure {
    margin: 0;
}

h1, h2, h3, h4 {
    color: var(--foreground);
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.025em;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-glow);
    text-decoration: underline;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

::selection {
    background: rgba(255, 106, 0, 0.25);
    color: #FFFFFF;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -70px;
    left: 16px;
    z-index: 3000;
    padding: 10px 18px;
    border: 1px solid var(--primary);
    border-radius: 9999px;
    background: var(--card);
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--shadow-glow);
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 14px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 9999px;
    background: var(--primary-soft);
    border: 1px solid rgba(255, 106, 0, 0.24);
    color: var(--primary-glow);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

/* Header ----------------------------------------------------------------- */

#top-bar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    min-height: var(--top-bar-height);
    padding: 12px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(9, 13, 22, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--foreground);
    text-decoration: none;
}

.brand:hover {
    color: var(--foreground);
    text-decoration: none;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--gradient-sunrise);
    box-shadow: 0 2px 10px rgba(255, 106, 0, 0.35);
    flex: 0 0 auto;
    color: #FFFFFF;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand:hover .brand-mark {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(255, 106, 0, 0.5);
}

.brand-mark svg {
    display: block;
    width: 20px;
    height: 20px;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--foreground);
}

.brand-studio {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1.4;
}

/* Wizard Steps Ribbon ---------------------------------------------------- */

#wizard-steps {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 9999px;
    background: rgba(25, 33, 47, 0.7);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    justify-self: center;
    max-width: fit-content;
}

.step-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    padding: 6px 16px;
    border: none;
    border-radius: 9999px;
    background: transparent;
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.step-tab:hover:not(:disabled) {
    color: var(--foreground);
    background: rgba(255, 255, 255, 0.06);
}

.step-tab:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: inherit;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    transition: all 0.2s ease;
}

.step-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.step-check {
    display: none;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    color: var(--success);
}

.step-check svg {
    display: block;
    width: 14px;
    height: 14px;
}

.step-tab.is-complete .step-check {
    display: inline-flex;
}

.step-tab.is-complete {
    color: var(--foreground-soft);
    background: transparent;
}

.step-tab.is-complete:hover:not(:disabled) {
    color: var(--foreground);
    background: rgba(255, 255, 255, 0.08);
}

.step-tab.is-active,
.step-tab[aria-current="step"] {
    background: var(--gradient-sunrise) !important;
    color: #FFFFFF !important;
    box-shadow: 0 2px 12px rgba(255, 106, 0, 0.35);
}

.step-tab.is-active .step-number,
.step-tab[aria-current="step"] .step-number {
    background: rgba(255, 255, 255, 0.25);
    color: #FFFFFF;
}

.top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.preview-chip {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 12px;
    border: 1px solid rgba(255, 106, 0, 0.3);
    border-radius: 9999px;
    background: var(--primary-soft);
    color: var(--primary-glow);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Buttons ---------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn .icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

/* Primary call to action button (Continue to design, Next, Save) */
.btn-ink {
    background: var(--gradient-sunrise);
    border-color: transparent;
    color: #FFFFFF;
    box-shadow: 0 4px 16px rgba(255, 106, 0, 0.35);
}

.btn-ink:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(255, 106, 0, 0.5);
    background: linear-gradient(135deg, #ff7a1a 0%, #ff954d 100%);
    color: #FFFFFF;
}

.btn-purchase {
    background: var(--gradient-sunrise);
    border-color: transparent;
    color: #FFFFFF;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 4px 18px rgba(255, 106, 0, 0.45);
}

.btn-purchase:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 26px rgba(255, 106, 0, 0.6);
    background: linear-gradient(135deg, #ff7a1a 0%, #ff954d 100%);
    color: #FFFFFF;
}

.btn-outline,
.btn-secondary {
    background: var(--secondary);
    border: 1px solid var(--border-strong);
    color: var(--foreground-soft);
    border-radius: 12px;
}

.btn-outline:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-hover);
    border-color: rgba(255, 255, 255, 0.25);
    color: #FFFFFF;
    transform: translateY(-1px);
}

.btn-quiet {
    background: transparent;
    border-color: transparent;
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.btn-quiet:hover:not(:disabled) {
    background: var(--primary-soft);
    color: var(--primary-glow);
}

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-soft);
}

.btn-small {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 9999px;
}

.btn-block {
    width: 100%;
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--secondary);
    color: var(--foreground-soft);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--secondary-hover);
    border-color: rgba(255, 255, 255, 0.25);
    color: #FFFFFF;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* Shell and panels -------------------------------------------------------- */

#hosted-app {
    min-height: 100vh;
}

#studio {
    display: grid;
    grid-template-columns: minmax(380px, 42%) minmax(0, 1fr);
    align-items: start;
    width: 100%;
    max-width: 1720px;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

#wizard-panel {
    display: flex;
    min-width: 0;
    min-height: calc(100vh - var(--top-bar-height));
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(16, 23, 38, 0.95) 0%, rgba(13, 19, 31, 0.98) 100%);
}

.step-panel {
    flex: 1 0 auto;
    padding: 18px 24px 14px;
    background: transparent;
    border-left: none;
}

.step-head {
    margin-bottom: 12px;
}

.step-head h1 {
    font-size: clamp(20px, 2vw, 26px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    outline: none;
    color: var(--foreground);
}

.step-intro {
    max-width: 48ch;
    margin-top: 4px;
    color: var(--foreground-muted);
    font-size: 13px;
    line-height: 1.4;
}

/* Control blocks & cards ------------------------------------------------- */

.control-block {
    min-width: 0;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--gradient-card-subtle);
    box-shadow: var(--shadow-soft);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.control-block:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.control-block + .control-block {
    margin-top: 10px;
}

.control-heading {
    color: var(--foreground);
    font-family: var(--font-display);
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.control-legend {
    display: block;
    padding: 0;
    color: var(--foreground);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.control-legend + * {
    margin-top: 8px;
}

.control-heading-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.control-heading + .control-help,
.control-legend + .control-help,
.control-heading-row + .control-help {
    margin-top: 4px;
}

.control-help {
    margin-top: 4px;
    color: var(--foreground-muted);
    font-size: 11.5px;
    line-height: 1.35;
}

.optional-label {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: none;
}

.nested-block {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(13, 19, 31, 0.5);
}

#road-style-fieldset.is-disabled {
    opacity: 0.55;
}

.mono-readout {
    color: var(--primary-glow);
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

/* Choice cards and chips ------------------------------------------------ */

.choice-grid {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.choice-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    min-height: 40px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--secondary);
    color: var(--foreground-soft);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.choice-card:hover {
    background: var(--secondary-hover);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

.choice-card:has(.choice-input:checked) {
    border: 1.5px solid var(--primary);
    background: rgba(255, 106, 0, 0.08);
    box-shadow: 0 0 16px rgba(255, 106, 0, 0.18);
    color: #FFFFFF;
}

.choice-card:has(.choice-input:focus-visible) {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.choice-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 24px;
    flex: 0 0 auto;
    color: var(--foreground-muted);
    transition: color 0.2s ease;
}

.choice-icon svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.choice-card:has(.choice-input:checked) .choice-icon {
    color: var(--primary-glow);
}

.choice-label {
    overflow: hidden;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.choice-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    opacity: 0;
    pointer-events: none;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chip-choice {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 4px 14px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: var(--secondary);
    color: var(--foreground-soft);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chip-choice:hover {
    background: var(--secondary-hover);
    border-color: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
}

.chip-choice:has(.choice-input:checked) {
    background: var(--gradient-sunrise);
    border-color: transparent;
    color: #FFFFFF;
    box-shadow: 0 2px 12px rgba(255, 106, 0, 0.35);
}

.chip-choice:has(.choice-input:focus-visible) {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Segmented controls (Road style, orientation) -------------------------- */

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: var(--secondary);
}

.seg-option {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 16px;
    border: none;
    border-radius: 9999px;
    color: var(--foreground-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.seg-option:hover {
    color: var(--foreground);
}

.seg-option:has(.choice-input:checked) {
    background: var(--gradient-sunrise);
    color: #FFFFFF;
    box-shadow: 0 2px 10px rgba(255, 106, 0, 0.3);
}

.seg-option:has(.choice-input:focus-visible) {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.segmented-small {
    border-color: var(--border);
    background: rgba(25, 33, 47, 0.7);
}

.seg-button {
    min-height: 30px;
    padding: 4px 12px;
    border: 0;
    border-radius: 9999px;
    background: transparent;
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
}

.seg-button:hover:not(:disabled) {
    color: var(--foreground);
}

.seg-button.is-active {
    background: var(--gradient-sunrise);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(255, 106, 0, 0.3);
}

.seg-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Fields & Inputs -------------------------------------------------------- */

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 6px;
}

.field > label,
.field-label-row > label {
    color: var(--foreground-soft);
    font-size: 12.5px;
    font-weight: 600;
}

.field-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
    margin-bottom: 4px;
}

.value-output {
    color: var(--primary-glow);
    font-family: var(--font-display);
    font-size: 13.5px;
    font-weight: 600;
}

.input-with-unit {
    position: relative;
    display: flex;
    min-width: 0;
}

.input-with-unit input {
    padding-right: 42px;
}

.input-with-unit .unit {
    position: absolute;
    top: 50%;
    right: 12px;
    color: var(--foreground-muted);
    font-family: var(--font-display);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    pointer-events: none;
    transform: translateY(-50%);
}

input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.3;
    transition: all 0.2s ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--foreground-subtle);
    opacity: 1;
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.18);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: none;
    background: var(--popover);
}

input:disabled,
select:disabled,
textarea:disabled {
    background: var(--card);
    color: var(--foreground-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

input[type="number"] {
    font-family: var(--font-display);
    font-size: 13.5px;
}

/* Compact Number Inputs (e.g. alongside range sliders) */
input[type="number"].input-compact,
input.input-compact,
.input-compact {
    width: 72px !important;
    min-width: 72px;
    max-width: 72px;
    flex: 0 0 72px;
    min-height: 38px;
    height: 38px;
    padding: 6px 8px;
    text-align: center;
    border-radius: 8px;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    color: var(--foreground);
    background: var(--background);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

input[type="number"].input-compact:hover:not(:disabled),
input.input-compact:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.2);
}

input[type="number"].input-compact:focus,
input[type="number"].input-compact:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: none;
    background: var(--popover);
}

/* Range Slider Row */
.range-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    width: 100%;
}

.range-row input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 24px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    outline: none;
}

.range-row input[type="range"]:focus-visible {
    outline: none;
}

/* WebKit Range Track */
.range-row input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.12);
    transition: background 0.15s ease;
}

.range-row input[type="range"]:hover:not(:disabled)::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.18);
}

.range-row input[type="range"]:focus-visible::-webkit-slider-runnable-track {
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* WebKit Range Thumb */
.range-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -6px; /* (6px track - 18px thumb) / 2 */
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #090D16;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 106, 0, 0.4);
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.range-row input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 0 2px var(--primary);
}

/* Firefox Range Track */
.range-row input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    transition: background 0.15s ease;
}

.range-row input[type="range"]:hover:not(:disabled)::-moz-range-track {
    background: rgba(255, 255, 255, 0.18);
}

.range-row input[type="range"]:focus-visible::-moz-range-track {
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Firefox Range Thumb */
.range-row input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #090D16;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

.range-row input[type="range"]:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.range-row-large {
    margin-top: 12px;
}

.relief-total {
    margin-top: 10px;
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 12.5px;
    line-height: 1.5;
}

#relief-controls {
    align-items: center;
}

#relief-controls[hidden] {
    display: none;
}

#relief-locked {
    border-left: 3px solid var(--border-strong);
    padding-left: 10px;
    color: var(--foreground-muted);
}

/* Disclosures ------------------------------------------------------------- */

.disclosure {
    margin-top: 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(13, 19, 31, 0.4);
    overflow: hidden;
}

.disclosure summary {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 10px 14px;
    color: var(--foreground-soft);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    transition: background-color 0.15s ease;
}

.disclosure summary:hover {
    background: rgba(255, 255, 255, 0.04);
}

.disclosure summary::-webkit-details-marker {
    display: none;
}

.disclosure summary::before {
    content: "+";
    width: 18px;
    color: var(--primary);
    font-family: var(--font-mono);
    font-size: 16px;
    line-height: 1;
}

.disclosure[open] summary::before {
    content: "\2212";
}

.disclosure .field-grid {
    margin: 0;
    padding: 0 14px 14px;
}

/* Route / Drop zone ------------------------------------------------------- */

.drop-zone {
    position: relative;
    display: flex;
    min-height: 72px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px 14px;
    border: 1.5px dashed var(--border-strong);
    border-radius: 10px;
    background: rgba(13, 19, 31, 0.6);
    color: var(--foreground-soft);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.drop-zone:hover,
.drop-zone.is-dragover {
    border-color: var(--primary);
    background: var(--primary-subtle);
    box-shadow: 0 0 16px rgba(255, 106, 0, 0.15);
}

.drop-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
}

.drop-input::-webkit-file-upload-button {
    visibility: hidden;
    display: none;
}

.drop-input::file-selector-button {
    visibility: hidden;
    display: none;
}

.drop-input:focus-visible + .drop-icon {
    outline: 2px solid var(--primary);
    outline-offset: 6px;
}

.drop-icon {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
    color: var(--primary);
    transition: transform 0.2s ease;
}

.drop-zone:hover .drop-icon {
    transform: translateY(-2px);
}

.drop-title {
    color: var(--foreground);
    font-size: 13px;
    font-weight: 600;
}

.drop-sub {
    color: var(--foreground-muted);
    font-size: 11px;
}

.button-row {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.gpx-name {
    margin-top: 8px;
    color: var(--foreground);
    font-size: 12.5px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
    padding: 0;
    border: none;
}

.stat-grid > div {
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
}

.stat-grid dt {
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stat-grid dd {
    margin: 2px 0 0;
    color: var(--foreground);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

#btn-autofit {
    margin-top: 12px;
}

.inline-error {
    margin-top: 12px;
    padding: 10px 14px;
    border-left: 3px solid var(--danger);
    border-radius: 0 10px 10px 0;
    background: var(--danger-soft);
    color: #ff8080;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.5;
}

/* Palette swatch groups --------------------------------------------------- */

.palette-groups {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.palette-group {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.palette-group legend {
    padding: 0;
    color: var(--foreground);
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.3;
}

.palette-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.palette-option {
    position: relative;
    display: flex;
    width: 70px;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.palette-option:hover {
    background: var(--secondary-hover);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.palette-option:has(.palette-input:focus-visible) {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.palette-option:has(.palette-input:checked) {
    border-color: var(--primary);
    background: rgba(255, 106, 0, 0.08);
    box-shadow: 0 0 14px rgba(255, 106, 0, 0.2);
}

.palette-swatch {
    position: relative;
    display: block;
    width: 24px;
    height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: var(--card);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.palette-option:has(.palette-input:checked) .palette-swatch {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.palette-check {
    position: absolute;
    right: -4px;
    bottom: -4px;
    display: none;
    width: 14px;
    height: 14px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary);
    color: #FFFFFF;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.palette-check svg {
    display: block;
    width: 9px;
    height: 9px;
}

.palette-option:has(.palette-input:checked) .palette-check {
    display: inline-flex;
}

.palette-label {
    display: block;
    width: 100%;
    color: var(--foreground-muted);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    transition: color 0.15s ease;
}

.palette-option:has(.palette-input:checked) .palette-label {
    color: #FFFFFF;
}

.palette-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    opacity: 0;
    pointer-events: none;
}

.palette-group.is-disabled {
    opacity: 0.55;
}

.palette-group.is-disabled .palette-option {
    cursor: not-allowed;
}

.palette-note {
    margin-top: 6px;
    color: var(--foreground-muted);
    font-size: 12px;
    line-height: 1.45;
}

/* Layer toggles ----------------------------------------------------------- */

.toggle-row {
    position: relative;
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    margin-top: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle-row:hover {
    background: var(--secondary-hover);
    border-color: rgba(255, 255, 255, 0.18);
}

.toggle-row:has(input:focus-visible) {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.toggle-row input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    opacity: 0;
    pointer-events: none;
}

.toggle-row:has(input:checked) {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.08);
}

.toggle-swatch {
    display: block;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: var(--card);
}

.toggle-copy strong {
    display: block;
    color: var(--foreground);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.25;
}

.toggle-copy span {
    display: block;
    margin-top: 1px;
    color: var(--foreground-muted);
    font-size: 11px;
    line-height: 1.3;
}

.toggle-state {
    min-width: 36px;
    padding: 2px 6px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--foreground-muted);
    font-family: var(--font-display);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-align: center;
    text-transform: uppercase;
    transition: all 0.2s ease;
}

.toggle-row:has(input:checked) .toggle-state {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.note-panel {
    margin-bottom: 22px;
    padding: 14px 18px;
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 12px;
    background: rgba(245, 158, 11, 0.08);
    color: #fcd34d;
    font-size: 13px;
    line-height: 1.55;
}

/* Base -------------------------------------------------------------------- */

.side-map {
    display: block;
    width: 96px;
    height: 96px;
    margin: 6px auto 8px;
}

.side-map-segment {
    fill: var(--card);
    stroke: var(--border-strong);
    stroke-width: 1;
    cursor: pointer;
    transition: fill 0.2s ease, stroke 0.2s ease;
}

.side-map-segment:hover {
    stroke: var(--primary);
}

.side-map-segment.is-filled {
    fill: rgba(255, 106, 0, 0.15);
    stroke: var(--primary);
}

.side-map-segment:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.side-map-number {
    fill: var(--foreground-muted);
    font-family: var(--font-display);
    font-size: 9.5px;
    font-weight: 700;
    text-anchor: middle;
    pointer-events: none;
}

.base-label-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.base-label-field {
    min-width: 0;
}

.base-label-field .field-label-row {
    margin-top: 0;
}

.char-count {
    color: var(--foreground-muted);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.label-input-row {
    display: flex;
    gap: 6px;
}

.label-input-row input {
    min-width: 0;
    flex: 1 1 auto;
}

.flip-btn {
    flex: 0 0 auto;
}

.flip-btn[aria-pressed="true"] {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-glow);
}

.check-row {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.check-row:hover {
    background: var(--secondary-hover);
    border-color: rgba(255, 255, 255, 0.18);
}

.base-colours-block {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.check-row input {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    flex: 0 0 auto;
    accent-color: var(--primary);
}

.check-row:has(input:focus-visible) {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.check-copy strong {
    display: block;
    color: var(--foreground);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
}

.check-copy span {
    display: block;
    margin-top: 3px;
    color: var(--foreground-muted);
    font-size: 12px;
    line-height: 1.45;
}

.base-dims {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 18px;
    padding: 0;
    border: none;
}

.base-dims > div {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--background);
}

.base-dims dt {
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.base-dims dd {
    margin: 3px 0 0;
    color: var(--foreground);
    font-family: var(--font-display);
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.3;
}

.colour-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 18px;
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--background);
}

.colour-summary-item {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    color: var(--foreground-soft);
    font-size: 12px;
    line-height: 1.35;
}

.colour-summary-item strong {
    display: block;
    color: var(--foreground);
    font-size: 12.5px;
    font-weight: 600;
}

.colour-summary-item span span {
    display: block;
    color: var(--foreground-muted);
    font-size: 11.5px;
}

.colour-summary-item .swatch {
    display: block;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: var(--card);
}

.colour-summary .btn {
    margin-left: auto;
}

/* Review and disclaimer --------------------------------------------------- */

.review-summary {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.review-placeholder {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--secondary);
}

.review-placeholder p:last-child {
    margin-top: 6px;
    color: var(--foreground-muted);
    font-size: 13.5px;
    line-height: 1.6;
}

.review-group {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--gradient-card-subtle);
}

.review-group header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.review-group h2 {
    color: var(--foreground);
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
}

.review-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 18px;
}

.review-list div {
    display: flex;
    min-width: 0;
    justify-content: space-between;
    gap: 10px;
    color: var(--foreground-muted);
    font-size: 12.5px;
}

.review-list dd {
    color: var(--foreground);
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 600;
    text-align: right;
}

.disclaimer-panel {
    margin-top: 22px;
    padding: 20px;
    border: 1px solid rgba(255, 106, 0, 0.22);
    border-radius: 14px;
    background: rgba(255, 106, 0, 0.05);
}

.disclaimer-panel h2 {
    color: var(--primary-glow);
    font-size: 15px;
    font-weight: 700;
}

.disclaimer-panel > p {
    margin-top: 8px;
    color: var(--foreground-soft);
    font-size: 13px;
    line-height: 1.6;
}

.disclaimer-check {
    margin-top: 14px;
    background: var(--card);
    border: 1px solid var(--border);
}

/* Action bar -------------------------------------------------------------- */

#step-actions {
    position: sticky;
    bottom: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
    padding: 10px 24px 12px;
    border-top: 1px solid var(--border);
    background: rgba(13, 20, 34, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.generate-status,
.purchase-note,
.action-hint {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.5;
}

.generate-status {
    color: var(--foreground-muted);
}

.purchase-note {
    color: var(--foreground-muted);
}

.action-hint {
    padding: 8px 14px;
    border-left: 3px solid var(--primary);
    border-radius: 0 8px 8px 0;
    background: var(--primary-soft);
    color: var(--foreground);
    font-weight: 600;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
}

#btn-next,
#btn-purchase {
    margin-left: auto;
}

/* Stage & Map ------------------------------------------------------------ */

#stage-panel {
    position: sticky;
    top: var(--top-bar-height);
    display: flex;
    min-width: 0;
    height: calc(100vh - var(--top-bar-height));
    min-height: 480px;
    padding: 20px 24px 18px;
    border-left: 1px solid var(--border);
    background: var(--background-deep);
}

.stage-view {
    display: flex;
    width: 100%;
    min-width: 0;
    flex-direction: column;
    gap: 12px;
}

.stage-head {
    display: flex;
    min-height: 36px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stage-head-left {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
}

.stage-kicker {
    display: inline-flex;
    align-items: center;
    color: var(--foreground);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.stage-chip {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 2px 10px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: var(--secondary);
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.stage-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

#preview-retry-inline {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 10.5px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.stage-chip[data-state="queued"] {
    border-color: rgba(0, 119, 255, 0.4);
    background: var(--accent-soft);
    color: var(--accent-glow);
}

.stage-chip[data-state="stale"] {
    border-color: rgba(245, 158, 11, 0.4);
    background: var(--warning-soft);
    color: #fbbf24;
}

.stage-chip[data-state="building"] {
    border-color: rgba(255, 106, 0, 0.4);
    background: var(--primary-soft);
    color: var(--primary-glow);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.stage-chip[data-state="building"]::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    animation: tk-beacon-pulse 1.3s ease-in-out infinite;
}

.switch-inline {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
}

.switch-inline input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.switch-inline span {
    position: relative;
    padding-left: 40px;
}

.switch-inline span::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    width: 32px;
    height: 18px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: var(--card);
    transform: translateY(-50%);
    transition: all 0.2s ease;
}

.switch-inline span::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--foreground-muted);
    transform: translateY(-50%);
    transition: left 120ms ease, background-color 120ms ease;
}

.switch-inline input:checked + span::before {
    border-color: var(--primary);
    background: var(--gradient-sunrise);
}

.switch-inline input:checked + span::after {
    left: 17px;
    background: #FFFFFF;
}

.switch-inline input:focus-visible + span::before {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Map Shell -------------------------------------------------------------- */

.map-shell {
    position: relative;
    min-height: 420px;
    flex: 1 1 auto;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--card);
    overflow: hidden;
    box-shadow: var(--shadow-medium);
}

/* Place search ------------------------------------------------------------ */

.location-search {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 700;
    width: min(380px, calc(100% - 32px));
    padding: 8px;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: rgba(15, 22, 38, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-medium);
}

.location-search-form {
    margin: 0;
}

.location-search-row {
    display: flex;
    min-width: 0;
    align-items: stretch;
    gap: 8px;
}

#location-search-input {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 13.5px;
    border-radius: 10px;
}

.location-search-button {
    min-height: 40px;
    flex: 0 0 auto;
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 10px;
}

.location-search-button .icon {
    width: 16px;
    height: 16px;
}

.location-selected {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.location-selected-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 1px;
}

.location-selected-kicker {
    color: var(--primary-glow);
    font-family: var(--font-ui);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1.3;
    text-transform: uppercase;
}

.location-selected-label {
    color: var(--foreground);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.location-selected .btn {
    min-height: 28px;
    flex: 0 0 auto;
    padding: 2px 8px;
    font-size: 11px;
}

.location-results {
    max-height: min(310px, 42vh);
    margin: 8px -8px -8px;
    padding: 0;
    border-top: 1px solid var(--border);
    background: var(--card);
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 0 0 12px 12px;
}

.location-result {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.location-result:last-child {
    border-bottom: 0;
}

.location-result:hover,
.location-result.is-active {
    background: var(--primary-soft);
}

.location-result.is-active {
    border-left-color: var(--primary);
}

.location-result-name {
    color: var(--foreground);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.location-result-context {
    color: var(--foreground-muted);
    font-size: 11.5px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.location-result-tag {
    color: var(--primary-glow);
    font-family: var(--font-display);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.4;
    text-transform: uppercase;
}

.location-feedback {
    margin-top: 7px;
    color: var(--foreground-muted);
    font-size: 11.5px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.location-feedback[data-state="error"] {
    padding-left: 8px;
    border-left: 3px solid var(--danger);
    color: #ff8080;
    font-weight: 600;
}

.location-feedback[data-state="success"] {
    padding-left: 8px;
    border-left: 3px solid var(--success);
    color: var(--foreground-soft);
}

.location-feedback[data-state="loading"] {
    color: var(--foreground-soft);
}

.location-attribution {
    margin-top: 7px;
    color: var(--foreground-subtle);
    font-family: var(--font-ui);
    font-size: 9px;
    line-height: 1.45;
}

.location-attribution a {
    color: var(--foreground-muted);
    text-decoration: underline;
}

#map {
    position: absolute;
    inset: 0;
    z-index: 0;
}

#shape-overlay {
    position: absolute;
    inset: 0;
    z-index: 500;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

.shape-polygon-casing {
    fill: none;
    stroke: rgba(255, 255, 255, 0.95);
    stroke-width: 8;
    stroke-linejoin: round;
    pointer-events: none;
}

.shape-polygon {
    fill: rgba(15, 23, 42, 0.08);
    fill-opacity: 1;
    stroke: #0F172A;
    stroke-width: 3.5;
    stroke-linejoin: round;
    filter: drop-shadow(0 2px 6px rgba(15, 23, 42, 0.35));
    pointer-events: all;
    cursor: move;
}

.rotation-line-casing {
    stroke: rgba(255, 255, 255, 0.95);
    stroke-width: 5.5;
    pointer-events: none;
}

.rotation-line {
    stroke: #0F172A;
    stroke-width: 2.2;
    stroke-dasharray: 5 5;
    pointer-events: none;
}

.rotation-knob {
    fill: #6D28D9;
    stroke: #FFFFFF;
    stroke-width: 2.5;
    pointer-events: all;
    cursor: grab;
    filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.65));
}

.shape-handle {
    fill: #FFFFFF;
    stroke: #0F172A;
    stroke-width: 3;
    pointer-events: all;
    cursor: nwse-resize;
    filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.65));
}

.shape-handle-radius {
    cursor: ew-resize;
}

.map-hud {
    position: absolute;
    top: auto;
    bottom: 16px;
    left: 16px;
    z-index: 650;
    width: min(290px, calc(100% - 32px));
    padding: 14px 16px;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: rgba(15, 22, 38, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-medium);
}

.map-hud-kicker {
    color: var(--primary-glow);
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.map-hud-value {
    margin-top: 3px;
    color: var(--foreground);
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
}

.map-hud-meta {
    margin-top: 2px;
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 11px;
    line-height: 1.4;
}

.map-howto {
    margin-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 7px;
}

.map-howto summary {
    color: var(--primary);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.map-howto summary::-webkit-details-marker {
    display: none;
}

.map-howto summary::before {
    content: "+";
    display: inline-block;
    width: 14px;
    font-family: var(--font-mono);
}

.map-howto[open] summary::before {
    content: "\2212";
}

.map-howto p {
    margin-top: 5px;
    color: var(--foreground-muted);
    font-size: 11.5px;
    line-height: 1.5;
}

.stage-footnote {
    color: var(--foreground-subtle);
    font-family: var(--font-ui);
    font-size: 10px;
    letter-spacing: 0.02em;
    line-height: 1.45;
}

.stage-footnote a {
    color: var(--foreground-muted);
}

/* Leaflet restyle --------------------------------------------------------- */

.leaflet-container {
    background: #E2E8F0;
    color: var(--foreground);
    font-family: var(--font-ui);
    font-size: 12px;
}

.leaflet-tile-pane {
    filter: none;
}

.gpx-route-line {
    filter: drop-shadow(0 1px 4px rgba(15, 23, 42, 0.55));
}

.leaflet-bar {
    overflow: hidden;
    border: 1px solid var(--border-strong) !important;
    border-radius: 10px !important;
    box-shadow: var(--shadow-soft) !important;
}

.leaflet-bar a,
.leaflet-bar a:hover {
    border-bottom: 1px solid var(--border) !important;
    background: var(--secondary) !important;
    color: var(--foreground) !important;
    line-height: 28px;
}

.leaflet-bar a:last-child {
    border-bottom: 0 !important;
}

.leaflet-bar a:hover {
    background: var(--secondary-hover) !important;
}

.leaflet-control-zoom a {
    width: 30px !important;
    height: 30px !important;
    font-size: 17px !important;
}

.leaflet-control-attribution {
    background: rgba(9, 13, 22, 0.85) !important;
    color: var(--foreground-subtle) !important;
    font-size: 9px !important;
    border-radius: 4px;
}

.leaflet-control-attribution a {
    color: var(--foreground-muted) !important;
}

.leaflet-control-scale-line {
    border-color: var(--foreground-muted) !important;
    background: rgba(9, 13, 22, 0.85) !important;
    color: var(--foreground-soft) !important;
    font-family: var(--font-display);
    font-size: 9px;
}

.centre-marker {
    background: transparent;
    border: 0;
}

.centre-marker-ring,
.centre-marker-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.centre-marker-ring {
    width: 24px;
    height: 24px;
    border: 2.5px solid #0F172A;
    background: rgba(255, 255, 255, 0.75);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95), 0 2px 8px rgba(15, 23, 42, 0.55);
}

.centre-marker-dot {
    width: 9px;
    height: 9px;
    border: 1.5px solid #FFFFFF;
    background: #0F172A;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.6);
}

/* 3D Preview -------------------------------------------------------------- */

.preview-host {
    position: relative;
    min-height: 420px;
    flex: 1 1 auto;
    border: 1px solid var(--border);
    border-radius: 16px;
    background-color: var(--background-deep);
    background-image: 
        radial-gradient(ellipse 600px 300px at 50% 50%, rgba(255, 106, 0, 0.04) 0%, transparent 60%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M24 0H0V24' fill='none' stroke='%23131B2E' stroke-width='1'/%3E%3C/svg%3E");
    background-size: auto, 24px 24px;
    overflow: hidden;
    box-shadow: var(--shadow-medium);
}

.preview-canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    background: transparent;
}

.preview-host.is-updating::after {
    content: "Updating preview…";
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 3;
    padding: 6px 14px;
    border: 1px solid rgba(255, 106, 0, 0.4);
    border-radius: 9999px;
    background: rgba(15, 22, 38, 0.92);
    color: var(--primary-glow);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    pointer-events: none;
    box-shadow: 0 0 16px rgba(255, 106, 0, 0.25);
    animation: tk-badge-breathe 2s ease-in-out infinite;
}

.preview-empty {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px;
    background: rgba(9, 13, 22, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    text-align: center;
}

.preview-host.has-model .preview-empty {
    display: none;
}

.preview-spinner-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    margin-bottom: 4px;
}

.preview-spinner-ring {
    display: none;
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 106, 0, 0.12);
    border-top-color: var(--primary);
    border-right-color: var(--primary-glow);
    filter: drop-shadow(0 0 10px rgba(255, 106, 0, 0.45));
    animation: tk-spin 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.preview-spinner-ring::before {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    border: 1.5px solid transparent;
    border-bottom-color: rgba(0, 119, 255, 0.6);
    border-left-color: rgba(77, 210, 255, 0.85);
    animation: tk-spin-reverse 1.8s linear infinite;
}

.preview-empty.is-loading .preview-spinner-ring,
#preview-panel[aria-busy="true"] .preview-empty .preview-spinner-ring,
.stage-view[aria-busy="true"] .preview-empty .preview-spinner-ring {
    display: block;
}

.preview-empty-icon {
    width: 38px;
    height: 38px;
    color: var(--primary);
    filter: drop-shadow(0 0 16px rgba(255, 106, 0, 0.35));
    transition: transform 0.3s ease, filter 0.3s ease;
}

.preview-empty.is-loading .preview-empty-icon,
#preview-panel[aria-busy="true"] .preview-empty-icon,
.stage-view[aria-busy="true"] .preview-empty-icon {
    animation: tk-icon-breathe 2.4s ease-in-out infinite;
    color: var(--primary-glow);
}

.preview-empty-title {
    color: var(--foreground);
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.015em;
}

.preview-empty-copy {
    max-width: 36ch;
    color: var(--foreground-muted);
    font-size: 13px;
    line-height: 1.55;
}

.preview-empty-live {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding: 5px 14px;
    border-radius: 9999px;
    background: rgba(15, 22, 38, 0.88);
    border: 1px solid rgba(255, 106, 0, 0.3);
    box-shadow: 0 0 14px rgba(255, 106, 0, 0.12);
}

.preview-empty.is-loading .preview-empty-live,
#preview-panel[aria-busy="true"] .preview-empty-live,
.stage-view[aria-busy="true"] .preview-empty-live {
    display: inline-flex !important;
}

.preview-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    animation: tk-beacon-pulse 1.2s ease-in-out infinite;
    flex-shrink: 0;
}

.preview-live-text {
    color: var(--foreground-soft);
    font-family: var(--font-ui);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.preview-empty .btn {
    margin-top: 10px;
}

.preview-progress {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
}

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

.preview-progress-label-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.preview-progress-spinner {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid rgba(255, 106, 0, 0.2);
    border-top-color: var(--primary);
    border-right-color: var(--primary-glow);
    animation: tk-spin 0.85s linear infinite;
    flex-shrink: 0;
}

.preview-progress-phase {
    color: var(--foreground-soft);
    font-family: var(--font-ui);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.preview-progress-pct {
    color: var(--primary-glow);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
}

.preview-progress-track {
    position: relative;
    height: 6px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.preview-progress-fill {
    display: block;
    position: relative;
    width: 0;
    height: 100%;
    border-radius: 9999px;
    background: var(--gradient-sunrise);
    box-shadow: 0 0 12px rgba(255, 106, 0, 0.6);
    transition: width 140ms ease;
    overflow: hidden;
}

.preview-progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.55) 50%,
        transparent 100%
    );
    animation: tk-shimmer 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes tk-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes tk-spin-reverse {
    from {
        transform: rotate(360deg);
    }
    to {
        transform: rotate(0deg);
    }
}

@keyframes tk-icon-breathe {
    0%, 100% {
        transform: scale(0.94);
        opacity: 0.82;
        filter: drop-shadow(0 0 10px rgba(255, 106, 0, 0.4));
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
        filter: drop-shadow(0 0 20px rgba(255, 106, 0, 0.7));
    }
}

@keyframes tk-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(250%);
    }
}

@keyframes tk-beacon-pulse {
    0%, 100% {
        transform: scale(0.75);
        opacity: 0.5;
        box-shadow: 0 0 2px var(--primary);
    }
    50% {
        transform: scale(1.25);
        opacity: 1;
        box-shadow: 0 0 10px var(--primary-glow);
    }
}

@keyframes tk-badge-breathe {
    0%, 100% {
        border-color: rgba(255, 106, 0, 0.3);
        box-shadow: 0 0 8px rgba(255, 106, 0, 0.15);
    }
    50% {
        border-color: rgba(255, 106, 0, 0.65);
        box-shadow: 0 0 18px rgba(255, 106, 0, 0.4);
    }
}

.preview-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}

.preview-stats > div {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
}

.preview-stats dt {
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.preview-stats dd {
    margin: 3px 0 0;
    color: var(--foreground);
    font-family: var(--font-display);
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.3;
}

/* Projects Dialog --------------------------------------------------------- */

.projects-dialog {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    background: rgba(6, 9, 16, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.projects-panel {
    display: flex;
    width: min(740px, 100%);
    max-height: calc(100vh - 40px);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    background: var(--card);
    box-shadow: var(--shadow-strong);
}

.projects-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 26px 16px;
    border-bottom: 1px solid var(--border);
}

.projects-head h2 {
    margin-top: 3px;
    color: var(--foreground);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.projects-intro {
    padding: 16px 26px 0;
    color: var(--foreground-muted);
    font-size: 13px;
    line-height: 1.55;
}

.project-save {
    padding: 16px 26px 20px;
    border-bottom: 1px solid var(--border);
}

.project-save > label {
    display: block;
    margin-bottom: 8px;
    color: var(--foreground-soft);
    font-size: 13px;
    font-weight: 600;
}

.project-save-row {
    display: flex;
    gap: 10px;
}

.project-save-row input {
    min-width: 0;
    flex: 1 1 auto;
}

.project-storage-note {
    margin-top: 8px;
    color: var(--foreground-muted);
    font-size: 12px;
    line-height: 1.45;
}

.project-storage-note.is-error {
    color: #ff8080;
}

.projects-dialog .inline-error,
.projects-dialog .project-feedback {
    margin: 12px 26px 0;
}

.project-feedback {
    padding: 10px 14px;
    border-left: 3px solid var(--primary);
    border-radius: 0 8px 8px 0;
    background: var(--primary-soft);
    color: var(--foreground);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.5;
}

.projects-saved {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 18px 26px 24px;
}

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

.projects-saved-head h3 {
    color: var(--foreground);
    font-size: 15px;
    font-weight: 700;
}

.projects-loading {
    color: var(--foreground-muted);
    font-size: 12.5px;
}

.projects-empty {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(13, 19, 31, 0.5);
    text-align: center;
}

.projects-empty-title {
    color: var(--foreground);
    font-size: 14px;
    font-weight: 700;
}

.projects-empty-copy {
    margin-top: 4px;
    color: var(--foreground-muted);
    font-size: 12.5px;
    line-height: 1.5;
}

.projects-list {
    display: flex;
    min-height: 0;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-top: 1px solid var(--border);
}

.project-item:first-child {
    border-top: 0;
}

.project-item-main {
    min-width: 0;
}

.project-item-name {
    color: var(--foreground);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.project-item-meta,
.project-item-specs {
    color: var(--foreground-muted);
    font-family: var(--font-ui);
    font-size: 11px;
    line-height: 1.45;
}

.project-item-specs {
    margin-top: 2px;
    color: var(--foreground-soft);
}

.project-item-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}

/* Footer and no-script ---------------------------------------------------- */

#page-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    width: 100%;
    max-width: 1720px;
    margin: 0 auto;
    padding: 18px 28px;
    border-top: 1px solid var(--border);
    background: var(--background);
    color: var(--foreground-subtle);
    font-size: 11.5px;
    line-height: 1.5;
}

#page-footer a {
    color: var(--foreground-muted);
}

.noscript-note {
    max-width: 640px;
    margin: 40px auto;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
    color: var(--foreground);
    font-size: 14px;
    line-height: 1.55;
    text-align: center;
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 1160px) {
    :root {
        --top-bar-height: 120px;
    }

    #top-bar {
        grid-template-columns: minmax(0, 1fr) auto;
        row-gap: 12px;
        padding: 12px 22px;
    }

    #wizard-steps {
        grid-column: 1 / -1;
        grid-row: 2;
        max-width: 100%;
        justify-self: stretch;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }

    .step-tab {
        padding: 6px 10px;
    }
}

@media (max-width: 980px) {
    :root {
        --top-bar-height: 0px;
    }

    #top-bar {
        position: sticky;
        grid-template-columns: minmax(0, 1fr) auto;
        padding: 10px 16px;
    }

    #studio {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        border-left: 0;
        border-right: 0;
    }

    #stage-panel {
        position: relative;
        top: auto;
        order: -1;
        align-self: stretch;
        width: 100%;
        height: clamp(320px, 44vh, 480px);
        min-height: 0;
        padding: 14px 16px 12px;
        border-left: 0;
        border-bottom: 1px solid var(--border);
    }

    .stage-head {
        min-height: 30px;
    }

    .map-shell,
    .preview-host {
        min-height: 0;
    }

    #wizard-panel {
        min-height: 0;
        border-right: 0;
    }

    .step-panel {
        padding: 26px 20px 22px;
    }

    #step-actions {
        position: sticky;
        bottom: 0;
        padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .preview-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .projects-dialog {
        padding: 0;
    }

    .projects-panel {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        border: 0;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 14px;
    }

    #top-bar {
        gap: 8px;
        padding: 8px 12px;
    }

    .brand {
        gap: 8px;
    }

    .brand-mark {
        width: 30px;
        height: 30px;
        border-radius: 8px;
    }

    .brand-mark svg {
        width: 16px;
        height: 16px;
    }

    .brand-name {
        font-size: 18px;
    }

    .brand-studio {
        display: none;
    }

    .top-actions {
        gap: 6px;
    }

    .top-actions .btn {
        min-height: 36px;
        padding: 6px 12px;
        font-size: 12px;
    }

    .preview-chip {
        display: none;
    }

    .step-name {
        display: none;
    }

    .step-tab {
        padding: 6px 8px;
    }

    #stage-panel {
        height: clamp(340px, 48vh, 440px);
        padding: 10px 12px 8px;
    }

    .map-hud {
        bottom: 8px;
        left: 8px;
        width: min(240px, calc(100% - 16px));
        padding: 10px 12px;
    }
}
