:root {
    --ink: #1c1916;
    --muted: #5c564e;
    --cream: #f4efe6;
    --paper: #fffdf8;
    --line: #ddd4c4;
    --forest: #1f3d32;
    --terracotta: #c45c26;
    --danger: #9b2c2c;
    --focus: #1f3d32;
    --radius: 16px;
    --font: "Outfit", system-ui, sans-serif;
    --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--cream);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
}

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

h1, h2 {
    font-family: var(--display);
    font-weight: 650;
    letter-spacing: -0.02em;
}

h1 { font-size: 2rem; margin: 0 0 0.4rem; }
h2 { font-size: 1rem; margin: 0 0 0.5rem; }

.shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    background: var(--forest);
    color: #f4efe6;
    padding: 1.5rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.brand, .brand:hover { color: inherit; text-decoration: none; display: flex; gap: 0.75rem; align-items: center; }
.brand small { display: block; color: #d7e3dc; font-size: 0.75rem; }
.brand-mark {
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--terracotta); color: #fff;
    display: grid; place-items: center; font-family: var(--display); font-weight: 650;
}

.nav { display: flex; flex-direction: column; gap: 0.25rem; }
.nav a {
    color: #e8efe9;
    text-decoration: none;
    min-height: 44px;
    display: flex; align-items: center;
    padding: 0 0.8rem;
    border-radius: 10px;
}
.nav a.is-active, .nav a:hover { background: rgba(255,255,255,0.1); }
.nav a[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }

.sidebar-foot { margin-top: auto; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); background: var(--paper);
}
.topbar p { margin: 0; font-weight: 600; }

.content { padding: 1.5rem; padding-bottom: 5.5rem; }

.bottom-nav {
    display: none;
    position: sticky; bottom: 0;
    background: var(--paper);
    border-top: 1px solid var(--line);
    padding: 0.4rem;
}
.bottom-nav a {
    min-height: 44px; display: flex; align-items: center; justify-content: center;
    text-decoration: none; color: var(--ink); font-size: 0.85rem;
}

.pill {
    background: #efe4d4; color: var(--forest);
    border-radius: 999px; padding: 0.3rem 0.75rem; font-size: 0.85rem;
}

.hero-panel, .card, .stats article {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.85rem;
    margin: 1.25rem 0;
}
.stat { font-family: var(--display); font-size: 1.7rem; margin: 0; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.muted { color: var(--muted); }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 0 1rem;
    border-radius: 12px; border: 1px solid transparent;
    font: inherit; cursor: pointer;
}
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--terracotta);
    outline-offset: 2px;
}
.btn-primary { background: var(--forest); color: #fff; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: inherit; border-color: currentColor; }
.btn-danger { background: var(--danger); color: #fff; }

.form { display: grid; gap: 0.9rem; }
.form label { display: grid; gap: 0.35rem; font-weight: 500; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="url"],
input[type="tel"],
input[type="file"],
textarea,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.55rem 0.85rem;
    font: inherit;
    color: var(--ink);
    background-color: var(--paper);
    color-scheme: light;
    -webkit-appearance: none;
    appearance: none;
}

textarea {
    min-height: 6.75rem;
    line-height: 1.5;
    resize: vertical;
}

select {
    padding-right: 2.4rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%231f3d32' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    cursor: pointer;
}

select::-ms-expand { display: none; }

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
input[type="number"]:hover,
input[type="url"]:hover,
input[type="tel"]:hover,
textarea:hover,
select:hover {
    border-color: #c8bba8;
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: 1;
}

input[type="checkbox"],
input[type="radio"] {
    width: 1.15rem;
    height: 1.15rem;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 4px;
    accent-color: var(--forest);
    -webkit-appearance: auto;
    appearance: auto;
    cursor: pointer;
}

input[type="file"] {
    padding: 0.45rem 0.7rem;
    background: #fff;
}

.check { display: flex !important; flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 400; }
.check input[type="checkbox"],
.check input[type="radio"] { width: 1.15rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.meta-links { display: flex; gap: 1rem; }
.errors { color: var(--danger); padding-left: 1.1rem; }
.flash { background: #e4efe8; padding: 0.75rem 1rem; border-radius: 10px; }

.auth-page {
    min-height: 100vh;
    display: grid; place-items: center;
    background:
        radial-gradient(circle at top right, #e8d5c4, transparent 32%),
        var(--cream);
    padding: 1.5rem;
}
.auth-card {
    width: min(460px, 100%);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 2rem;
}
.eyebrow { text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.75rem; color: var(--terracotta); margin: 0; }

.table { width: 100%; border-collapse: collapse; background: var(--paper); }
.table th, .table td { text-align: left; padding: 0.75rem; border-bottom: 1px solid var(--line); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.toolbar h1, .toolbar h2 { margin: 0; }
.danger { margin-top: 1.5rem; border-color: #e8c4c4; }

.inline-form {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}
.inline-form select {
    width: auto;
    min-width: 9rem;
}
.lesson-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.lesson-list a { display: flex; flex-direction: column; min-height: 44px; text-decoration: none; color: inherit; }
.vocab-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; }
.result-wrong { background: #f8e6e4; padding: 0.75rem 1rem; border-radius: 10px; }
.prose { white-space: normal; }
blockquote { border-left: 3px solid var(--terracotta); padding-left: 0.8rem; color: var(--muted); }
.disclaimer { font-size: 0.9rem; color: var(--muted); }
.goal-bar {
    height: 10px;
    background: #efe4d4;
    border-radius: 999px;
    overflow: hidden;
    margin: 0.75rem 0 0;
}
.goal-bar span { display: block; height: 100%; background: var(--forest); }
.hangman-word {
    letter-spacing: 0.35em;
    font-size: 2rem;
    font-family: var(--display);
    margin: 0 0 0.75rem;
}
.letter-grid { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.letter-grid .btn { min-width: 44px; padding: 0 0.6rem; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; }
.badge-grid article { background: #f6efe8; border-radius: 12px; padding: 0.85rem; }
.badge-grid .is-locked { opacity: 0.45; }
.chat { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.chat-user { background: #f6efe8; }
.eval-card { border-color: #e4d2c4; }
.timer {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}
.timer.is-low { color: var(--danger); border-color: #e8c4c4; }
.exam-q { display: grid; gap: 0.5rem; padding: 0.75rem 0; border-top: 1px solid var(--line); }
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 1rem;
}
.filters label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.filters input,
.filters select { min-width: 11rem; }
.filters-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
}
.filters-search {
    display: grid;
    grid-template-columns: 1fr auto;
}
.filters-grid input,
.filters-grid select,
.filters-search input { min-width: 0; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .bottom-nav { display: grid; grid-template-columns: repeat(4, 1fr); }
    .stats, .split, .grid-2, .filters-grid, .filters-search { grid-template-columns: 1fr; }
    .content { padding-bottom: 6rem; }
}
