:root {
    --page: #f4f4ef;
    --card: #fffef9;
    --ink: #161616;
    --muted: #5b5f61;
    --accent: #1f5f8b;
    --accent-strong: #123d59;
    --border: #d8ddd8;
    --good-bg: #e7f4ea;
    --good-ink: #1f5c2b;
    --bad-bg: #f9e3df;
    --bad-ink: #8b2d21;
    --soft: #eef2f1;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(31, 95, 139, 0.10), transparent 26%),
        linear-gradient(180deg, #fbfbf8 0%, var(--page) 100%);
}

.shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 18px 40px;
}

.hero {
    margin-bottom: 24px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(31, 95, 139, 0.08), rgba(255, 254, 249, 0.96));
}

h1 {
    margin: 0 0 10px;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 0.98;
    letter-spacing: -0.03em;
}

.hero-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.hero-title-icon {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    box-shadow: 0 8px 18px rgba(18, 61, 89, 0.16);
}

h2 {
    margin-top: 0;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

h3 {
    margin: 0;
    font-size: 0.98rem;
    letter-spacing: -0.01em;
}

.hero p,
.hint,
.panel p,
.output {
    color: var(--muted);
}

.layout {
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr);
}

.panel {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card);
    box-shadow: 0 10px 30px rgba(29, 29, 27, 0.05);
}

.panel.compact {
    max-width: 720px;
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.controls.controls-bottom {
    margin-top: 32px;
    margin-bottom: 0;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

button,
.download-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid var(--accent-strong);
    background: var(--accent);
    color: #fff;
    font: inherit;
    padding: 10px 16px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid #c9d3d4;
    background: var(--soft);
    color: var(--accent-strong);
    font: inherit;
    padding: 10px 16px;
    text-decoration: none;
    transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

button:hover,
.download-link:hover,
.link-button:hover {
    transform: translateY(-1px);
}

button.secondary {
    background: var(--soft);
    color: var(--accent-strong);
    border-color: #c9d3d4;
}

.field-row {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 18px;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
}

input[type="number"],
input[type="text"],
select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font: inherit;
    background: #fff;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus,
input[type="checkbox"]:focus {
    outline: 2px solid rgba(31, 95, 139, 0.22);
    outline-offset: 2px;
}

.field-row-secondary {
    grid-template-columns: minmax(0, 1fr);
    margin-top: -2px;
}

.support-link-row {
    margin-bottom: 18px;
}

.support-link-copy {
    margin: 0;
    font-size: 0.95rem;
    color: var(--muted);
}

.support-link-copy a {
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 0.12em;
}

.form-section-divider {
    margin: 20px 0 18px;
    border-top: 1px solid var(--border);
}

[data-radio-only][hidden],
[hidden] {
    display: none !important;
}

.state-grid {
    display: grid;
    gap: 10px 14px;
    grid-template-columns: 1fr;
}

.state-option {
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) 112px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #dfe5df;
    background: #fff;
}

.state-choice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.state-option label {
    margin: 0;
    font-weight: 400;
}

.state-code {
    display: inline-block;
    min-width: 2.2rem;
    font-weight: 700;
    color: var(--accent-strong);
}

.state-meta {
    margin-top: 2px;
    font-size: 0.92rem;
    color: var(--muted);
}

.count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4.2rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: var(--soft);
    color: var(--accent-strong);
    font-size: 0.84rem;
    font-weight: 700;
}

.state-threshold label {
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
}

.state-threshold input[type="number"] {
    padding: 10px 12px;
}

code {
    padding: 0.08rem 0.34rem;
    border-radius: 0.45rem;
    background: var(--soft);
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.92em;
}

.message,
.error,
.warning {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 12px;
}

.message {
    background: var(--good-bg);
    color: var(--good-ink);
}

.error {
    background: var(--bad-bg);
    color: var(--bad-ink);
}

.warning {
    background: #fff3d6;
    color: #7a4a00;
    border: 1px solid #f0cf86;
    font-weight: 700;
}

pre.output {
    margin: 14px 0 0;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid #eadfcb;
    background: #f9f6ef;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.9rem;
    line-height: 1.45;
}

ul.meta {
    margin: 0 0 22px;
    padding-left: 1.2rem;
}

.meta li + li {
    margin-top: 8px;
}

aside.panel h2,
aside.panel h3 {
    margin-bottom: 10px;
}

aside.panel h2:not(:first-child),
aside.panel h3:not(:first-child) {
    margin-top: 22px;
}

.stack {
    display: grid;
    gap: 16px;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}

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

    .state-option {
        grid-template-columns: 1fr;
    }
}
