:root {
    color-scheme: light dark;
    --background: #f4f4f1;
    --surface: #ffffff;
    --surface-hover: #eeeeea;
    --text: #171817;
    --muted: #70736f;
    --border: #d8d9d4;
    --focus: #365b84;
    --page-width: 880px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #121413;
        --surface: #1b1e1c;
        --surface-hover: #242824;
        --text: #eceeea;
        --muted: #a4aaa2;
        --border: #363b36;
        --focus: #8bb7e8;
    }
}

:root[data-theme="light"] {
    --background: #f4f4f1;
    --surface: #ffffff;
    --surface-hover: #eeeeea;
    --text: #171817;
    --muted: #70736f;
    --border: #d8d9d4;
    --focus: #365b84;
}

:root[data-theme="dark"] {
    --background: #121413;
    --surface: #1b1e1c;
    --surface-hover: #242824;
    --text: #eceeea;
    --muted: #a4aaa2;
    --border: #363b36;
    --focus: #8bb7e8;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--background);
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--background);
    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

.skip-link {
    position: fixed;
    z-index: 10;
    top: 0.75rem;
    left: 0.75rem;
    padding: 0.65rem 0.8rem;
    border-radius: 0.35rem;
    background: var(--text);
    color: var(--surface);
    font-size: 0.875rem;
    transform: translateY(-180%);
}

.skip-link:focus {
    transform: translateY(0);
}

.page {
    width: min(var(--page-width), calc(100% - 3rem));
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    grid-template-rows: auto 1fr;
}

.site-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: -0.015em;
    text-decoration: none;
}

.brand-mark {
    width: 1.85rem;
    height: 1.85rem;
    display: grid;
    place-items: center;
    border-radius: 0.35rem;
    background: var(--text);
    color: var(--surface);
    font-size: 0.72rem;
    font-weight: 700;
}

.theme-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-icon {
    width: 1rem;
    height: 1rem;
    display: grid;
    place-items: center;
    color: var(--muted);
    transition: color 140ms ease;
}

.theme-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

:root[data-theme="light"] .theme-icon-sun,
:root[data-theme="dark"] .theme-icon-moon {
    color: var(--text);
}

.theme-toggle {
    width: 2.75rem;
    height: 1.5rem;
    padding: 0.16rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background-color: var(--surface);
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease;
}

.theme-toggle:hover {
    background-color: var(--surface-hover);
}

.theme-toggle:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.theme-toggle-thumb {
    width: 1rem;
    height: 1rem;
    display: block;
    border-radius: 50%;
    background: var(--text);
    transform: translateX(0);
    transition: transform 160ms ease;
}

.theme-toggle[aria-checked="true"] .theme-toggle-thumb {
    transform: translateX(1.25rem);
}

main {
    align-self: center;
    padding: 3rem 0;
}

.section-heading {
    margin-bottom: 1.25rem;
}

.section-heading h1 {
    margin: 0;
    font-size: clamp(1.7rem, 4vw, 2.15rem);
    font-weight: 650;
    letter-spacing: -0.04em;
}

.app-list {
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--surface);
    list-style: none;
    overflow: hidden;
}

.app-list li + li {
    border-left: 1px solid var(--border);
}

.app-link {
    min-height: 190px;
    padding: 1.35rem;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: 1fr auto;
    gap: 1rem;
    text-decoration: none;
    transition: background-color 140ms ease;
}

.app-link:hover {
    background: var(--surface-hover);
}

.app-link:focus-visible {
    position: relative;
    z-index: 1;
    outline: 3px solid var(--focus);
    outline-offset: -3px;
}

.app-icon {
    grid-column: 1;
    grid-row: 1;
    width: 2.6rem;
    height: 2.6rem;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 0.55rem;
    background: var(--background);
}

.app-icon svg {
    width: 1.35rem;
    height: 1.35rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-copy {
    grid-column: 1;
    grid-row: 2;
    align-self: end;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.app-copy strong {
    font-size: 1rem;
    font-weight: 650;
}

.app-copy small {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.arrow {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
    color: var(--muted);
    font-size: 1rem;
    transition: color 140ms ease, transform 140ms ease;
}

.app-link:hover .arrow,
.app-link:focus-visible .arrow {
    color: var(--text);
    transform: translate(2px, -2px);
}

.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.error-card {
    width: min(460px, 100%);
    padding: clamp(1.75rem, 6vw, 2.75rem);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--surface);
}

.error-card .brand {
    margin-bottom: 3rem;
}

.error-code {
    margin: 0 0 0.6rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.08em;
}

.error-card h1 {
    margin: 0;
    font-size: clamp(1.65rem, 7vw, 2.2rem);
    font-weight: 650;
    letter-spacing: -0.035em;
}

.error-card > p:not(.error-code) {
    margin: 1rem 0 1.5rem;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.button {
    min-height: 2.7rem;
    padding: 0.7rem 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 0.4rem;
    background: var(--text);
    color: var(--surface);
    font-size: 0.82rem;
    font-weight: 650;
    text-decoration: none;
}

.button:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

@media (max-width: 680px) {
    .page {
        width: min(100% - 2rem, 440px);
    }

    .site-header {
        min-height: 62px;
    }

    main {
        padding: 2rem 0;
    }

    .app-list {
        grid-template-columns: 1fr;
    }

    .app-list li + li {
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .app-link {
        min-height: 92px;
        padding: 1rem;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: 1fr;
        align-items: center;
    }

    .app-icon {
        grid-column: 1;
        grid-row: 1;
    }

    .app-copy,
    .arrow {
        align-self: center;
    }

    .app-copy {
        grid-column: 2;
        grid-row: 1;
    }

    .arrow {
        grid-column: 3;
        grid-row: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
