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

:root {
    color-scheme: light dark;
    --font:
        -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
        sans-serif;
    --bg: light-dark(#f4f5fb, #0d0d1a);
    --surface: light-dark(rgba(255, 255, 255, 0.8), rgba(20, 20, 40, 0.8));
    --text: light-dark(#1a1a2e, #e8e8f0);
    --text-secondary: light-dark(#6b7280, #8888a0);
    --border: light-dark(rgba(0, 0, 0, 0.06), rgba(255, 255, 255, 0.06));
    --primary: light-dark(#14b8a6, #2dd4bf);
    --primary-hover: light-dark(#0d9488, #14b8a6);
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: light-dark(
        0 1px 3px rgba(0, 0, 0, 0.06),
        0 1px 3px rgba(0, 0, 0, 0.3)
    );
    --shadow-lg: light-dark(
        0 10px 25px rgba(0, 0, 0, 0.08),
        0 10px 25px rgba(0, 0, 0, 0.4)
    );
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html,
body {
    min-height: 100%;
}

body:not(.page-poll) {
    display: flex;
    flex-direction: column;
}

body:not(.page-poll) main {
    flex-grow: 1;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 0 0 0.5rem;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 2rem 0 0.75rem;
}

h3 {
    font-size: 1.17rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
}

hgroup {
    margin-bottom: 2rem;
}

hgroup p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 0;
}

p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1rem;
}

a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-hover);
}

fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

input[type="text"] {
    font-family: inherit;
    font-size: 1rem;
    padding: 0.875rem 1.25rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    width: 100%;
    outline: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px
        light-dark(rgba(99, 102, 241, 0.15), rgba(129, 140, 248, 0.15));
}

button {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

button:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

button:not(:disabled):active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

article {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

article:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

article header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 1rem;
}

article header .counter {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

progress {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 100%;
    height: 0.75rem;
    border-radius: 999px;
    overflow: hidden;
    display: block;
    background: var(--border);
}

progress::-webkit-progress-bar {
    background: transparent;
}

progress::-webkit-progress-value {
    background: var(--progress-color, var(--primary));
    border-radius: 999px;
    transition: width 0.5s ease;
}

progress::-moz-progress-bar {
    background: var(--progress-color, var(--primary));
    border-radius: 999px;
}

ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

li {
    margin: 0;
}

li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

li a:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
    border-color: var(--primary);
}

#error {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

pre {
    background: light-dark(#1a1a2e, #0d0d1a);
    color: #e8e8f0;
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.6;
    border: 1px solid var(--border);
}

code {
    font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
}

.tk-kw {
    color: #c792ea;
}
.tk-fn {
    color: #82aaff;
}
.tk-str {
    color: #c3e88d;
}
.tk-ml {
    color: #f78c6c;
}
.tk-op {
    color: #89ddff;
}
.tk-nl {
    color: #546e7a;
}

footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Index page */
.nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.nav a {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.nav a:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.hero {
    position: relative;
    margin-bottom: 2.5rem;
}

.hero .gh {
    position: absolute;
    top: 0.25rem;
    right: 0;
    color: var(--text-secondary);
    opacity: 0.35;
    transition: opacity 0.2s;
    line-height: 0;
}

.hero .gh:hover {
    opacity: 1;
    color: var(--text-secondary);
}

.hero .gh svg {
    width: 22px;
    height: 22px;
}

.card {
    padding: 1.5rem;
    margin-bottom: 2.5rem;
}

.hints {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin: 1rem 0 1.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.hints span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Poll pages (vote, many, result) */
body.page-poll {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

body.page-poll main {
    display: grid;
    gap: 1vh;
    grid-template-columns: 1;

    button {
        --dark-luminance: 8;
        --light-luminance: 95;
        background: var(--bg);
        color: lch(
            from var(--bg)
                clamp(
                    var(--dark-luminance),
                    round((100 - l), 100),
                    var(--light-luminance)
                )
                0 0
        );
    }
}

@media (min-width: 768px) {
    body.page-poll main {
        grid-template-columns: repeat(2, 1fr);
        &:has(> :nth-child(1):last-child) {
            grid-template-columns: repeat(1, minmax(0, 25%));
            justify-content: center;
        }
        &:has(> :nth-child(2):last-child) {
            grid-template-columns: repeat(2, 1fr);
        }
    }
}

@media (min-width: 1224px) {
    body.page-poll main {
        grid-template-columns: repeat(2, 1fr);
        &:has(> :nth-child(1):last-child) {
            grid-template-columns: repeat(1, minmax(0, 25%));
            justify-content: center;
        }
        &:has(> :nth-child(2):last-child) {
            grid-template-columns: repeat(2, 1fr);
        }
        &:has(> :nth-child(3):last-child) {
            grid-template-columns: repeat(3, 1fr);
        }
    }
}
