/* StraightCalc / calculator interface v2
   A focused tool aesthetic. Deliberately no Bootstrap dependency.
   The 1080px center column leaves outer width for future ad rails.
*/
:root {
    --ink: #142034;
    --ink-soft: #36465d;
    --muted: #65738a;
    --blue: #2864ed;
    --blue-press: #164ec9;
    --line: #dbe2eb;
    --canvas: #f3f5f9;
    --white: #fff;
    --max-content: 1080px;
}
* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--canvas); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .52; cursor: not-allowed; }
:focus-visible { outline: 3px solid #81afff; outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Brand bar */
.site-header { background: #101c31; color: #fff; border-bottom: 3px solid var(--blue); }
.site-header-inner { max-width: var(--max-content); width: calc(100% - 40px); margin: auto; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: #fff; text-decoration: none; letter-spacing: -.055em; font-weight: 800; font-size: 1.48rem; line-height: 1; }
.brand span { color: #85aeff; }
.site-nav { display: flex; align-items: center; gap: 24px; }
.site-nav a { color: #bfc9d9; font-weight: 600; font-size: .88rem; text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: #fff; }

/* Centered calculator content = free exterior space for side rails later */
.tool-shell { width: calc(100% - 40px); max-width: var(--max-content); margin: 0 auto; padding: 34px 0 76px; flex: 1; min-width: 0; }
.page-heading { max-width: 790px; margin-bottom: 28px; }
.eyebrow { display: flex; align-items: center; gap: 9px; font-size: .69rem; font-weight: 850; letter-spacing: .13em; color: var(--blue-press); margin: 0 0 11px; }
.eyebrow-bar { width: 18px; height: 3px; background: var(--blue); }
h1 { color: var(--ink); font-size: clamp(1.9rem, 3vw, 2.7rem); letter-spacing: -.045em; line-height: 1.15; margin: 0 0 12px; font-weight: 780; }
.page-description { color: var(--muted); line-height: 1.65; max-width: 720px; margin: 0; font-size: .99rem; }
.work-layout { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(286px, .9fr); gap: 22px; align-items: start; }
.work-layout > *, .work-main, .work-sidebar { min-width: 0; }
.work-main { display: grid; gap: 18px; }

/* Inputs, compact and technical */
.measure-card { background: var(--white); border: 1px solid var(--line); border-radius: 9px; padding: 25px 26px 22px; }
.section-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.section-number { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; border: 1px solid #c8d6f3; background: #eef3ff; color: #2457c7; font-size: .79rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.section-number.light { color: #b7cafe; border-color: #435b81; background: #1b3150; }
.section-kicker { font-size: .65rem; font-weight: 850; color: #4774c8; letter-spacing: .11em; margin: 0; }
.section-heading h2 { margin: 2px 0 0; font-size: 1.18rem; letter-spacing: -.025em; line-height: 1.25; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
.field { min-width: 0; }
.field label { display: block; margin-bottom: 7px; font-size: .84rem; font-weight: 690; color: var(--ink-soft); }
.input-wrap { position: relative; min-width: 0; }
.input-wrap input { padding-right: 66px; }
.field input, .field select, .create-form input { display: block; width: 100%; max-width: 100%; min-width: 0; height: 49px; background: #fff; color: #13233b; padding: 10px 13px; border: 1px solid #bfccda; border-radius: 6px; font-size: 1rem; }
.field input:focus, .field select:focus, .create-form input:focus { border-color: var(--blue); outline: 2px solid #b3cafe; outline-offset: 0; }
.input-unit { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); font-weight: 700; font-size: .78rem; color: #79869a; pointer-events: none; }
.formula-note { padding-top: 17px; border-top: 1px solid #edf0f5; color: var(--muted); font-size: .82rem; line-height: 1.5; margin: 21px 0 0; }
.error-message { background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; padding: 9px 12px; border-radius: 5px; margin: 14px 0 0; font-size: .86rem; }

/* Result is the hero of the workflow */
.result-card { background: #162842; color: #fff; border-radius: 9px; padding: 23px 26px 21px; overflow: hidden; position: relative; }
.result-card::before { content: ""; position: absolute; top: 0; left: 0; width: 5px; height: 100%; background: #4b8aff; }
.result-topline, .result-topline-title { display: flex; align-items: center; gap: 11px; }
.result-topline { justify-content: space-between; }
.result-topline h2 { margin: 0; font-size: 1.08rem; letter-spacing: -.02em; }
.live-label { display: flex; align-items: center; gap: 7px; font-size: .67rem; font-weight: 800; letter-spacing: .1em; color: #aac8fc; }
.live-dot { height: 6px; width: 6px; border-radius: 50%; background: #7ec4ff; }
.main-result { padding: 20px 0 24px; border-bottom: 1px solid #344962; }
.main-result p { color: #b7c5d8; font-size: .82rem; font-weight: 600; margin: 0 0 4px; }
.number-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.number-line strong { color: #fff; font-size: clamp(2.9rem, 5vw, 4.5rem); font-variant-numeric: tabular-nums; letter-spacing: -.055em; line-height: 1.13; font-weight: 800; overflow-wrap: anywhere; }
.number-line > span { color: #b8caff; font-size: 1.16rem; font-weight: 650; }
.result-breakdown { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 18px 0 21px; }
.result-breakdown > div { min-width: 0; display: grid; gap: 3px; }
.result-breakdown span { font-size: .75rem; color: #b1c0d5; }
.result-breakdown strong { color: #f3f7ff; font-size: 1.08rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result-actions { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 10px; }
.button { border-radius: 6px; border: 1px solid transparent; font-size: .9rem; line-height: 1.25; font-weight: 730; min-height: 45px; padding: 11px 14px; text-align: center; }
.button-light { background: #eef3fc; border-color: #eef3fc; color: #213756; }
.button-light:hover:not(:disabled) { background: #dce8fa; }
.button-blue { color: #fff; background: #2864ed; border-color: #2864ed; }
.button-blue:hover:not(:disabled) { background: #1c54d2; }
.button-blue span { margin-left: 6px; }
.button-outline { background: #fff; border-color: #b3c7f2; color: #2459ce; }
.button-outline:hover:not(:disabled) { background: #f4f7ff; }
.button-full { width: 100%; }
.result-status { min-height: 0; font-size: .81rem; color: #b8d7ff; margin: 8px 0 0; }
.result-status:empty { display: none; }
.result-card.is-invalid .number-line strong { opacity: .45; }
.result-card.is-invalid .live-label { opacity: .6; }

/* Explanation */
.explanation { padding: 15px 4px 0; border-top: 1px solid var(--line); }
.explanation h2 { font-size: 1rem; margin: 0 0 8px; letter-spacing: -.02em; }
.explanation p { color: var(--muted); font-size: .86rem; line-height: 1.7; margin: 0 0 8px; }
.explanation strong { color: var(--ink-soft); }

/* Projects are an optional utility, not required for calculation */
.project-card { background: #fff; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.project-summary { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; list-style: none; padding: 21px; }
.project-summary::-webkit-details-marker { display: none; }
.project-symbol { display: grid; place-items: center; width: 37px; height: 37px; flex: none; background: #edf3ff; color: #245bd2; border-radius: 7px; font-size: 1.35rem; }
.project-summary-copy { display: grid; gap: 3px; flex: 1; min-width: 0; }
.project-overline { color: #5e7eaf; font-size: .62rem; font-weight: 840; letter-spacing: .1em; }
.project-summary-copy strong { font-size: 1.06rem; letter-spacing: -.02em; color: var(--ink); line-height: 1.25; }
.project-summary-copy > span:last-child { color: var(--muted); font-size: .78rem; }
.summary-chevron { width: 9px; height: 9px; border-right: 2px solid #697a91; border-bottom: 2px solid #697a91; transform: rotate(45deg); transition: transform .15s; margin: 13px 3px 0 0; flex: none; }
.project-card[open] .summary-chevron { transform: rotate(225deg); }
.project-body { border-top: 1px solid #edf0f5; padding: 20px 21px 22px; }
.project-intro { font-size: .84rem; color: var(--muted); line-height: 1.6; margin: 0 0 19px; }
.sidebar-field { margin-bottom: 17px; }
.project-message { font-size: .8rem; color: #2660c8; min-height: 0; margin: 9px 0 0; overflow-wrap: anywhere; }
.project-message:empty { display: none; }
.create-disclosure { border-top: 1px solid var(--line); margin-top: 23px; padding-top: 16px; }
.create-disclosure > summary { color: #2459ce; font-size: .86rem; font-weight: 690; cursor: pointer; }
.create-form { display: grid; gap: 9px; padding-top: 14px; }
.backup-tools { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 14px; }
.backup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.text-button { padding: 0; border: 0; background: none; color: #245bd2; font-size: .85rem; font-weight: 720; text-align: left; }
.text-button:hover { text-decoration: underline; }
.backup-tools p { margin: 9px 0 0; font-size: .76rem; line-height: 1.6; color: #7c633f; }

.site-footer { border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: .78rem; }
.site-footer-inner { max-width: var(--max-content); width: calc(100% - 40px); margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 20px 0; }

@media (max-width: 900px) {
    .work-layout { grid-template-columns: minmax(0, 1fr); }
    .tool-shell { padding-top: 27px; }
}
@media (max-width: 540px) {
    .site-header-inner, .tool-shell, .site-footer-inner { width: calc(100% - 28px); }
    .site-header-inner { min-height: 62px; }
    .brand { font-size: 1.28rem; }
    .site-nav { gap: 14px; }
    .site-nav a { font-size: .8rem; }
    .tool-shell { padding-top: 24px; padding-bottom: 46px; }
    .page-heading { margin-bottom: 22px; }
    h1 { font-size: 1.95rem; }
    .page-description { font-size: .91rem; }
    .measure-card { padding: 19px 17px; }
    .field-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .result-card { padding: 20px 17px; }
    .number-line strong { font-size: clamp(2.5rem, 11vw, 3.6rem); }
    .result-breakdown { gap: 10px; }
    .result-breakdown strong { font-size: .95rem; }
    .result-actions { grid-template-columns: minmax(0, 1fr); }
    .project-summary { padding: 17px; }
    .project-body { padding: 18px 17px 19px; }
    .site-footer-inner { display: grid; }
}



/* ==========================================
   STRAIGHTCALC — MY PROJECTS
   ========================================== */

.section-eyebrow {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: #2563eb;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Main dashboard layout */

.projects-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.projects-layout > * {
    min-width: 0;
}

/* Dashboard panels */

.projects-layout > .tool-card,
.projects-backup {
    display: block;
    min-width: 0;
    padding: 26px;
    background: #ffffff;
    border: 1px solid #dce4ee;
    border-radius: 14px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.035);
}

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

.projects-layout h2,
.projects-backup h2 {
    margin: 0;
    color: #0f172a;
    font-size: 1.2rem;
    font-weight: 750;
    line-height: 1.35;
}

#project-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    background: #eff6ff;
    color: #2563eb;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 800;
}

/* Project list */

.project-list {
    display: grid;
    gap: 10px;
}

.project-list-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    width: 100%;
    padding: 15px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: #0f172a;
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.project-list-item:hover {
    background: #f1f6ff;
    border-color: #93c5fd;
}

.project-list-item.active {
    background: #eff6ff;
    border-color: #2563eb;
    box-shadow: inset 3px 0 0 #2563eb;
}

.project-list-item:focus-visible,
.projects-layout button:focus-visible,
.projects-backup button:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
}

.project-list-name {
    font-size: 0.95rem;
    font-weight: 750;
    overflow-wrap: anywhere;
}

.project-list-meta {
    color: #64748b;
    font-size: 0.78rem;
}

/* Create project form */

.projects-sidebar .tool-divider {
    border: 0;
    border-top: 1px solid #e2e8f0;
    margin: 24px 0;
}

.projects-sidebar .tool-field {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.projects-sidebar .tool-field label {
    color: #334155;
    font-size: 0.875rem;
    font-weight: 650;
}

.projects-sidebar .tool-field input {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 11px 13px;
    background: #fff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
    font-size: 0.95rem;
}

.projects-sidebar .tool-field input:focus {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

.projects-sidebar .tool-button {
    width: 100%;
    min-height: 46px;
    padding: 12px 16px;
    background: #2563eb;
    color: #fff;
    border: 1px solid #2563eb;
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

.projects-sidebar .tool-button:hover:not(:disabled) {
    background: #1d4ed8;
}

/* Selected project */

.projects-main {
    min-height: 320px;
}

#selected-project-name {
    overflow-wrap: anywhere;
}

#project-updated {
    margin: 7px 0 0;
    color: #64748b;
    font-size: 0.8rem;
}

.projects-main h3 {
    margin: 26px 0 14px;
    color: #0f172a;
    font-size: 1rem;
    font-weight: 750;
}

.projects-main h4 {
    margin: 20px 0 10px;
    color: #334155;
    font-size: 0.85rem;
    font-weight: 750;
}

/* Project summary */

.project-summary-box {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.project-summary-number {
    color: #0f172a;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.project-summary-label {
    color: #64748b;
    font-size: 0.875rem;
}

/* Saved calculations */

#calculation-list {
    display: grid;
    gap: 10px;
}

.project-calculation {
    min-width: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.project-calculation[open] {
    border-color: #bfdbfe;
}

.project-calculation summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 17px;
    list-style: none;
    cursor: pointer;
}

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

.project-calculation summary::before {
    content: "▸";
    flex-shrink: 0;
    color: #2563eb;
    font-size: 1.1rem;
}

.project-calculation[open] summary::before {
    content: "▾";
}

.project-calculation summary:hover {
    background: #f8fafc;
}

.project-calculation-title {
    flex: 1;
    min-width: 0;
    color: #0f172a;
    font-size: 0.9rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.project-calculation-type {
    color: #64748b;
    font-size: 0.75rem;
    overflow-wrap: anywhere;
}

.project-calculation-body {
    padding: 8px 18px 20px;
    border-top: 1px solid #e2e8f0;
}

.project-data-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px solid #f1f5f9;
}

.project-data-label {
    color: #64748b;
    font-size: 0.85rem;
}

.project-data-value {
    color: #0f172a;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: right;
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
}

/* Backup and restore */

.projects-backup {
    margin-top: 22px;
}

.projects-backup h2 {
    margin-bottom: 12px;
}

.projects-backup > .tool-help {
    max-width: 720px;
    margin: 0 0 20px;
    color: #64748b;
    line-height: 1.6;
}

.projects-backup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.projects-backup-actions .tool-button-secondary {
    width: auto;
    min-width: 165px;
    min-height: 44px;
    padding: 11px 18px;
    background: #fff;
    color: #2563eb;
    border: 1px solid #2563eb;
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

.projects-backup-actions .tool-button-secondary:hover {
    background: #eff6ff;
}

.projects-backup .tool-message {
    margin-top: 18px;
    font-size: 0.875rem;
}

.projects-backup .tool-warning {
    max-width: 720px;
    margin: 20px 0 0;
    padding: 13px 15px;
    background: #fffbeb;
    color: #92400e;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1.6;
}

/* Keep hidden panels hidden */

.projects-layout [hidden],
.projects-backup [hidden] {
    display: none !important;
}

/* Tablet */

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

    .projects-main {
        min-height: 220px;
    }
}

/* Mobile */

@media (max-width: 540px) {
    .projects-layout {
        gap: 16px;
    }

    .projects-layout > .tool-card,
    .projects-backup {
        padding: 18px;
        border-radius: 12px;
    }

    .projects-section-header {
        margin-bottom: 18px;
    }

    .project-list-item {
        padding: 14px;
    }

    .project-calculation summary {
        flex-wrap: wrap;
        gap: 8px;
    }

    .project-calculation-type {
        flex-basis: 100%;
        padding-left: 18px;
    }

    .project-data-row {
        gap: 10px;
    }

    .projects-backup {
        margin-top: 16px;
    }

    .projects-backup-actions {
        flex-direction: column;
    }

    .projects-backup-actions .tool-button-secondary {
        width: 100%;
    }
}


/* Project rename controls */

.projects-rename-toggle {
    flex-shrink: 0;
    padding: 8px 12px;
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    border-radius: 7px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.projects-rename-toggle:hover {
    background: #dbeafe;
}

.projects-rename-form {
    padding: 18px;
    margin-bottom: 22px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.projects-rename-form .tool-field {
    margin-bottom: 14px;
}

.projects-rename-actions {
    display: flex;
    gap: 10px;
}

.projects-rename-actions button {
    width: auto;
    flex: 1;
}


/* ==========================================
   PROJECT RENAME FORM - V2 STYLING
   ========================================== */

.projects-rename-form .tool-field {
    display: block;
    margin-bottom: 16px;
}

.projects-rename-form .tool-field label {
    display: block;
    margin-bottom: 8px;
    color: #334155;
    font-size: 0.875rem;
    font-weight: 650;
}

.projects-rename-form .tool-field input {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 11px 13px;
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.projects-rename-form .tool-field input:focus {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

.projects-rename-actions {
    display: flex;
    gap: 12px;
}

.projects-rename-actions button {
    flex: 1;
    width: auto;
    min-width: 0;
    min-height: 44px;
    padding: 11px 16px;
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}

/* Primary: Save Name */

.projects-rename-actions .tool-button {
    background: #2563eb;
    color: #ffffff;
    border: 1px solid #2563eb;
}

.projects-rename-actions .tool-button:hover:not(:disabled) {
    background: #1d4ed8;
}

/* Secondary: Cancel */

.projects-rename-actions .tool-button-secondary {
    background: #ffffff;
    color: #2563eb;
    border: 1px solid #2563eb;
}

.projects-rename-actions .tool-button-secondary:hover {
    background: #eff6ff;
}

.projects-rename-actions button:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
}

.projects-rename-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Small mobile screens */

@media (max-width: 400px) {
    .projects-rename-actions {
        flex-direction: column;
    }

    .projects-rename-actions button {
        width: 100%;
        flex: none;
    }
}


/* ==========================================
   PROJECT DASHBOARD INTERACTION STYLES
   ========================================== */

/* Project header actions */

.projects-heading-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* Destructive actions */

.projects-danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 14px;

    background: #ffffff;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 8px;

    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.projects-danger-button:hover:not(:disabled) {
    background: #fef2f2;
    border-color: #f87171;
}

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

.projects-danger-button:focus-visible {
    outline: 2px solid #dc2626;
    outline-offset: 3px;
}

.project-delete-calculation {
    margin-top: 20px;
}

/* Desktop: fixed-height workspace panels */

@media (min-width: 821px) {

    .projects-layout > .tool-card {
        height: clamp(
            420px,
            calc(100dvh - 260px),
            740px
        );

        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Project list scrolls independently */

    .projects-sidebar .project-list {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        padding-right: 5px;
        scrollbar-width: thin;
    }

    /* Keep project creation controls accessible */

    .projects-sidebar .tool-divider,
    .projects-sidebar #create-project-form {
        flex-shrink: 0;
    }

    /* Selected project content scrolls independently */

    .projects-main #project-detail,
    .projects-main #project-empty-state {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        padding-right: 5px;
        scrollbar-width: thin;
    }

}

/* Mobile: natural page scrolling */

@media (max-width: 820px) {

    .projects-layout > .tool-card {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .projects-sidebar .project-list,
    .projects-main #project-detail,
    .projects-main #project-empty-state {
        max-height: none;
        overflow: visible;
    }

    #project-detail {
        scroll-margin-top: 20px;
    }

    .projects-section-header {
        flex-wrap: wrap;
    }

}

@media (max-width: 480px) {
    .projects-heading-actions {
        width: 100%;
    }
}


/* Add calculations to project */

.projects-add-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;

    margin-bottom: 22px;
    padding: 18px;

    background: #f8fafc;
    border: 1px solid #dbe4ef;
    border-radius: 10px;
}

.projects-add-action strong {
    display: block;
    color: #0f172a;
    font-size: 0.95rem;
}

.projects-add-action p {
    margin: 5px 0 0;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.5;
}

.projects-add-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 42px;
    padding: 10px 16px;

    background: #2563eb;
    color: #ffffff;
    border: 1px solid #2563eb;
    border-radius: 8px;

    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 700;
    white-space: nowrap;
}

.projects-add-button:hover {
    background: #1d4ed8;
}

.projects-add-button:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
}

@media (max-width: 540px) {
    .projects-add-action {
        align-items: stretch;
    }

    .projects-add-button {
        width: 100%;
    }
}


/* ==========================================
   WALL SHEATHING LAYOUT
   ========================================== */

.sheathing-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 22px;
    color: #172b4d;
    font-size: 0.9rem;
    font-weight: 650;
    cursor: pointer;
}

.sheathing-toggle input {
    width: 18px;
    height: 18px;
    accent-color: #2563eb;
}

.sheathing-openings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid #e2e8f0;
}

.sheathing-openings-header h3 {
    margin: 0 0 5px;
    font-size: 1rem;
    color: #0f172a;
}

.sheathing-openings-header p {
    margin: 0;
    max-width: 400px;
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.6;
}

.sheathing-openings-header .button {
    width: auto;
    min-height: 40px;
    white-space: nowrap;
}

.sheathing-opening {
    margin-top: 16px;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
}

.sheathing-opening-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.sheathing-opening-heading strong {
    font-size: 0.875rem;
    color: #0f172a;
}

.sheathing-remove-opening {
    padding: 5px 10px;
    background: white;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #b91c1c;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.sheathing-opening-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.sheathing-opening-fields label {
    display: grid;
    gap: 6px;
    min-width: 0;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 650;
}

.sheathing-opening-fields input {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: white;
    color: #0f172a;
    font: inherit;
    font-size: 0.95rem;
}

.sheathing-result-note {
    margin: 20px 0 0;
    color: #cbd5e1;
    font-size: 0.8rem;
    line-height: 1.6;
}

/* Elevation drawing */

.sheathing-drawing-card {
    margin-top: 20px;
}

.sheathing-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-bottom: 16px;
    font-size: 0.8rem;
    color: #475569;
}

.sheathing-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.sheathing-legend i {
    display: inline-block;
    width: 17px;
    height: 12px;
}

.legend-panel {
    background: #bfdbfe;
    border: 1px solid #2563eb;
}

.legend-stud {
    border-left: 2px dashed #64748b;
}

.legend-opening {
    background: #fff;
    border: 1px dashed #dc2626;
}

.sheathing-elevation {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    border: 1px solid #dbe4ef;
    border-radius: 8px;
    background: #ffffff;
    padding: 12px;
    scrollbar-width: thin;
}

.sheathing-drawing-note {
    margin: 12px 0 0;
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.6;
}

.sheathing-warning-list {
    padding-left: 20px;
    color: #64748b;
    font-size: 0.85rem;
    line-height: 1.7;
}

.sheathing-warning-list li {
    margin-bottom: 8px;
}

.sheathing-project-link {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

#sheathing-error[hidden] {
    display: none !important;
}

@media (max-width: 540px) {
    .sheathing-openings-header .button {
        width: 100%;
    }

    .sheathing-opening-fields {
        grid-template-columns: minmax(0, 1fr);
    }

    .sheathing-drawing-card {
        padding: 18px;
    }

    .sheathing-elevation {
        padding: 8px;
    }
}


/* Wall sheathing V2 framing and joint legend */

.legend-review {
    border-left: 3px dashed #d97706;
}

.legend-unsupported {
    border-left: 3px dashed #dc2626;
}

.sheathing-seam-summary {
    margin: 0 0 14px;
    padding: 11px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #475569;
    font-size: 0.82rem;
    line-height: 1.5;
}


/* ==========================================
   CALCULATOR LAYOUT CONTAINMENT FIX
   ========================================== */

/* Allow main content to shrink inside the grid */
.work-layout,
.work-main,
.work-sidebar {
    min-width: 0;
}

.work-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}

/* Prevent cards from forcing wider grid tracks */
.work-main > *,
.work-sidebar > *,
.measure-card,
.result-card {
    min-width: 0;
    max-width: 100%;
}

/* Keep all form controls inside their columns */
.work-main form,
.work-main .field-grid,
.work-main .field,
.work-main .input-wrap {
    min-width: 0;
    max-width: 100%;
}

.work-main .field input,
.work-main .field select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* The elevation scrolls internally, not the page */
.sheathing-elevation {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Desktop keeps a separate project sidebar */
@media (min-width: 901px) {
    .work-layout {
        grid-template-columns:
            minmax(0, 1.85fr)
            minmax(286px, 0.9fr);
        gap: 22px;
    }
}

/* Tablets and phones stack the panels */
@media (max-width: 900px) {
    .work-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Small screens use a single input column */
@media (max-width: 540px) {
    .work-main .field-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .sheathing-openings-header {
        align-items: stretch;
    }

    .sheathing-openings-header > * {
        min-width: 0;
        max-width: 100%;
    }

    .sheathing-openings-header .button {
        width: 100%;
        white-space: normal;
    }
}


/* ==========================================
   STOCK SHEET CUTTING DIAGRAMS
   ========================================== */

.sheathing-cutting-card {
    min-width: 0;
}

.sheathing-cutting-description {
    margin: 0 0 18px;
    color: #64748b;
    font-size: 0.88rem;
    line-height: 1.6;
}

.stock-sheet-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
    color: #475569;
    font-size: 0.8rem;
}

.stock-sheet-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.stock-sheet-legend i {
    display: inline-block;
    width: 16px;
    height: 12px;
    border: 1px solid;
}

.stock-legend-piece {
    background: #bfdbfe;
    border-color: #2563eb !important;
}

.stock-legend-offcut {
    background: #dcfce7;
    border-color: #16a34a !important;
}

.stock-legend-scrap {
    background: #e2e8f0;
    border-color: #94a3b8 !important;
}

.stock-sheet-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(min(100%, 230px), 1fr));
    gap: 16px;
    min-width: 0;
}

.stock-sheet-card {
    min-width: 0;
    padding: 15px;
    background: #f8fafc;
    border: 1px solid #dbe4ef;
    border-radius: 10px;
}

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

.stock-sheet-header strong {
    color: #0f172a;
    font-size: 0.95rem;
}

.stock-sheet-header span {
    color: #64748b;
    font-size: 0.76rem;
}

.stock-sheet-drawing {
    width: 100%;
    min-width: 0;
    padding: 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
}

.stock-sheet-svg {
    display: block;
    width: 100%;
    height: auto;
}

.stock-sheet-details {
    margin-top: 13px;
    color: #475569;
    font-size: 0.8rem;
    line-height: 1.6;
}

.stock-sheet-details strong {
    color: #334155;
}

.stock-sheet-details ul {
    margin: 6px 0 10px;
    padding-left: 18px;
}

.stock-sheet-details li {
    margin-bottom: 3px;
}

.stock-sheet-offcut-label {
    margin: 10px 0 0;
    padding-top: 9px;
    color: #15803d;
    border-top: 1px solid #e2e8f0;
    font-size: 0.78rem;
}

@media (max-width: 540px) {
    .stock-sheet-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .stock-sheet-card {
        padding: 12px;
    }
}


/* Compact stock sheet cutting diagrams */

.stock-sheet-grid {
    grid-template-columns:
        repeat(auto-fit, minmax(min(100%, 190px), 1fr));
    gap: 14px;
}

.stock-sheet-card {
    padding: 12px;
}

.stock-sheet-drawing {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 230px;
    overflow: hidden;
}

.stock-sheet-svg {
    display: block;
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}












/* ============================================
   Wall sheathing — Quick / Advanced Layout
   ============================================ */
.sheathing-quick-help {
    margin: 17px 0;
    color: #64748b;
    font-size: .83rem;
    line-height: 1.6;
}
.sheathing-advanced,
.sheathing-visual-details {
    min-width: 0;
    max-width: 100%;
}
.sheathing-advanced > summary,
.sheathing-visual-details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    background: #f8fafc;
    border: 1px solid #dbe4ef;
    border-radius: 9px;
    cursor: pointer;
    list-style: none;
}
.sheathing-advanced > summary::-webkit-details-marker,
.sheathing-visual-details > summary::-webkit-details-marker {
    display: none;
}
.sheathing-advanced > summary:hover,
.sheathing-visual-details > summary:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
}
.sheathing-advanced > summary strong,
.sheathing-visual-details > summary strong {
    display: block;
    color: #0f172a;
    font-size: .95rem;
}
.sheathing-advanced > summary small,
.sheathing-visual-details > summary small {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: .78rem;
    line-height: 1.5;
}
.sheathing-expand-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: #eaf1ff;
    color: #2563eb;
    font-size: 1.2rem;
    transition: transform .18s ease;
}
.sheathing-advanced[open] > summary .sheathing-expand-icon,
.sheathing-visual-details[open] > summary .sheathing-expand-icon {
    transform: rotate(180deg);
}
.sheathing-advanced > .sheathing-detail-content {
    display: grid;
    gap: 16px;
    padding-top: 20px;
}
.sheathing-detail-content,
.sheathing-detail-content > *,
.sheathing-detail-content .field-grid,
.sheathing-detail-content .field {
    min-width: 0;
}
.sheathing-physical-grid { margin-top: 0; }
.sheathing-advanced .formula-note { margin-top: 0; }
.sheathing-visual-details > .sheathing-detail-content {
    display: grid;
    gap: 18px;
    padding-top: 18px;
}
.sheathing-visual-details .sheathing-drawing-card,
.sheathing-visual-details .sheathing-cutting-card { margin-top: 0; }
.sheathing-visual-details .explanation { margin: 0; }
@media(max-width: 540px) {
    .sheathing-advanced > summary,
    .sheathing-visual-details > summary { padding: 15px; }
    .sheathing-advanced > summary small,
    .sheathing-visual-details > summary small { font-size: .75rem; }
}
@media(prefers-reduced-motion: reduce) {
    .sheathing-expand-icon { transition: none; }
}

/* Keep the growing calculator navigation usable on small screens. */
@media (max-width: 650px) {
    .site-header-inner {
        flex-wrap: wrap;
        align-items: center;
        padding: 12px 0;
        gap: 11px;
    }
    .site-nav {
        width: 100%;
        min-width: 0;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 7px 10px;
    }
    .site-nav a { font-size: .77rem; }
}

/* Wall Sheathing: saved project controls */
.sheathing-workspace-fields {
    display: grid;
    gap: 9px;
    min-width: 0;
}
.sheathing-workspace-fields label {
    font-size: .84rem;
    font-weight: 700;
    color: #223554;
    margin-top: 7px;
}
.sheathing-workspace-fields input,
.sheathing-workspace-fields select {
    width: 100%;
    min-width: 0;
    min-height: 45px;
    padding: 10px 12px;
    font: inherit;
    font-size: .9rem;
    color: #0f172a;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}
.sheathing-save-button,
.sheathing-secondary-button {
    width: 100%;
    min-height: 44px;
    padding: 10px 13px;
    border-radius: 8px;
    font: inherit;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
}
.sheathing-save-button {
    background: #2563eb;
    border: 1px solid #2563eb;
    color: #fff;
    margin-top: 8px;
}
.sheathing-save-button:hover:not(:disabled) { background: #1d4ed8; }
.sheathing-secondary-button {
    background: #fff;
    border: 1px solid #93b4fa;
    color: #1d4ed8;
}
.sheathing-secondary-button:hover:not(:disabled) { background: #eff6ff; }
.sheathing-save-button:disabled,
.sheathing-secondary-button:disabled { opacity: .55; cursor: not-allowed; }
.sheathing-save-button:focus-visible,
.sheathing-secondary-button:focus-visible,
.sheathing-workspace-fields input:focus-visible,
.sheathing-workspace-fields select:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
.sheathing-editing {
    padding: 9px 12px;
    margin: 0 0 14px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    color: #1e40af;
    background: #eff6ff;
    font-size: .82rem;
    overflow-wrap: anywhere;
}
.sheathing-project-message {
    margin: 6px 0 0;
    color: #334155;
    font-size: .82rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.sheathing-create-project {
    border-top: 1px solid #e2e8f0;
    margin-top: 18px;
    padding-top: 14px;
}
.sheathing-create-project summary {
    font-size: .83rem;
    font-weight: 700;
    color: #2563eb;
    cursor: pointer;
}
.sheathing-create-project form { padding-top: 8px; }
.sheathing-project-link-inline {
    display: inline-block;
    margin-top: 18px;
    color: #2563eb;
    font-size: .83rem;
    font-weight: 700;
}
.sheathing-storage-note {
    margin: 12px 0 0;
    color: #92400e;
    font-size: .76rem;
    line-height: 1.6;
}
.projects-add-action { flex-wrap: wrap; }
.projects-add-action > div { flex: 1 1 220px; }
.project-calculation-actions { display:flex; gap: 10px; flex-wrap:wrap; margin-top: 17px; }
.project-calculation-actions a { font-size: .8rem; text-decoration: none; }
