/* v2 copy of /styles.css. Only change: the mobile media query also covers short touch screens (phone landscape). /styles.css stays the v1 file. */
:root {
    --topbar-h: 56px;
    --sheet-radius: 18px;
    --panel-bg: rgba(8, 15, 16, 0.92);
    --panel-border: rgba(59, 73, 75, 0.72);
    --shadow-heavy: 0 24px 70px rgba(0, 0, 0, 0.48);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: #080f10;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: clip;
}

button,
input {
    font: inherit;
}

.app-shell {
    display: flex;
    flex-direction: column;
}

.app-topbar {
    gap: 18px;
}

.app-title {
    font-family: "Space Grotesk", sans-serif;
    letter-spacing: 0;
    white-space: nowrap;
}

.brand-lockup {
    min-width: 0;
}

.kpi-strip {
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.kpi-strip::-webkit-scrollbar {
    display: none;
}

.kpi-chip {
    flex: 0 0 auto;
    min-height: 32px;
    white-space: nowrap;
}

.kpi-chip b {
    font-variant-numeric: tabular-nums;
}

.app-main {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

.parameter-panel {
    position: relative;
}

.sheet-header,
.sheet-grip {
    display: none;
}

.parameter-form {
    width: 100%;
}

.control-field input {
    min-height: 34px;
}

.form-actions {
    min-width: 330px;
}

.legend-row {
    min-height: 32px;
}

.canvas-stage {
    position: relative;
    display: block;
    min-height: min(68vh, 760px);
    overflow: hidden;
    overscroll-behavior: contain;
}

#tree-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    touch-action: none;
}

#tree-canvas.dragging {
    cursor: grabbing;
}

#canvas-tooltip {
    position: fixed;
    pointer-events: none;
    background: rgba(22, 27, 34, 0.95);
    border: 1px solid #3b494b;
    border-radius: 4px;
    padding: 8px 12px;
    font-family: "Roboto Mono", monospace;
    font-size: 12px;
    color: #dce4e5;
    display: none;
    z-index: 1000;
    white-space: nowrap;
}

.scale-toggle button {
    min-height: 28px;
}

.parameters-fab,
.parameter-backdrop {
    display: none;
}

.sheet-icon-btn {
    display: inline-grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    background: rgba(21, 29, 30, 0.92);
    color: #dce4e5;
}

.sheet-icon-btn .material-symbols-outlined {
    font-size: 20px;
}

@media (max-width: 1180px) {
    .app-topbar {
        padding-inline: 16px;
    }

    .app-title {
        font-size: 18px;
    }

    .kpi-chip-wide .kpi-chip-label {
        display: none;
    }

    .parameter-form {
        gap: 14px 18px;
    }

    .form-actions {
        flex-basis: 100%;
        justify-content: space-between;
        min-width: 0;
    }
}

@media (max-width: 760px), (max-height: 500px) and (pointer: coarse) {
    :root {
        --topbar-h: 64px;
    }

    body.sheet-open {
        overflow: hidden;
    }

    .app-topbar {
        height: var(--topbar-h);
        align-items: stretch;
        flex-direction: column;
        justify-content: center;
        gap: 7px;
        padding: 8px 12px 7px;
    }

    .brand-lockup {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .app-title {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 15px;
        line-height: 1;
    }

    #loading {
        flex: 0 0 auto;
        font-size: 10px;
    }

    .kpi-strip {
        width: calc(100vw - 24px);
        gap: 8px;
    }

    .kpi-chip {
        min-height: 28px;
        gap: 8px;
        padding: 5px 9px;
        border-radius: 999px;
        font-size: 11px;
    }

    .kpi-chip-label {
        font-size: 9px;
    }

    .kpi-divider {
        display: none;
    }

    .app-main {
        padding-top: var(--topbar-h);
        min-height: 100dvh;
    }

    .parameter-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 70;
        max-height: min(82dvh, 680px);
        padding: 10px 16px 18px;
        border: 1px solid var(--panel-border);
        border-bottom: 0;
        border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
        background: var(--panel-bg);
        box-shadow: var(--shadow-heavy);
        transform: translateY(calc(100% - 26px));
        transition: transform 220ms ease, box-shadow 220ms ease;
        overflow: auto;
        overscroll-behavior: contain;
    }

    #parameter-panel {
        z-index: 80;
    }

    body.sheet-open .parameter-panel {
        transform: translateY(0);
    }

    .sheet-grip {
        display: block;
        width: 42px;
        height: 4px;
        margin: 0 auto 10px;
        border-radius: 999px;
        background: #849495;
        opacity: 0.65;
    }

    .sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 14px;
    }

    .sheet-kicker {
        margin: 0 0 2px;
        color: #849495;
        font: 700 10px/1 "Inter", sans-serif;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .sheet-header h2 {
        margin: 0;
        color: #dce4e5;
        font: 700 18px/1.1 "Inter", sans-serif;
    }

    .parameter-form {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px 12px;
    }

    .control-field {
        width: auto;
        min-width: 0;
    }

    .control-field input {
        min-height: 42px;
        font-size: 16px;
    }

    .form-actions {
        grid-column: 1 / -1;
        display: grid;
        gap: 14px;
        min-width: 0;
    }

    .legend-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 9px;
        border-right: 0;
        padding-right: 0;
    }

    #calculate-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .canvas-stage {
        min-height: calc(100dvh - var(--topbar-h));
        height: calc(100dvh - var(--topbar-h));
    }

    .scale-toggle {
        top: 12px;
        right: 12px;
        max-width: calc(100vw - 24px);
    }

    .scale-toggle button {
        padding: 6px 10px;
        font-size: 9px;
    }

    .canvas-stage .canvas-credit {
        display: none !important;
    }

    .canvas-stage .canvas-hints {
        left: 14px !important;
        right: auto !important;
        bottom: 18px;
        width: auto;
        align-items: flex-start;
        transform: none !important;
    }

    .hint-row {
        gap: 0;
        padding: 0;
        border: 1px solid rgba(59, 73, 75, 0.65);
        border-radius: 999px;
        background: rgba(8, 15, 16, 0.76);
        backdrop-filter: blur(10px);
    }

    .hint-copy,
    .hint-separator {
        display: none;
    }

    #nav-tree-stats {
        padding: 10px 12px;
        border: 0;
        background: transparent;
    }

    #nav-n-label,
    #nav-tree-stats span:nth-child(2) {
        display: none;
    }

    #canvas-tooltip {
        display: none !important;
    }

    .parameter-backdrop {
        position: fixed;
        inset: 0;
        z-index: 60;
        background: rgba(0, 0, 0, 0.42);
        backdrop-filter: blur(2px);
    }

    body.sheet-open .parameter-backdrop {
        display: block;
    }

    .parameters-fab {
        position: fixed;
        right: 14px;
        bottom: 18px;
        z-index: 55;
        display: inline-flex;
        align-items: center;
        gap: 7px;
        min-height: 44px;
        padding: 0 14px;
        border: 1px solid rgba(0, 240, 255, 0.35);
        border-radius: 999px;
        background: #00f0ff;
        color: #00363a;
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.44), 0 0 18px rgba(0, 240, 255, 0.24);
        font: 800 11px/1 "Inter", sans-serif;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .parameters-fab .material-symbols-outlined {
        font-size: 18px;
    }

    body.sheet-open .parameters-fab {
        display: none;
    }
}

@media (max-width: 420px) {
    .kpi-chip {
        font-size: 10px;
    }

    .parameter-form {
        grid-template-columns: 1fr;
    }

    #nav-tree-stats {
        padding-inline: 11px;
    }
}
