:root { font-family: system-ui, sans-serif; color: #172033; background: #f3f6fb; }
body { margin: 0; padding: 2rem 1rem; }

main { margin: auto; max-width: 42rem; background: #fff; padding: 2rem; border-radius: 1rem; box-shadow: 0 8px 30px #1720331a; }
main.narrow { max-width: 25rem; }
main.medium { max-width: 32rem; }
main.wide { max-width: 68rem; }

main > header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
main > header.top { align-items: flex-start; margin-bottom: 2rem; }
main > header.top h1 { margin: 0; }
main > header a { color: #2563eb; text-decoration: none; }
main > header form { display: inline; }
main > header button { width: auto; margin: 0; padding: 0; border: 0; background: none; font: inherit; cursor: pointer; color: #2563eb; }

label { display: block; font-weight: 600; }
label + input, label + select, label + textarea { margin-top: .35rem; }
.form label { margin-top: 1.2rem; }
.form input, .form select { box-sizing: border-box; width: 100%; margin-top: .35rem; padding: .8rem; border: 1px solid #cbd5e1; border-radius: .55rem; font: inherit; }
.form button { width: 100%; margin-top: 1.5rem; padding: .8rem; border: 1px solid #2563eb; border-radius: .55rem; font: inherit; background: #2563eb; color: #fff; cursor: pointer; }

.error { color: #b91c1c; }
.info, .hint { color: #53627a; }
.eyebrow { margin: 0 0 .35rem; color: #2563eb; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.hero { font-size: clamp(2rem, 6vw, 3.6rem); margin: 3rem 0 .5rem; }
.subtitle { font-size: 1.2rem; color: #53627a; max-width: 38rem; }
.section-label { margin: 1.5rem 0 .5rem; color: #53627a; font-weight: 700; }
.correct-feedback { color: #15803d; font-weight: 700; }
.wrong-feedback { color: #b91c1c; font-weight: 700; }

.button { display: inline-block; margin-top: .5rem; padding: .8rem 1rem; background: #2563eb; color: #fff; border-radius: .6rem; text-decoration: none; font-weight: 600; }
.button + .button { margin-left: .75rem; }
.button.secondary { background: #fff; color: #2563eb; border: 1px solid #2563eb; }

.stats, .actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; margin-top: 2rem; }
.card, .stat { padding: 1.5rem; background: #fff; border-radius: 1rem; box-shadow: 0 8px 30px #17203314; }
.card h2 { margin-top: 0; }
.stat strong { display: block; font-size: 2rem; color: #2563eb; }
.stat span, .settings { color: #53627a; }

#progress, #result { color: #53627a; }
#question { font-size: 1.65rem; font-weight: 700; margin: 2rem 0 1rem; }
.placeholder { border-radius: .5rem; background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 50%, #eef2f7 75%); background-size: 200% 100%; animation: loading-placeholder 1.1s ease-in-out infinite; }
.placeholder.question { min-height: 2.4rem; }
.placeholder.answer { height: 3.1rem; border-radius: .6rem; }
@keyframes loading-placeholder { to { background-position: -200% 0; } }
#answers { display: grid; gap: .75rem; }
#answers.tall { min-height: 15rem; }
#answers button { font: inherit; padding: .9rem 1rem; border: 1px solid #cbd5e1; border-radius: .6rem; background: #fff; text-align: left; cursor: pointer; }
#answers button:hover:not(:disabled) { border-color: #2563eb; background: #eff6ff; }
#answers button.correct { background: #dcfce7; border-color: #16a34a; }
#answers button.wrong { background: #fee2e2; border-color: #dc2626; }
#next, #restart { display: none; margin-top: 1.25rem; padding: .9rem 1rem; border: 1px solid #2563eb; border-radius: .6rem; background: #2563eb; color: #fff; font: inherit; cursor: pointer; }
#message { display: none; }
#rating-state { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: 1.25rem; }
#rating-state div { padding: .65rem .35rem; border: 2px solid transparent; border-radius: .6rem; text-align: center; color: #53627a; opacity: .45; transition: opacity .15s, border-color .15s, transform .15s; }
#rating-state div.active { border-color: #172033; color: #172033; opacity: 1; transform: translateY(-2px); font-weight: 700; }
#rating-state .again { background: #fee2e2; }
#rating-state .hard { background: #ffedd5; }
#rating-state .good { background: #dcfce7; }
#rating-state .easy { background: #dbeafe; }

.tile-row { display: flex; min-height: 4rem; gap: .65rem; flex-wrap: wrap; align-content: flex-start; padding: .7rem; border: 2px dashed #cbd5e1; border-radius: .75rem; }
.tile { min-width: 3.5rem; min-height: 3.5rem; padding: .8rem 1rem; border: 1px solid #93c5fd; border-radius: .6rem; background: #eff6ff; color: #172033; font: inherit; font-size: 1.4rem; font-weight: 700; cursor: pointer; }
.tile:hover { border-color: #2563eb; background: #dbeafe; }

#word { display: flex; gap: .35rem; flex-wrap: wrap; min-height: 3.8rem; align-items: center; }
.letter { display: grid; width: 2.6rem; height: 3.1rem; place-items: center; border-bottom: 3px solid #d4d6d7; font-size: 1.75rem; font-weight: 700; }
.gap-letter { border: 2px dashed #93c5fd; border-bottom: 3px solid #2563eb; border-radius: .45rem; background: #eff6ff; color: #172033; cursor: pointer; }
.gap-letter:disabled { cursor: default; }
.gap-letter.filled { border-style: solid; background: #dbeafe; }

#vocabulary-set { width: 100%; max-width: 30rem; padding: .8rem; border: 1px solid #cbd5e1; border-radius: .55rem; font: inherit; }
.table-wrap { margin-top: 2rem; overflow-x: auto; }
#vocabulary-table { width: 100% !important; }
.table-wrap th, .table-wrap td { vertical-align: top; }

.article-title { font-size: 1.4rem; margin: 1.5rem 0 .5rem; }
.explore-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(16rem, 2fr); gap: 2rem; margin-top: 1.5rem; align-items: start; }
#exploration-canvas { display: block; width: 100%; height: 20rem; max-height: 70vh; cursor: default; touch-action: manipulation; }
.text-column { overflow-y: auto; max-height: calc(70vh + 6rem); padding-right: .5rem; }
#new-article, #check-translation { font: inherit; padding: .7rem 1rem; border: 1px solid #2563eb; border-radius: .55rem; background: #2563eb; color: #fff; cursor: pointer; }
#new-article:disabled, #check-translation:disabled { opacity: .6; cursor: wait; }
#new-article { margin-top: 1rem; background: #fff; color: #2563eb; }
#check-translation { width: 100%; margin-top: .75rem; }
#translation-input { box-sizing: border-box; width: 100%; padding: .8rem; border: 1px solid #cbd5e1; border-radius: .55rem; font: inherit; resize: vertical; }
#llm-hints ul { margin: .5rem 0 0; padding-left: 1.25rem; }
#llm-hints li + li { margin-top: .35rem; }

.flashcards [hidden] { display: none !important; }
.deck-header { display: flex; align-items: center; gap: 1rem; }
.deck-close { color: #94a3b8; font-size: 2rem; line-height: 1; text-decoration: none; }
.deck-progress { flex: 1; height: 1rem; border-radius: 1rem; background: #e5e7eb; overflow: hidden; }
#deck-progress-bar { width: 0; height: 100%; border-radius: inherit; background: #58cc02; transition: width .3s; }
#deck-count { color: #53627a; font-weight: 700; font-variant-numeric: tabular-nums; }
#deck-prompt { margin: 1.5rem 0 0; font-size: 1.35rem; font-weight: 700; }
.deck { position: relative; width: min(100%, 16rem); aspect-ratio: 1; margin: 3.5rem auto 1rem; }
.deck-layer, #flashcard { position: absolute; inset: 0; box-sizing: border-box; border: 2px solid #e5e7eb; border-radius: 1.5rem; background: #fff; }
.deck-layer { transform: translateY(calc(var(--depth) * -.5rem)) scale(calc(1 - var(--depth) * .04)); transform-origin: top center; }
#flashcard { display: grid; place-items: center; padding: 1.25rem; border-bottom-width: 4px; text-align: center; font-size: 1.9rem; font-weight: 700; overflow-wrap: anywhere; transition: background .2s, border-color .2s, color .2s; }
#flashcard-text.long { font-size: 1.2rem; }
#flashcard.loading { background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 50%, #eef2f7 75%); background-size: 200% 100%; animation: loading-placeholder 1.1s ease-in-out infinite; }
#flashcard.entering { animation: card-enter .2s ease-out; }
#flashcard.correct { background: #dcfce7; border-color: #16a34a; color: #14532d; }
#flashcard.wrong { background: #fee2e2; border-color: #dc2626; color: #7f1d1d; }
#flashcard.result { cursor: pointer; }
#flashcard.leaving { animation: card-leave .25s ease-in forwards; }
@keyframes card-enter { from { opacity: 0; transform: scale(.95); } }
@keyframes card-leave { to { opacity: 0; transform: translateX(-120%) rotate(-8deg); } }
#heard { min-height: 1.4rem; margin: .5rem 0 0; color: #53627a; text-align: center; }
#solution { min-height: 2rem; margin: .25rem 0 1rem; color: #b91c1c; font-size: 1.3rem; font-weight: 700; text-align: center; }
#start-deck { display: block; margin: 1rem auto 0; border: 0; font: inherit; font-weight: 600; cursor: pointer; }
#mic { display: flex; align-items: center; justify-content: center; gap: .35rem; width: min(100%, 12rem); height: 5rem; margin: 0 auto; border: 0; border-bottom: 5px solid #1899d6; border-radius: 1.25rem; background: #1cb0f6; cursor: pointer; }
#mic span { width: .45rem; height: calc(var(--bar, .5) * 2.6rem); border-radius: 1rem; background: #fff; transition: height .08s; }
#mic.listening { animation: mic-pulse 1.2s ease-in-out infinite; }
#mic.busy span { animation: mic-busy .9s ease-in-out infinite alternate; }
#mic.busy span:nth-child(even) { animation-delay: .3s; }
#mic:disabled { cursor: default; }
#mic:disabled:not(.busy) { background: #cbd5e1; border-bottom-color: #94a3b8; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 .6rem #1cb0f633; } }
@keyframes mic-busy { to { opacity: .35; } }
#deck-status { min-height: 1.4rem; text-align: center; }
#skip { display: block; margin: 1rem auto 0; border: 0; background: none; color: #94a3b8; font: inherit; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
#skip:disabled { opacity: .5; cursor: default; }

@media (max-width: 52rem) {
  .explore-layout { grid-template-columns: minmax(0, 1fr); }
}
