:root {
    color-scheme: light dark;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #1d2733;
    --muted: #5b6b7c;
    --border: #d5dde6;
    --accent: #1f3a5f;
    --accent-text: #ffffff;
    --link: #1f5fa8;
    --code-bg: #eef2f6;
    --error: #b42318;
    --warning-bg: #fff7e0;
    --warning-border: #e6b84d;
    --start: #d9dee5;
    --zip: #d6e6fb;
    --address: #dcf2e1;
    --check: #f8e1c8;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11161c;
        --surface: #1a2129;
        --text: #e3e9ef;
        --muted: #9aa8b6;
        --border: #2e3843;
        --accent: #8fb3e0;
        --accent-text: #0f1a27;
        --link: #8fb8ec;
        --code-bg: #222b35;
        --error: #ff8a80;
        --warning-bg: #3a3018;
        --warning-border: #8a6d1f;
        --start: #39424d;
        --zip: #233b5a;
        --address: #234530;
        --check: #4d3721;
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
    line-height: 1.7;
}

a {
    color: var(--link);
}

code, pre {
    font-family: ui-monospace, "Cascadia Mono", Consolas, "Noto Sans Mono", monospace;
}

.wrap {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 16px;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 24px 0 16px;
    margin-bottom: 24px;
}

.site-header h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 8px;
    font-size: 1.5rem;
    line-height: 1.3;
}

.site-header h1 span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.site-header h1 img {
    border-radius: 6px;
    flex: none;
}

.lead {
    margin: 0 0 8px;
    color: var(--muted);
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 8px;
}

.badges img {
    display: block;
}

.links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.card h2 {
    margin: 0 0 12px;
    font-size: 1.15rem;
}

.card h3 {
    margin: 24px 0 8px;
    font-size: 1rem;
}

.samples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.samples-label {
    color: var(--muted);
    font-size: 0.9rem;
}

.sample {
    font: inherit;
    font-size: 0.875rem;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--code-bg);
    color: var(--text);
    cursor: pointer;
}

.sample:hover {
    border-color: var(--accent);
}

.field {
    display: block;
    margin-bottom: 14px;
}

.field > span {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.field input {
    width: 100%;
    font: inherit;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
}

.field input:focus, .sample:focus-visible, .button:focus-visible, .mode input:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 1px;
}

.mode {
    border: 0;
    padding: 0;
    margin: 0 0 14px;
}

.mode legend {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.mode label {
    display: block;
    cursor: pointer;
}

.note {
    margin: 0;
    font-size: 0.875rem;
    color: var(--muted);
}

.placeholder, .muted {
    color: var(--muted);
}

.muted {
    font-size: 0.85rem;
    margin-left: 8px;
}

.error {
    color: var(--error);
    font-weight: 600;
}

.warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: 6px;
    padding: 8px 12px;
}

/* バーコードは白地に黒(ライブラリの出力のまま)。ダークモードでも白地で表示する */
.barcode {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
}

.barcode svg {
    display: block;
    width: 100%;
    max-width: 828px;
    height: auto;
    margin: 0 auto;
}

.downloads {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.button {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    background: var(--accent);
    color: var(--accent-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}

.button.secondary {
    background: transparent;
    color: var(--link);
    border: 1px solid var(--border);
}

.details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 16px;
    margin: 16px 0 0;
}

.details dt {
    font-weight: 600;
}

.details dd {
    margin: 0;
    min-width: 0;
}

.details code {
    background: var(--code-bg);
    padding: 1px 6px;
    border-radius: 4px;
}

/* シンボル列は区切り(スタート・郵便番号・住所表示番号・チェックデジット・ストップ)ごとにまとめ、まとまりの単位で折り返す */
.symbol-groups {
    display: flex;
    flex-wrap: wrap;
    /* 見出しが2行のまとまり(チェックデジット)があっても、記号の行をそろえる */
    align-items: flex-end;
    gap: 12px 10px;
}

.symbol-group {
    min-width: 0;
}

.symbol-group-label {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.3;
    margin-bottom: 4px;
    white-space: pre;
}

.symbols {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.symbol {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 0.85rem;
    padding: 1px 6px;
    border-radius: 4px;
    min-width: 2em;
    text-align: center;
}

.symbol-group.start .symbol { background: var(--start); }
.symbol-group.zip .symbol { background: var(--zip); }
.symbol-group.address .symbol { background: var(--address); }
.symbol-group.check .symbol { background: var(--check); }

.code {
    background: var(--code-bg);
    border-radius: 6px;
    padding: 12px 14px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.6;
    margin: 0;
}

/* 「このデモについて」の箇条書き(シンボル列などのリストには当てない) */
.card > ul {
    margin: 0;
    padding-left: 1.25em;
}

/* 長いパッケージ名などが狭い画面ではみ出さないよう折り返す */
.card > ul code, .details code {
    overflow-wrap: anywhere;
}

/* 画面には表示せず、スクリーンリーダーにだけ読ませる */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.footer {
    color: var(--muted);
    font-size: 0.85rem;
    padding-bottom: 32px;
}

@media (max-width: 560px) {
    .details {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .details dd {
        margin-bottom: 10px;
    }

    .muted {
        display: block;
        margin-left: 0;
    }
}

/* 読み込み中の表示とエラー表示(Blazor のテンプレートより) */
.loading {
    position: relative;
    min-height: 60vh;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--border);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "読み込み中");
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    color: #1d2733;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
