/* Image measurement workspace: the canvas and its controls stay together so
   the tool remains usable on a narrow screen without hiding calibration. */
body.photo-measure-page,
body.photo-measure-page button,
body.photo-measure-page input,
body.photo-measure-page select {
    font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

.photo-measure-page .photo-estimate-note {
    margin-top: 12px;
    color: #8a3b12;
    font-size: 14px;
    font-weight: 700;
}

.photo-measure-workspace .tool-workbench {
    display: block;
}

/* Photo measurement already has its own copy/download/print actions. Keep
   the generic calculator utility row from duplicating those controls below
   the workspace, especially on a phone. */
.photo-measure-page .tool-utility-actions {
    display: none;
}

.photo-measure-layout {
    display: grid;
    grid-template-columns: minmax(300px, .82fr) minmax(0, 1.18fr);
    gap: 20px;
    min-width: 0;
}

.photo-measure-controls,
.photo-canvas-panel {
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 14px 34px rgba(31, 52, 95, .055);
}

.photo-measure-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.photo-upload-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 10px;
}

.photo-example-buttons {
    display: grid;
    gap: 8px;
    align-content: stretch;
}

.photo-example-buttons button {
    display: grid;
    align-content: center;
    justify-items: start;
    gap: 3px;
    white-space: nowrap;
}

.photo-example-buttons button strong {
    font-size: 14px;
}

.photo-example-buttons button small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.photo-example-buttons button:hover small,
.photo-example-buttons button:focus-visible small {
    color: inherit;
}

.photo-upload-row .upload-drop {
    position: relative;
    display: grid;
    align-content: center;
    gap: 6px;
    min-height: 92px;
    cursor: pointer;
}

.photo-upload-row .upload-drop::after {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    content: "Choose image";
    font-size: 12px;
    font-weight: 700;
}

.photo-upload-row .upload-drop:focus-within {
    outline: 3px solid color-mix(in srgb, var(--accent) 48%, transparent);
    outline-offset: 2px;
}

.photo-upload-row .upload-drop input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.photo-upload-row .upload-drop.is-dragging {
    border-color: var(--ink);
    background: var(--accent-soft);
}

.photo-local-note,
.photo-calibration-hint,
.photo-pixel-readout,
.photo-canvas-toolbar span,
.photo-measure-controls .field-help {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.photo-calibration,
.photo-measure-tools {
    display: grid;
    gap: 13px;
    margin: 0;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 13px;
}

.photo-calibration legend,
.photo-measure-tools legend {
    padding: 0 6px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
}

.photo-choice-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.photo-choice-row label {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 7px;
    align-content: start;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}

.photo-choice-row label small {
    grid-column: 2;
    color: var(--muted);
    line-height: 1.35;
}

.photo-calibration-fields,
.photo-output-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
}

.photo-calibration-fields[hidden] {
    display: none;
}

.photo-output-fields {
    grid-template-columns: minmax(125px, .6fr) minmax(0, 1.4fr);
}

.photo-tool-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.photo-tool-buttons button {
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--canvas);
    color: var(--ink);
    cursor: pointer;
}

.photo-tool-buttons button.is-active,
.photo-tool-buttons button:hover {
    border-color: var(--ink);
    background: var(--ink);
    color: var(--panel);
}

.photo-tool-buttons button[data-photo-locked="true"] {
    border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
    background: color-mix(in srgb, var(--accent-soft) 52%, var(--canvas));
}

.photo-tool-buttons button[data-photo-locked="true"]:hover,
.photo-tool-buttons button[data-photo-locked="true"]:focus-visible {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--ink);
}

.photo-tool-lock {
    margin: 0;
    padding: 8px 10px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    color: var(--ink);
    font-size: 12px;
    line-height: 1.4;
}

.photo-tool-lock[hidden] {
    display: none;
}

.photo-advanced-settings {
    border: 1px solid var(--line);
    border-radius: 11px;
    background: color-mix(in srgb, var(--panel) 90%, var(--canvas));
}

.photo-advanced-settings summary {
    min-height: 44px;
    padding: 11px 13px;
    color: var(--ink);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    list-style-position: inside;
}

.photo-advanced-settings summary::marker {
    color: var(--accent);
}

.photo-advanced-settings[open] summary {
    border-bottom: 1px solid var(--line);
}

.photo-advanced-settings__body {
    display: grid;
    gap: 10px;
    padding: 11px;
}

.photo-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.photo-actions .secondary-button {
    min-height: 40px;
    padding-inline: 11px;
}

.photo-navigation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
}

.photo-navigation button {
    min-height: 36px;
    padding: 7px 10px;
}

.photo-navigation button.is-active {
    background: var(--ink);
    color: var(--panel);
}

.photo-navigation span {
    min-width: 48px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.photo-measure-list {
    display: grid;
    gap: 8px;
    max-height: 260px;
    margin: 0;
    padding: 0;
    overflow: auto;
    list-style: none;
}

.photo-measure-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--canvas);
}

.photo-measure-item input {
    min-width: 0;
    min-height: 35px;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    color: var(--ink);
}

.photo-measure-item strong {
    white-space: nowrap;
    font-size: 14px;
}

.photo-measure-item small {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.photo-measure-item button {
    border: 0;
    background: transparent;
    color: #9b321b;
    cursor: pointer;
    font-size: 12px;
}

.photo-canvas-panel {
    display: flex;
    min-height: 520px;
    flex-direction: column;
    gap: 12px;
}

.photo-canvas-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
}

.photo-canvas-wrap {
    position: relative;
    display: grid;
    flex: 1;
    min-height: 420px;
    place-items: center;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ebe5d9;
}

.photo-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    max-height: none;
    object-fit: contain;
    cursor: crosshair;
    touch-action: none;
}

/* The photo tool is action-first: controls remain above the canvas and keep a
   compact rhythm before the wider two-column layout is introduced. */
.photo-measure-page .photo-calibration,
.photo-measure-page .photo-measure-tools {
    gap: 10px;
}

.photo-measure-page .photo-choice-row label strong {
    font-size: 16px;
    line-height: 1.2;
}

.photo-measure-page .photo-choice-row label small {
    font-size: 12px;
    line-height: 1.3;
}

.photo-measure-page .photo-calibration-fields .tool-field span,
.photo-measure-page .photo-output-fields .tool-field span {
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
}

.photo-measure-page .photo-calibration-fields .field-help {
    grid-column: 1 / -1;
    margin: 0;
}

.photo-empty-state {
    position: absolute;
    max-width: 260px;
    color: #756b5e;
    text-align: center;
    pointer-events: none;
}

.photo-empty-state[hidden] {
    display: none;
}

.photo-magnifier {
    position: absolute;
    z-index: 3;
    width: 132px;
    height: 132px;
    overflow: hidden;
    border: 3px solid var(--ink);
    border-radius: 50%;
    background: var(--panel);
    box-shadow: 0 8px 20px rgba(31, 52, 95, .2);
    pointer-events: none;
}

.photo-magnifier[hidden] {
    display: none;
}

.photo-magnifier::after {
    position: absolute;
    inset: 50% auto auto 0;
    width: 100%;
    height: 1px;
    background: rgba(220, 38, 38, .8);
    content: "";
}

.photo-magnifier::before {
    position: absolute;
    inset: 0 auto auto 50%;
    width: 1px;
    height: 100%;
    background: rgba(220, 38, 38, .8);
    content: "";
}

.ruler-ad-slot {
    display: grid;
    min-height: 92px;
    margin: 20px 0;
    place-items: center;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: color-mix(in srgb, var(--panel) 88%, var(--canvas));
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.ruler-ad-slot span {
    opacity: .72;
}

.photo-tool-buttons button[disabled] {
    cursor: not-allowed;
    opacity: .45;
}

.photo-landscape-hint {
    display: none;
    margin: 0;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: color-mix(in srgb, var(--panel) 88%, var(--canvas));
    color: var(--muted);
    font-size: 13px;
}

.ruler-sidebar-ad {
    display: none;
}

@media (min-width: 1200px) {
    .ruler-sidebar-ad {
        display: grid;
        width: min(100%, 280px);
        min-height: 250px;
        margin: 24px auto;
    }
}

@media (max-width: 720px) and (orientation: portrait) {
    .photo-landscape-hint {
        display: block;
    }
}

@media (max-width: 900px) {
    .photo-measure-layout {
        grid-template-columns: 1fr;
    }

    .photo-canvas-panel {
        min-height: 420px;
    }

    .photo-canvas-wrap {
        min-height: 300px;
    }
}

@media (max-width: 1100px) {
    .photo-measure-layout {
        grid-template-columns: 1fr;
    }

    .photo-canvas-panel {
        min-height: 440px;
    }
}

@media (max-width: 560px) {
    .photo-measure-controls,
    .photo-canvas-panel {
        padding: 13px;
        border-radius: 12px;
    }

    .photo-upload-row {
        grid-template-columns: 1fr;
    }

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

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

    .photo-output-fields {
        grid-template-columns: minmax(108px, .7fr) minmax(0, 1.3fr);
    }

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

    .photo-tool-buttons {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 5px;
    }

    .photo-tool-buttons button {
        min-width: 0;
        padding: 7px 3px;
        font-size: 11px;
        line-height: 1.15;
        overflow-wrap: anywhere;
    }

    .photo-measure-page .photo-choice-row label {
        padding: 8px;
    }

    .photo-measure-page .photo-choice-row label strong {
        font-size: 14px;
    }

    .photo-measure-page .photo-choice-row label small {
        font-size: 11px;
    }

    .photo-navigation {
        display: grid;
        grid-template-columns: auto auto 34px minmax(34px, 1fr) 34px auto;
        gap: 5px;
    }

    .photo-navigation button {
        min-width: 0;
        padding-inline: 6px;
        font-size: 12px;
    }

    .photo-navigation span {
        min-width: 0;
    }

    .photo-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .photo-actions .secondary-button {
        min-width: 0;
        padding-inline: 7px;
        font-size: 12px;
    }

    .photo-canvas-panel {
        min-height: 350px;
    }

    .photo-canvas-wrap {
        min-height: 250px;
    }

    .photo-measure-item {
        grid-template-columns: 1fr auto;
    }

    .photo-measure-item strong {
        grid-column: 1;
    }
}

@media (max-width: 420px) {
    .photo-measure-controls,
    .photo-canvas-panel {
        padding: 10px;
    }

    .photo-calibration-fields {
        gap: 6px;
    }

    .photo-calibration-fields .tool-field span,
    .photo-output-fields .tool-field span {
        font-size: 12px;
    }

    .photo-calibration-fields select,
    .photo-calibration-fields input,
    .photo-output-fields select {
        min-width: 0;
        padding-inline: 7px;
        font-size: 12px;
    }

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

@media print {
    .photo-measure-page .ruler-product-header,
    .photo-measure-page .photo-measure-controls,
    .photo-measure-page .tool-app-intro,
    .photo-measure-page .tool-content,
    .photo-measure-page .tool-guides,
    .photo-measure-page .tool-faq,
    .photo-measure-page .related-tools,
    .photo-measure-page .ruler-footer {
        display: none !important;
    }

    .photo-measure-page .photo-measure-layout,
    .photo-measure-page .photo-canvas-panel,
    .photo-measure-page .photo-canvas-wrap {
        display: block;
        min-height: 0;
        border: 0;
        box-shadow: none;
    }

    .photo-measure-page .photo-canvas-wrap canvas {
        width: 100%;
        max-height: none;
    }
}
