:root {
    color-scheme: light;
    font-family: "Sansita", Arial, sans-serif;
    color: #102a43;
    background: #eef3f7;
    font-synthesis: none;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
}
button, input, select {
    font: inherit;
}
button, select, a {
    -webkit-tap-highlight-color: transparent;
}
button, .header-actions a {
    min-height: 42px;
    padding: 9px 15px;
    border: 1px solid #b9c9d7;
    border-radius: 7px;
    color: #102a43;
    background: #ffffff;
    cursor: pointer;
}
button:disabled {
    cursor: default;
    opacity: 0.45;
}
button.primary {
    color: #ffffff;
    background: #102a43;
    border-color: #102a43;
}
button:hover:not(:disabled) {
    border-color: #ed8d2d;
}
:focus-visible {
    outline: 3px solid #ed8d2d;
    outline-offset: 3px;
}
[hidden] {
    display: none !important;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px max(20px, calc((100vw - 1420px) / 2));
    background: #102a43;
    color: #ffffff;
}
.page-header img {
    display: block;
    width: min(340px, 45vw);
    height: auto;
}
.free-draw-brand {
    position: relative;
}
.free-draw-brand .brand-version {
    position: absolute;
    left: calc(100% + 8px);
    top: 3px;
    color: #aebcc8;
    font: 400 9px/12px 'Sansita', Arial, sans-serif;
    white-space: nowrap;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 13px;
}
.header-actions a {
    text-decoration: none;
    white-space: nowrap;
}
.header-actions span {
    color: #e4edf4;
}
main {
    max-width: 1460px;
    margin: 0 auto;
    padding: 28px 20px 40px;
}
.page-title, .card-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.eyebrow {
    color: #536c81;
    font-size: 12px;
    letter-spacing: 0.12em;
    margin: 0 0 6px;
}
h1 {
    font-size: clamp(25px, 3vw, 36px);
    margin: 0;
}
h2 {
    font-size: 20px;
    margin: 0;
}
.intro {
    margin: 12px 0 24px;
    color: #466078;
    line-height: 1.5;
}
.badge {
    background: #fff3e5;
    color: #874400;
    padding: 7px 12px;
    border-radius: 20px;
    white-space: nowrap;
    font-size: 13px;
}
.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    align-items: start;
    gap: 20px;
}
.drawing-card, .measurement-card {
    min-width: 0;
    background: #ffffff;
    border: 1px solid #d6e0e8;
    border-radius: 12px;
    padding: 20px;
}
.card-heading span {
    font-size: 13px;
    color: #536c81;
}
.drawing-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}
.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
    min-height: 42px;
    cursor: pointer;
}
.toggle input {
    width: 19px;
    height: 19px;
    accent-color: #102a43;
}
.drawing-help, .field-help, #measurementHint {
    color: #536c81;
    font-size: 14px;
    line-height: 1.5;
}
#drawing {
    width: 100%;
    display: block;
    border: 1px solid #cbd8e2;
    border-radius: 8px;
    background: #fbfdff;
    touch-action: none;
    cursor: crosshair;
}
#drawing.is-closed {
    touch-action: pan-y;
    cursor: default;
}
.room-fill {
    fill: #e9f1f8;
    fill-opacity: 0.75;
    stroke: #102a43;
    stroke-width: 4;
}
.wall-line {
    fill: none;
    stroke: #102a43;
    stroke-width: 4;
    stroke-linejoin: round;
}
.corner {
    fill: #ffffff;
    stroke: #102a43;
    stroke-width: 3;
}
.start-corner {
    stroke: #d67518;
    stroke-width: 4;
}
.preview-line {
    stroke: #d67518;
    stroke-width: 3;
    stroke-dasharray: 10 6;
    fill: none;
}
.wall-label {
    fill: #102a43;
    font-family: Arial, sans-serif;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
    paint-order: stroke;
    stroke: #ffffff;
    stroke-linejoin: round;
}
.wall-measurement {
    font-weight: 400;
}
#drawing.is-measured #drawingGrid {
    display: none;
}
#drawing.has-tiles .room-fill {
    fill: none;
}
.tile-grout-background {
    fill: #bdc9d3;
}
.free-draw-tile {
    fill: #ffffff;
    stroke: #9baebd;
    stroke-width: 0.55;
}
.tile-wall-reference {
    stroke: transparent;
    pointer-events: stroke;
    cursor: pointer;
}
.tile-wall-highlight {
    stroke: #a535ff;
    pointer-events: none;
}
.tile-wall-label {
    cursor: pointer;
}
.tile-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.tile-fields label {
    min-width: 0;
    font-size: 12px;
}
.tile-fields input,
.tile-fields select {
    width: 100%;
    min-height: 36px;
    margin-top: 4px;
    padding: 6px;
}
.tile-position-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0;
}
.tile-position-toggle input {
    width: auto;
    min-height: 0;
    margin: 0;
}
.tile-help {
    overflow-wrap: anywhere;
    font-size: 12px;
    line-height: 1.4;
}
.drawing-footer {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    font-size: 12px;
    color: #536c81;
}
.message {
    margin: 16px 0 0;
    padding: 12px;
    border-radius: 7px;
    font-size: 14px;
    line-height: 1.5;
    background: #f0f5f9;
}
.message.error {
    background: #fff0ed;
    color: #9f3020;
}
.message.success {
    background: #eaf5ee;
    color: #245a37;
}
.calculate-label {
    display: block;
    margin: 18px 0 7px;
    font-weight: 700;
}
select {
    width: 100%;
    min-height: 44px;
    padding: 8px;
    border: 1px solid #b9c9d7;
    border-radius: 6px;
    color: #102a43;
    background: #ffffff;
}
.wall-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 130px;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-top: 1px solid #e5edf3;
}
.wall-field label small {
    display: block;
    margin-top: 4px;
    color: #647e93;
    font-size: 12px;
    font-weight: 400;
}
.wall-field input {
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid #b9c9d7;
    border-radius: 6px;
    color: #102a43;
    background: #ffffff;
}
.wall-field input:disabled {
    background: #eef3f7;
    color: #536c81;
}
.calculate-button {
    width: 100%;
    margin-top: 14px;
}
.result {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid #b9d7c4;
    border-radius: 8px;
    background: #f0f8f3;
    line-height: 1.6;
}
.result p {
    margin: 4px 0;
}
.result strong {
    display: block;
}
.scope-note {
    border-top: 1px solid #e5edf3;
    padding-top: 16px;
    margin: 20px 0 0;
    color: #647e93;
    font-size: 13px;
    line-height: 1.5;
}
@media (max-width: 900px) {
    .workspace {
        grid-template-columns: 1fr;
    }
    .header-actions {
        gap: 10px;
    }
    .header-actions span {
        display: none;
    }
}
@media (max-width: 480px) {
    main {
        padding: 20px 12px 30px;
    }
    .page-header {
        padding: 12px;
    }
    .page-header img {
        width: 200px;
        max-width: 52vw;
    }
    .header-actions a {
        font-size: 12px;
        padding: 10px;
    }
    .drawing-card, .measurement-card {
        padding: 14px;
    }
    .badge {
        display: none;
    }
    .card-heading {
        align-items: start;
    }
    .card-heading span {
        text-align: right;
    }
    .toggle {
        width: 100%;
    }
    .drawing-toolbar button {
        flex: 1;
        padding-inline: 6px;
        font-size: 13px;
    }
    #keyboardHelp {
        display: none;
    }
}

@media (min-width: 901px) {
    .measurement-legend {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 12px;
        padding: 10px 0 14px;
        font-size: 12px;
    }
    .measurement-card .measurement-verified {
        color: #245a37;
    }
    .measurement-card .measurement-pending {
        color: #145ba0;
    }
    .measurement-card .measurement-error {
        color: #a12b20;
    }
    .wall-field input.measurement-verified {
        border-color: #6e9e7f;
        background: #f2f8f4;
    }
    .wall-field input.measurement-pending {
        border-color: #80a9cf;
        background: #f2f7fc;
    }
    .wall-field input.measurement-error {
        border-color: #c25b50;
        background: #fff2ef;
    }
    .wall-field input::placeholder {
        color: currentColor;
        opacity: 0.85;
    }
    .wall-label.measurement-verified {
        fill: #245a37;
    }
    .wall-label.measurement-pending {
        fill: #145ba0;
    }
    .wall-label.measurement-error {
        fill: #a12b20;
    }
}

@media (min-width: 901px) {
    #drawing {
        max-height: max(1px, calc(100vh - 220px));
        max-height: max(1px, calc(100dvh - 220px));
    }
}

@media (min-width: 901px) {
    /* Keep the compact control positions out of the desktop first paint.
       JavaScript moves these same nodes into the header and step drawers. */
    #angledModeControl,
    #drawingCard > #drawingCardHeading,
    #drawingCard > #drawingToolbar,
    #drawingCard > #drawingHelp,
    #drawingCard > #drawingFooter,
    #drawingCard > #message,
    html:not(.free-draw-ready) #stepTwoDrawer > .step-content {
        display: none;
    }
    .page-header {
        padding-block: 8px;
    }
    .page-header img {
        width: 230px;
    }
    main {
        padding-top: 12px;
    }
    .page-title,
    .intro {
        display: none;
    }
    .shift-hint {
        margin-right: auto;
        font-size: 13px;
        color: #536c81;
    }
}

@media (min-width: 901px) {
    .page-header {
        display: grid;
        grid-template-columns: 150px minmax(0, 1fr) auto;
        align-items: center;
        gap: 12px;
        padding-block: 6px;
    }
    .page-header img {
        width: 150px;
    }
    .header-actions {
        flex-direction: row;
        gap: 10px;
        font-size: 10px;
    }
    .header-actions a {
        min-height: 30px;
        padding: 6px 10px;
        font-size: 12px;
    }
    .desktop-drawing-header {
        display: flex;
        align-items: center;
        min-width: 0;
        gap: 4px;
    }
    .desktop-drawing-top {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 4px 12px;
        min-width: 0;
    }
    .desktop-drawing-header .card-heading {
        gap: 8px;
    }
    .desktop-drawing-header h2 {
        font-size: 14px;
        white-space: nowrap;
    }
    .desktop-drawing-header .card-heading span {
        font-size: 11px;
        color: #cbdbe8;
        white-space: nowrap;
    }
    .desktop-drawing-header .drawing-toolbar {
        margin: 0 0 0 auto;
        gap: 6px;
        flex-wrap: nowrap;
    }
    .desktop-drawing-header .drawing-toolbar button {
        min-height: 30px;
        padding: 6px 10px;
        font-size: 12px;
    }
    .desktop-drawing-header .drawing-toolbar .primary {
        background: #ed8d2d;
        border-color: #ed8d2d;
        color: #102a43;
    }
    .desktop-drawing-header .shift-hint {
        display: none;
    }
    .desktop-drawing-details {
        display: flex;
        align-items: center;
        gap: 12px;
        min-width: 0;
    }
    .desktop-drawing-header .drawing-help {
        flex: 1;
        min-width: 0;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 11px;
        line-height: 1.2;
        color: #cbdbe8;
    }
    .desktop-drawing-header .drawing-footer {
        flex: 0 0 auto;
        margin: 0;
        font-size: 11px;
        line-height: 1.2;
        color: #cbdbe8;
    }
    .desktop-drawing-header #keyboardHelp {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
    .desktop-drawing-header .message {
        margin: 0;
        padding: 0;
        border-radius: 0;
        background: transparent;
        font-size: 11px;
        line-height: 1.2;
        color: #cbdbe8;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .desktop-drawing-header .message.error {
        color: #ffc4bb;
    }
    .desktop-drawing-header .message.success {
        color: #b9e5c6;
    }
    main {
        padding-top: 8px;
        padding-bottom: 8px;
    }
    .drawing-card {
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
    }
    #drawing {
        max-height: max(1px, calc(100vh - 110px));
        max-height: max(1px, calc(100dvh - 110px));
    }
}

@media (min-width: 901px) {
    #wallFields {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0 12px;
        align-items: stretch;
    }
    #wallFields .wall-field {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 1fr auto;
        gap: 4px;
        padding-block: 8px;
    }
    #wallFields .wall-field label {
        min-height: 34px;
        font-size: 12px;
    }
    #wallFields .wall-field label small {
        font-size: 10px;
        line-height: 1.25;
    }
    #wallFields .wall-field input {
        min-height: 36px;
        padding: 6px 8px;
    }
    .measurement-card .scope-note {
        display: none;
    }
}

.step-drawer > summary {
    cursor: pointer;
}
.step-drawer > summary h2,
.step-drawer > summary .card-heading {
    display: inline-flex;
    vertical-align: middle;
}
.step-drawer > summary h2 {
    margin: 0;
}
.step-drawer .drawing-help {
    overflow-wrap: anywhere;
}
@media (min-width: 901px) {
    .step-content {
        padding-top: 12px;
    }
    .measurement-card {
        max-height: calc(100dvh - 80px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .step-drawer + .step-drawer {
        margin-top: 18px;
    }
    .step-drawer[hidden] + .step-drawer {
        margin-top: 0;
    }
    .step-drawer .card-heading {
        flex-wrap: wrap;
        gap: 4px 10px;
    }
    .step-drawer .card-heading span {
        font-size: 11px;
    }
    #measurementStatus .drawing-footer {
        flex-wrap: wrap;
        gap: 6px;
        font-size: 11px;
    }
    #measurementStatus .message {
        overflow-wrap: anywhere;
        font-size: 12px;
    }
}

@media (max-width: 900px) {
    .step-drawer > summary {
        list-style: none;
        pointer-events: none;
    }
    .step-drawer > summary::-webkit-details-marker {
        display: none;
    }
}
