:root {
    color-scheme: dark;

    --bg: #0e1116;
    --surface: #171b22;
    --surface-2: #1f242d;
    --border: #2a303b;
    --text: #e8eaf0;
    --muted: #9099a8;

    --accent: #f2b84b;
    --accent-text: #1a1304;
    --ok: #4cc38a;
    --bad: #f2777a;

    --identical: #4cc38a;
    --false-friend: #f2b84b;
    --unique: #6ea8fe;

    --radius: 16px;
    --nav-height: 64px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

html {
    /* żeby element z fokusem nie chował się pod dolnym paskiem */
    scroll-padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 8px);
}

h1 {
    font-size: 1.6rem;
    margin: 0 0 4px;
}

    h1:focus {
        outline: none;
    }

h2 {
    font-size: 1.05rem;
    margin: 0 0 12px;
}

p {
    margin: 0 0 12px;
}

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

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

.small {
    font-size: 0.85rem;
}

/* układ strony */

.app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px);
}

.page-head {
    margin-bottom: 16px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

/* przyciski - duże, żeby dało się trafić kciukiem */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 56px;
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
}

    .btn:active {
        transform: scale(0.98);
    }

    .btn:disabled {
        opacity: 0.5;
        cursor: default;
    }

    .btn:focus-visible, input:focus-visible, select:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

.btn-primary {
    background: var(--accent);
    border-color: transparent;
    color: var(--accent-text);
}

.btn-ok {
    background: var(--ok);
    border-color: transparent;
    color: #06200f;
}

.btn-bad {
    background: var(--bad);
    border-color: transparent;
    color: #2b0607;
}

.btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* pola formularzy */

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

    .field > span {
        display: block;
        margin-bottom: 6px;
        color: var(--muted);
        font-size: 0.85rem;
    }

input[type=text], select {
    width: 100%;
    min-height: 56px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 56px;
    cursor: pointer;
}

    .switch input {
        width: 28px;
        height: 28px;
        accent-color: var(--accent);
    }

.message {
    margin: 12px 0 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    font-size: 0.95rem;
}

    .message.ok {
        color: var(--ok);
    }

    .message.bad {
        color: var(--bad);
    }

/* nauka: fiszki i quiz - karta rośnie, przyciski zostają na dole pod kciukiem */

.study {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.segmented {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

    .segmented button {
        min-height: 44px;
        padding: 0 4px;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: var(--muted);
        font: inherit;
        font-size: 0.85rem;
        font-weight: 600;
        cursor: pointer;
        touch-action: manipulation;
    }

        .segmented button.active {
            background: var(--surface-2);
            color: var(--text);
            box-shadow: inset 0 0 0 1px var(--border);
        }

.feedback {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
}

    .feedback strong {
        display: block;
    }

    .feedback.ok strong {
        color: var(--ok);
    }

    .feedback.bad strong {
        color: var(--bad);
    }

/* statystyki na stronie głównej */

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    text-align: center;
}

    .stats strong {
        display: block;
        font-size: 1.7rem;
        line-height: 1.2;
    }

    .stats span {
        color: var(--muted);
        font-size: 0.8rem;
    }

/* ekran ładowania i błędów z szablonu Blazora */

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

    .loading-progress circle {
        fill: none;
        stroke: var(--surface-2);
        stroke-width: 0.5rem;
        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;
    color: var(--muted);
    inset: calc(28vh + 2.8rem) 0 auto 0;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Ładowanie");
    }

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    padding: 14px 48px calc(14px + env(safe-area-inset-bottom)) 16px;
    background: #4a1d1f;
    color: #ffe3e3;
}

    #blazor-error-ui .dismiss {
        position: absolute;
        right: 16px;
        top: 12px;
        cursor: pointer;
    }

.blazor-error-boundary {
    padding: 16px;
    border-radius: var(--radius);
    background: #4a1d1f;
    color: #ffe3e3;
}

    .blazor-error-boundary::after {
        content: "Wystąpił błąd.";
    }

/* pasek "dostępna nowa wersja" */

#update-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 12px);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 536px;
    margin: 0 auto;
    padding: 10px 10px 10px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

    #update-banner[hidden] {
        display: none;
    }

    #update-banner button {
        min-height: 44px;
        padding: 0 16px;
        border: 0;
        border-radius: 10px;
        background: var(--accent);
        color: var(--accent-text);
        font: inherit;
        font-weight: 600;
        cursor: pointer;
    }

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
