@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/Inter-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/Inter-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    --teal: #009f8f;
    --teal-dark: #00766d;
    --green: #00b050;
    --ink: #1f2937;
    --muted: #64748b;
    --line: #d8dee8;
    --surface: #ffffff;
    --bg: #eef3f6;
    --warn: #f59e0b;
    --danger: #dc2626;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    padding-bottom: 86px;
}

.app-shell.blocked {
    padding-bottom: 0;
}

.app-shell.blocked .meta-strip,
.app-shell.blocked .stepper {
    display: none;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 74px;
    padding: 12px 14px;
    color: #ffffff;
    background: linear-gradient(180deg, #00b9aa 0%, var(--teal-dark) 100%);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18);
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.crest,
.crest-img {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
}

.crest {
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 8px;
    color: #0b443f;
    background: #f4c542;
    font-size: 11px;
    font-weight: 700;
}

.crest-img {
    display: block;
    object-fit: contain;
}

.brand-kicker {
    margin: 0;
    opacity: 0.9;
    font-size: 11px;
    font-weight: 700;
}

h1 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
}

.status-pill {
    flex: 0 0 auto;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 12px;
    font-weight: 700;
}

main {
    width: min(920px, 100%);
    margin: 0 auto;
    padding: 12px;
}

.meta-strip,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.meta-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 12px;
}

.meta-item {
    min-width: 0;
}

.meta-label {
    display: block;
    color: var(--muted);
    font-size: 11px;
}

.meta-value {
    display: block;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.stepper {
    display: grid;
    grid-template-columns: repeat(7, minmax(42px, 1fr));
    gap: 6px;
    margin: 12px 0;
}

.step-dot {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.step-dot.active {
    border-color: var(--teal);
    color: #ffffff;
    background: var(--teal);
}

.step-dot.done {
    border-color: #a7f3d0;
    color: #065f46;
    background: #ecfdf5;
}

.panel {
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
}

.panel-title {
    margin: 0;
    color: #00896f;
    font-size: 16px;
}

.panel-counter {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.panel-body {
    display: grid;
    gap: 10px;
    padding: 12px;
}

.section-title {
    margin: 8px 0 0;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.question {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid #e4e9f1;
    border-radius: 8px;
    background: #ffffff;
}

.question.highlight {
    border-color: #baead7;
    background: #f0fdf8;
}

.question-label {
    display: block;
    font-weight: 700;
}

.question-ms {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
    font-weight: 400;
}

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

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

.field-grid.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.history-answer-stack {
    display: grid;
    gap: 6px;
}

.history-answer-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
}

.history-answer-label {
    color: #334155;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.history-answer-label::after {
    content: " -";
    color: var(--muted);
    font-weight: 600;
}

.segmented {
    display: grid;
    gap: 6px;
}

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

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

.segmented.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segmented label {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 38px;
    padding: 7px 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented label:has(input:checked) {
    border-color: var(--teal);
    color: #ffffff;
    background: var(--teal);
}

.input,
textarea {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
}

textarea {
    min-height: 76px;
    resize: vertical;
}

.family-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 82px minmax(0, 1fr) 38px;
    gap: 8px;
    align-items: center;
}

.icon-btn {
    display: grid;
    place-items: center;
    min-width: 38px;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--danger);
    background: #fff5f5;
    font-weight: 700;
}

.add-btn {
    justify-self: start;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    color: #065f46;
    background: #ecfdf5;
    font-weight: 700;
}

.review-grid {
    display: grid;
    gap: 10px;
}

.review-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.review-card h3 {
    margin: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    color: #00896f;
    font-size: 14px;
}

.review-card dl {
    display: grid;
    grid-template-columns: minmax(110px, 0.7fr) minmax(0, 1.3fr);
    gap: 6px 10px;
    margin: 0;
    padding: 10px 12px;
}

.review-card dt {
    color: var(--muted);
    font-weight: 700;
}

.review-card dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.error-text {
    color: var(--danger);
    font-size: 12px;
    font-weight: 700;
}

.bottom-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
}

.btn {
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    font-weight: 700;
}

.btn-primary {
    color: #ffffff;
    background: linear-gradient(180deg, var(--green), #00963e);
}

.btn-secondary {
    color: #334155;
    background: #e2e8f0;
}

.btn[disabled] {
    opacity: 0.55;
}

.toast {
    position: fixed;
    right: 12px;
    bottom: 86px;
    left: 12px;
    z-index: 40;
    display: none;
    padding: 12px 14px;
    border-radius: 8px;
    color: #ffffff;
    background: #334155;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.22);
    font-weight: 700;
}

.toast.show {
    display: block;
}

.toast.error {
    background: var(--danger);
}

.toast.success {
    background: #047857;
}

.loading-box {
    padding: 24px;
    text-align: center;
    color: var(--teal-dark);
    font-weight: 700;
}

.not-allowed-card {
    margin-top: 18px;
    text-align: center;
}

.not-allowed-card .panel-body {
    justify-items: center;
    padding: 32px 18px;
}

.not-allowed-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 999px;
    color: #ffffff;
    background: var(--danger);
    font-size: 24px;
    font-weight: 800;
}

.not-allowed-card h2 {
    margin: 0;
    color: var(--danger);
    font-size: 20px;
}

.not-allowed-card p {
    max-width: 520px;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

@media (max-width: 720px) {
    body {
        font-family: "Inter", "Segoe UI", Arial, Helvetica, sans-serif;
        font-size: 13px;
        line-height: 1.38;
    }

    .app-header {
        align-items: flex-start;
        min-height: 64px;
        padding: 9px 12px;
    }

    .crest,
    .crest-img {
        width: 36px;
        height: 36px;
    }

    h1 {
        font-size: 16px;
    }

    .status-pill {
        max-width: 100px;
        text-align: center;
    }

    main {
        padding: 8px;
    }

    .meta-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 3px 8px;
        padding: 7px 9px;
    }

    .field-grid,
    .field-grid.three,
    .field-grid.four,
    .review-card dl {
        grid-template-columns: 1fr;
    }

    .meta-strip .meta-item:first-child {
        grid-column: 1 / -1;
    }

    .meta-strip .meta-label {
        font-size: 10px;
    }

    .meta-strip .meta-value {
        font-size: 12px;
        line-height: 1.25;
    }

    .meta-strip .meta-item:first-child .meta-value {
        font-size: 13px;
    }

    .stepper {
        display: block;
        margin: 8px 0;
    }

    .step-dot {
        display: none;
    }

    .step-dot.active {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 34px;
        padding: 0 12px;
        border-radius: 7px;
        font-weight: 800;
    }

    .panel-header {
        padding: 8px 10px;
    }

    .panel-title {
        font-size: 14px;
    }

    .panel-body {
        gap: 6px;
        padding: 8px;
    }

    .section-title {
        margin: 6px 0 0;
    }

    .question {
        gap: 5px;
        padding: 7px 8px;
        border-radius: 7px;
    }

    .question-label {
        font-size: 12px;
    }

    .question-ms {
        margin-top: 1px;
        font-size: 11px;
    }

    .field-grid {
        gap: 7px;
    }

    .history-answer-stack {
        gap: 4px;
    }

    .history-answer-row {
        grid-template-columns: 54px minmax(0, 1fr);
        gap: 4px;
    }

    .history-answer-label {
        font-size: 11px;
    }

    .segmented {
        display: flex;
        flex-wrap: wrap;
        gap: 5px 12px;
    }

    .segmented.two,
    .segmented.three,
    .segmented.four {
        grid-template-columns: none;
    }

    .segmented.three {
        grid-template-columns: none;
    }

    .segmented.four {
        grid-template-columns: none;
    }

    .segmented label {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        min-width: 0;
        min-height: 20px;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        color: var(--ink);
        font-size: 11px;
        text-align: left;
    }

    .segmented input {
        position: static;
        width: 13px;
        height: 13px;
        margin: 0;
        opacity: 1;
        pointer-events: auto;
        accent-color: var(--teal);
    }

    .segmented label:has(input:checked) {
        border-color: transparent;
        color: var(--ink);
        background: transparent;
    }

    .input,
    textarea {
        min-height: 32px;
        padding: 6px 9px;
        border-radius: 6px;
    }

    textarea {
        min-height: 64px;
    }

    .family-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .icon-btn {
        min-width: 32px;
        min-height: 32px;
    }

    .add-btn {
        min-height: 32px;
        padding: 0 10px;
    }

    .review-card h3,
    .review-card dl {
        padding: 8px 10px;
    }

    .bottom-bar {
        grid-template-columns: 1fr 1fr;
        gap: 7px;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    }

    .btn {
        min-height: 40px;
    }

    .loading-box {
        padding: 20px;
    }
}
