:root {
    color-scheme: light;
    --bg: #ffffff;
    --panel: #ffffff;
    --panel-strong: #f5f1e8;
    --text: #171817;
    --muted: #625f57;
    --line: #ded8cc;
    --accent: #d8b75a;
    --accent-strong: #946f00;
    --demo-light: #fbf7ec;
    --demo-dark: #181818;
    --shadow: 0 22px 60px rgba(34, 28, 18, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, rgba(216, 183, 90, 0.12), transparent 460px),
        var(--bg);
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    line-height: 1.6;
}

a {
    color: inherit;
}

.i18n {
    display: none;
}

html[data-content-lang="en"] .i18n[lang="en"],
html[data-content-lang="ja"] .i18n[lang="ja"] {
    display: revert;
}

html[data-content-lang="en"] .i18n-block[lang="en"],
html[data-content-lang="ja"] .i18n-block[lang="ja"] {
    display: block;
}

html[data-content-lang="en"] .i18n-inline[lang="en"],
html[data-content-lang="ja"] .i18n-inline[lang="ja"] {
    display: inline;
}

.site-header,
main,
footer {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 0;
}

.nav-links,
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-links a {
    color: var(--muted);
    font-size: 0.95rem;
    text-decoration: none;
}

.nav-links a:hover {
    color: var(--text);
}

.lang-switcher {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.lang-switcher select {
    width: auto;
    min-height: 38px;
}

.intro {
    display: flex;
    flex-direction: column;
    gap: 34px;
    align-items: stretch;
    padding: 0 0 44px;
}

.intro-copy {
    max-width: 860px;
    margin: 0 auto;
}

.section-heading {
    max-width: 720px;
    margin-bottom: 24px;
}

.intro-title {
    margin: 0 0 24px;
    font-size: clamp(2.8rem, 8vw, 6.4rem);
    font-weight: 400;
    line-height: 0.98;
    letter-spacing: 0;
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p,
li {
    overflow-wrap: anywhere;
}

h2 {
    margin: 14px 0;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    line-height: 1.05;
    letter-spacing: 0;
}

h3 {
    margin: 14px 0;
    font-size: 1.18rem;
}

p {
    margin: 0;
}

ol {
    margin: 0;
    padding-left: 1.25rem;
}

.lede,
.section-heading p,
.download p,
.info-section p,
.info-section li,
.font-list-section p {
    color: var(--muted);
    font-size: 1.05rem;
}

.lede {
    max-width: 660px;
    margin-top: 24px;
    font-size: clamp(1.08rem, 2.2vw, 1.35rem);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 30px;
}

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.button.primary {
    border-color: rgba(240, 204, 104, 0.5);
    background: var(--accent);
    color: #15130c;
}

.intro-figure {
    margin: 0;
}

.intro-figure img {
    display: block;
    width: 100%;
    max-height: 620px;
    object-fit: cover;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.demo-section {
    padding: 38px 0 56px;
}

.demo-panel,
.download,
.info-section,
.font-list-section {
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.demo-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 14px 18px 0;
}

.theme-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 750;
}

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

.theme-track {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 132px;
    min-height: 38px;
    padding: 4px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
    cursor: pointer;
}

.theme-track span {
    display: grid;
    place-items: center;
    color: var(--muted);
}

.theme-switch input:not(:checked) + .theme-track span:first-child,
.theme-switch input:checked + .theme-track span:last-child {
    background: var(--accent);
    color: #15130c;
    font-weight: 850;
}

.demo-text-wrap {
    position: relative;
}

.demo-text {
    display: flex;
    min-height: 280px;
    align-items: center;
    justify-content: center;
    padding: 28px;
    border-bottom: 1px solid var(--line);
    background: var(--demo-light);
    color: #111;
    font-size: clamp(5rem, 17vw, 12rem);
    line-height: 1;
    text-align: center;
    outline: none;
    overflow-wrap: anywhere;
    transition:
        background-color 160ms ease,
        color 160ms ease;
}

.demo-panel[data-demo-background="dark"] .demo-text {
    background: var(--demo-dark);
    color: #eee;
}

.font-progress {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 5px;
    overflow: hidden;
    background: transparent;
    pointer-events: none;
}

.font-progress span {
    display: block;
    width: 100%;
    height: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: var(--accent);
    transition: transform 120ms ease;
}

.font-progress[data-state="loaded"] span {
    opacity: 0;
    transition:
        transform 120ms ease,
        opacity 700ms ease 260ms;
}

.font-progress[data-state="error"] span {
    background: #cf3f34;
}

.controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    align-items: end;
    padding: 18px;
}

.control {
    min-width: 0;
}

.control > span,
.control legend {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

select,
.segmented,
.check {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
    color: var(--text);
}

select {
    padding: 0 12px;
    border-radius: 0;
    font: inherit;
}

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin: 0;
    padding: 4px;
}

.segmented label,
.check {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

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

.segmented span {
    display: flex;
    width: 100%;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

.segmented input:checked + span {
    background: var(--accent);
    color: #15130c;
    font-weight: 800;
}

/* === Compact Language Toggle === */
.lang-switcher.segmented {
    width: auto; /* Key fix: don't stretch */
    min-height: 38px; /* Slightly smaller than 46px */
    padding: 3px;
    gap: 3px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
    border-radius: 6px; /* Optional: softer look */
    display: inline-grid; /* Makes it size to content */
    grid-template-columns: auto auto;
}

.lang-switcher.segmented label {
    min-height: 32px; /* Reduce height */
    gap: 6px;
}

.lang-switcher.segmented span {
    min-height: 32px;
    padding: 0 4px;
    font-size: 0.85rem; /* Slightly smaller text */
    font-weight: 600;
}

/* Make the active state look cleaner */
.lang-switcher.segmented input:checked + span {
    background: var(--accent);
    color: #15130c;
    font-weight: 700;
    border-radius: 4px;
}

.check {
    padding: 0 12px;
    font-weight: 700;
}

.check input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.download-current {
    width: 100%;
}

.download {
    margin: 28px 0 24px;
    padding: 24px;
}

.info-section,
.font-list-section {
    margin: 24px 0;
    padding: 24px;
}

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

.install-grid article {
    border: 1px solid var(--line);
    background: var(--panel-strong);
    padding: 18px;
}

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

.font-download {
    display: grid;
    gap: 4px;
    min-height: 74px;
    align-content: center;
    padding: 14px 16px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
    text-decoration: none;
}

.font-download:hover {
    border-color: var(--accent);
    background: #fff9e6;
}

.font-download span {
    color: var(--muted);
    font-size: 0.92rem;
}

code {
    color: var(--accent-strong);
}

footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 28px 0 42px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.92rem;
}

footer a {
    color: var(--text);
}

@media (max-width: 920px) {
    .controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .download-current {
        grid-column: 1 / -1;
    }
}

@media (max-width: 820px) {
    .nav,
    footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .install-grid,
    .font-download-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .site-header,
    main,
    footer {
        width: min(100% - 20px, 1120px);
    }

    .nav-links {
        flex-wrap: wrap;
    }

    .intro {
        padding-top: 20px;
    }

    .demo-toolbar {
        justify-content: flex-start;
    }

    .theme-switch {
        align-items: flex-start;
        flex-direction: column;
    }

    .demo-text {
        min-height: 220px;
        padding: 18px;
    }

    .controls {
        grid-template-columns: 1fr;
    }
}
