:root {
    --bg: #ffffff;
    --bg2: #f6f7f9;
    --card: #ffffff;
    --card2: #f1f2f6;
    --text: #0b0d12;
    --muted: #5a6576;
    --line: #e6e8ee;
    --accent: #111827;
    --accent2: #374151;
    --danger: #e2555f;
    --ok: #1f9d5a;
    --shadow: 0 18px 50px rgba(10, 20, 35, .10);
    --radius: 16px;
    --focus: rgba(17, 24, 39, .12);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    min-height: 100%;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 18px;
}

.auth-page .container {
    align-items: center;
    justify-content: center;
}

.shell {
    width: 100%;
    max-width: 980px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-page .shell {
    width: min(520px, 100%);
    max-width: 520px;
    align-items: center;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 6px;
}

.auth-page .topbar {
    width: 100%;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    padding: 10px 6px 2px;
}

.auth-page #langBtn {
    align-self: flex-end;
    order: -1;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.auth-page .brand {
    align-items: center;
    text-align: center;
}

.brand h1 {
    margin: 0;
    font-size: 18px;
    letter-spacing: .2px;
}

.brand p {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.auth-page .brand-icon {
    width: 64px;
    height: 64px;
    margin-top: 10px;
    margin-bottom: 8px;
    object-fit: contain;
    display: block;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 14px 14px 10px 14px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.card-header h2 {
    margin: 0;
    font-size: 16px;
}

.card-header .sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.card-body {
    padding: 14px;
}

.pwa-prompt {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    width: min(560px, calc(100% - 24px));
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
    box-shadow: var(--shadow);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 1200;
}

.pwa-prompt.show {
    display: flex;
}

.pwa-prompt.above-nav {
    bottom: calc(96px + env(safe-area-inset-bottom));
}

.pwa-prompt .copy {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

.pwa-prompt .actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.pwa-prompt.ios .pwa-install {
    display: none;
}

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

@media (min-width: 860px) {
    .grid-2 {
        grid-template-columns: 1.1fr .9fr;
    }
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.label {
    font-size: 12px;
    color: var(--muted);
}

.input,
select,
button,
textarea {
    font: inherit;
}

.input,
select,
textarea {
    width: 100%;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg2);
    color: var(--text);
    outline: none;
}

.input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--focus);
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.row.stretch>* {
    flex: 1;
}

.btn {
    border: 1px solid var(--line);
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bg2);
    color: var(--text);
    cursor: pointer;
    transition: transform .05s ease, background .2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    user-select: none;
}

.btn:hover {
    background: #eef0f4;
}

.btn:active {
    transform: translateY(1px);
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    color: #ffffff;
}

.btn.primary:hover {
    filter: brightness(1.05);
}

.btn.danger {
    background: rgba(226, 85, 95, .12);
    border: 1px solid rgba(226, 85, 95, .35);
    color: #b4232d;
}

.btn.small {
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 12px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg2);
    color: var(--muted);
}

.pill.ok {
    color: var(--ok);
    border-color: rgba(39, 209, 127, .35);
    background: rgba(39, 209, 127, .10);
}

.pill.warn {
    color: #ffd36b;
    border-color: rgba(255, 211, 107, .35);
    background: rgba(255, 211, 107, .10);
}

.alert {
    border: 1px solid var(--line);
    background: var(--bg2);
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13px;
    color: var(--text);
}

.alert.error {
    border-color: rgba(255, 92, 122, .40);
    background: rgba(255, 92, 122, .10);
}

.alert.success {
    border-color: rgba(39, 209, 127, .40);
    background: rgba(39, 209, 127, .10);
}

.divider {
    height: 1px;
    background: var(--line);
    margin: 12px 0;
}

.seg {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.seg button {
    flex: 1;
    min-width: 64px;
    padding: 10px 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg2);
    color: var(--muted);
}

.seg button.active {
    color: #ffffff;
    border-color: var(--accent);
    background: var(--accent);
}

.list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item {
    border: 1px solid var(--line);
    background: var(--bg2);
    padding: 10px 12px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item .title {
    font-weight: 650;
    font-size: 14px;
}

.item .meta {
    color: var(--muted);
    font-size: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.kbd {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 8px;
    background: var(--bg2);
    border: 1px solid var(--line);
    color: var(--text);
    word-break: break-all;
}

details {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--bg2);
    overflow: hidden;
}

details summary {
    cursor: pointer;
    padding: 12px 12px;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

details summary::-webkit-details-marker {
    display: none;
}

details .content {
    padding: 0 12px 12px 12px;
}

.exercise-btn {
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: var(--bg2);
    color: var(--text);
    padding: 10px 10px;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 8px;
}

.exercise-btn:hover {
    border-color: var(--accent);
    background: #eef0f4;
}

.footer-note {
    font-size: 12px;
    color: var(--muted);
    padding: 0 6px 6px 6px;
}
