:root {
    --color-ink: #24212f;
    --color-muted: #6d6670;
    --color-bg: #f0eeee;
    --color-panel: #fffdfa;
    --color-panel-soft: #fbf7f2;
    --color-accent: #9e2600;
    --color-accent-dark: #731b00;
    --color-blue: #174a7c;
    --color-line: rgb(36 33 47 / 14%);
    --color-accent-line: rgb(158 38 0 / 26%);
    --shadow-soft: 0 14px 30px rgb(36 33 47 / 7%);
    --font-ui: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
    --font-display: Georgia, "Times New Roman", "Yu Mincho", serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100svh;
    color: var(--color-ink);
    font-family: var(--font-ui);
    background:
        linear-gradient(180deg, rgb(255 255 255 / 42%), transparent 240px),
        var(--color-bg);
}

button,
input,
select {
    font: inherit;
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgb(251 246 241 / 94%);
    border-bottom: 1px solid var(--color-accent-line);
    box-shadow: 0 8px 20px rgb(0 0 0 / 7%);
    backdrop-filter: blur(10px);
}

.site-header__inner {
    width: min(1040px, calc(100% - 32px));
    min-height: 64px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    color: var(--color-accent);
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: 0;
}

.brand-kana,
.header-link {
    color: var(--color-muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.layout {
    width: min(1040px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 46px;
}

.search-shell {
    display: grid;
    grid-template-columns: minmax(0, 0.88fr) minmax(340px, 1.12fr);
    gap: 24px;
    align-items: start;
}

.intro,
.search-panel,
.result-shell {
    background: linear-gradient(180deg, var(--color-panel), var(--color-panel-soft));
    border: 2px solid var(--color-line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.intro {
    padding: 28px;
}

.intro__eyebrow {
    margin: 0 0 8px;
    color: var(--color-blue);
    font-family: var(--font-display);
    font-size: 0.86rem;
    font-weight: 700;
}

h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 2rem;
    line-height: 1.25;
    letter-spacing: 0;
}

.intro p:last-child {
    margin: 18px 0 0;
    color: var(--color-muted);
    line-height: 1.85;
}

.search-panel,
.result-shell {
    padding: 22px;
}

.origin-list {
    display: grid;
    gap: 12px;
}

.origin-row {
    display: grid;
    grid-template-columns: minmax(110px, 0.8fr) minmax(160px, 1fr) 40px;
    gap: 10px;
    align-items: end;
    padding: 12px;
    background: rgb(255 255 255 / 62%);
    border: 1px solid var(--color-line);
    border-radius: 8px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--color-muted);
    font-size: 0.86rem;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--color-ink);
    background: #fff;
    border: 1px solid rgb(36 33 47 / 22%);
    border-radius: 8px;
}

input:focus,
select:focus,
button:focus-visible {
    outline: 0;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgb(158 38 0 / 14%);
}

.button,
.icon-button {
    min-height: 42px;
    border: 2px solid var(--color-accent);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 15px;
    color: #fff;
    background: var(--color-accent);
}

.button:hover {
    background: var(--color-accent-dark);
    border-color: var(--color-accent-dark);
}

.button--secondary {
    color: var(--color-accent);
    background: #fff;
}

.button--secondary:hover {
    color: var(--color-accent-dark);
    background: rgb(158 38 0 / 10%);
}

.button:disabled,
.icon-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.icon-button {
    width: 40px;
    padding: 0;
    color: var(--color-accent);
    background: #fff;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.form-status {
    min-height: 1.5em;
    margin: 14px 0 0;
    color: var(--color-muted);
    font-size: 0.92rem;
    font-weight: 700;
}

.form-status.is-error {
    color: #b3261e;
}

.result-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: start;
    margin-bottom: 14px;
}

.result-list {
    display: grid;
    gap: 14px;
}

.candidate-card {
    padding: 16px;
    background: rgb(255 255 255 / 72%);
    border: 1px solid var(--color-line);
    border-radius: 8px;
}

.candidate-card__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.candidate-card h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.35rem;
    letter-spacing: 0;
}

.rank-badge {
    color: var(--color-blue);
    font-weight: 800;
}

.candidate-card__reason {
    margin: 10px 0 12px;
    color: var(--color-muted);
    line-height: 1.7;
}

.metric-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.metric {
    padding: 6px 9px;
    background: rgb(23 74 124 / 8%);
    border: 1px solid rgb(23 74 124 / 20%);
    border-radius: 999px;
    color: var(--color-blue);
    font-size: 0.86rem;
    font-weight: 800;
}

.route-table {
    width: 100%;
    border-collapse: collapse;
    overflow-wrap: anywhere;
}

.route-table th,
.route-table td {
    padding: 9px 8px;
    border-top: 1px solid var(--color-line);
    text-align: left;
}

.route-table th {
    color: var(--color-muted);
    font-size: 0.84rem;
}

@media (max-width: 760px) {
    .site-header__inner,
    .layout {
        width: min(100% - 24px, 1040px);
    }

    .search-shell {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.62rem;
    }

    .origin-row {
        grid-template-columns: 1fr 1fr 40px;
    }

    .result-head {
        display: grid;
    }
}

@media (max-width: 520px) {
    .brand-kana {
        display: none;
    }

    .origin-row {
        grid-template-columns: 1fr 40px;
    }

    .origin-row label {
        grid-column: 1 / -1;
    }

    .origin-row__remove {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    .form-actions,
    .form-actions .button {
        width: 100%;
    }
}
