:root {
    color-scheme: light;
    --page: #f4f6f8;
    --panel: #ffffff;
    --ink: #202a33;
    --muted: #5c6975;
    --line: #d8e0e7;
    --soft: #edf2f5;
    --accent: #245f86;
    --accent-dark: #174665;
    --warning-bg: #fff8e7;
    --warning-line: #d9a52e;
    --error-bg: #fff0f0;
    --error-line: #b42318;
    --success-bg: #eef8f1;
    --success-line: #2d7b4e;
    --radius: 12px;
    --shadow: 0 3px 14px rgba(30, 48, 64, 0.07);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--page);
    overflow-x: hidden;
}

body {
    min-width: 0;
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
    line-height: 1.65;
    overflow-x: hidden;
}

button,
input,
textarea {
    font: inherit;
}

button,
a,
input,
textarea {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--accent-dark);
}

a:hover {
    color: #0e354e;
}

:focus-visible {
    outline: 3px solid #e09b23;
    outline-offset: 2px;
}

.calc-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 38px;
}

.calc-hero {
    padding: 8px 0 22px;
}

.calc-kicker,
.section-kicker {
    margin: 0 0 5px;
    color: var(--accent-dark);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.12em;
}

h1,
h2,
h3,
p,
ul,
ol,
dl {
    margin-top: 0;
}

h1,
h2,
h3 {
    line-height: 1.25;
}

h1 {
    margin-bottom: 10px;
    font-size: clamp(1.85rem, 4vw, 2.8rem);
    letter-spacing: 0.02em;
}

.h1-chunk {
    display: inline-block;
}

.calc-lead {
    max-width: 58rem;
    margin-bottom: 6px;
    color: #35434e;
    font-size: 1.08rem;
}

.privacy-note {
    color: var(--muted);
    font-size: 0.86rem;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.calc-panel,
.calc-card,
.calc-series,
.calc-comments {
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.calc-panel h2,
.calc-card h2,
.calc-series h2,
.calc-comments h2 {
    margin-bottom: 8px;
    font-size: 1.3rem;
}

.panel-intro {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 0.92rem;
}

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

.field-grid label {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 5px;
    color: #273741;
    font-weight: 700;
}

.field-grid label:first-child {
    grid-column: 1 / -1;
}

input,
textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid #aebbc5;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
}

input {
    min-height: 46px;
    padding: 8px 10px;
}

input:focus,
textarea:focus {
    border-color: var(--accent);
}

.field-help {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.45;
}

.calc-actions,
.copy-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

button {
    min-height: 46px;
    padding: 8px 16px;
    border: 1px solid #7d93a2;
    border-radius: 8px;
    background: #fff;
    color: #1b3445;
    cursor: pointer;
    font-weight: 700;
}

button:hover:not(:disabled) {
    background: #eef4f7;
}

button.primary-button {
    border-color: var(--accent-dark);
    background: var(--accent);
    color: #fff;
}

button.primary-button:hover:not(:disabled) {
    background: var(--accent-dark);
}

button.secondary {
    background: #f7f9fa;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.status-box,
.state-badge {
    margin: 16px 0 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
    color: #35434e;
    font-size: 0.9rem;
}

.state-badge {
    display: inline-block;
    margin: 0 0 16px;
    padding: 5px 10px;
    font-weight: 800;
}

.state-badge[data-state="valid"] {
    border-color: var(--success-line);
    background: var(--success-bg);
    color: #1f5f3a;
}

.state-badge[data-state="warning"] {
    border-color: var(--warning-line);
    background: var(--warning-bg);
    color: #765400;
}

.state-badge[data-state="error"] {
    border-color: var(--error-line);
    background: var(--error-bg);
    color: #8e1c13;
}

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

.result-card {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fbfcfd;
}

.result-card span,
.result-card strong {
    display: block;
}

.result-card span {
    color: var(--muted);
    font-size: 0.82rem;
}

.result-card strong {
    margin-top: 2px;
    overflow-wrap: anywhere;
    font-size: 1.12rem;
    line-height: 1.35;
}

.result-card-emphasis {
    border-color: #9bb8ca;
    background: #eef6fa;
}

.result-card-emphasis strong {
    color: var(--accent-dark);
    font-size: 1.36rem;
}

.message-box {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid;
    border-radius: 8px;
}

.message-box h3 {
    margin-bottom: 6px;
    font-size: 1rem;
}

.message-box ul {
    margin: 0;
    padding-left: 1.25rem;
}

.warning-box {
    border-color: var(--warning-line);
    background: var(--warning-bg);
}

.error-box {
    border-color: var(--error-line);
    background: var(--error-bg);
}

.assumption-box {
    border-color: #9bb8ca;
    background: #f2f7fa;
}

.copy-fallback {
    min-height: 110px;
    margin-top: 10px;
    padding: 10px;
    resize: vertical;
}

.note {
    margin: 16px 0 0;
    padding: 12px 14px;
    border-left: 4px solid #8ba4b5;
    background: #eef2f5;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.calc-card p:last-child,
.calc-card ul:last-child,
.calc-card ol:last-child {
    margin-bottom: 0;
}

.calc-card ul,
.calc-card ol {
    margin-bottom: 0;
    padding-left: 1.3rem;
}

.calc-card li + li {
    margin-top: 5px;
}

.official-sources {
    grid-column: 1 / -1;
}

.official-sources a {
    overflow-wrap: anywhere;
}

.calc-series {
    margin-top: 18px;
}

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

.series-links a {
    display: flex;
    min-height: 68px;
    flex-direction: column;
    justify-content: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    text-decoration: none;
}

.series-links a:hover {
    background: #f0f6f9;
}

.series-links strong {
    color: var(--accent-dark);
}

.series-links span {
    color: var(--muted);
    font-size: 0.84rem;
}

.calc-comments {
    margin-top: 18px;
}

.return-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.return-links a {
    display: flex;
    min-height: 78px;
    flex-direction: column;
    justify-content: center;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    text-decoration: none;
}

.return-links span,
.return-links small {
    color: var(--muted);
}

.calc-footer {
    margin-top: 22px;
    color: var(--muted);
    font-size: 0.82rem;
    text-align: center;
}

.calc-footer a {
    color: inherit;
}

[hidden] {
    display: none !important;
}

@media (max-width: 860px) {
    .calc-grid,
    .info-grid {
        grid-template-columns: 1fr;
    }

    .official-sources {
        grid-column: auto;
    }
}

@media (max-width: 520px) {
    .calc-shell {
        width: min(100% - 20px, 1120px);
        padding: 12px 0 24px;
    }

    .calc-hero {
        padding: 2px 0 10px;
    }

    h1 {
        margin-bottom: 6px;
        font-size: 1.78rem;
    }

    .calc-lead {
        margin-bottom: 4px;
        font-size: 0.94rem;
        line-height: 1.45;
    }

    .calc-hero .privacy-note {
        display: none;
    }

    .calc-grid {
        gap: 10px;
    }

    .calc-panel,
    .calc-card,
    .calc-series,
    .calc-comments {
        padding: 12px;
    }

    .calc-panel h2,
    .calc-card h2,
    .calc-series h2,
    .calc-comments h2 {
        margin-bottom: 5px;
        font-size: 1.15rem;
    }

    .panel-intro {
        margin-bottom: 10px;
        font-size: 0.85rem;
    }

    .field-grid {
        gap: 8px;
    }

    .field-grid label {
        gap: 3px;
        font-size: 0.9rem;
    }

    input,
    button {
        min-height: 44px;
    }

    input {
        padding: 7px 8px;
    }

    .field-help {
        font-size: 0.74rem;
    }

    .calc-actions,
    .copy-row {
        gap: 8px;
        margin-top: 10px;
    }

    .calc-actions button {
        flex: 1 1 30%;
        padding: 7px 9px;
        font-size: 0.88rem;
    }

    .status-box {
        margin-top: 9px;
        padding: 8px 10px;
        font-size: 0.82rem;
    }

    .result-board {
        gap: 7px;
    }

    .result-card {
        padding: 9px;
    }

    .result-card strong {
        font-size: 1rem;
    }

    .result-card-emphasis strong {
        font-size: 1.16rem;
    }

    .note {
        margin-top: 10px;
        padding: 9px 10px;
        font-size: 0.78rem;
    }

    .info-grid,
    .calc-series,
    .calc-comments,
    .return-links {
        margin-top: 10px;
    }

    .series-links,
    .return-links {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
