:root {
  color-scheme: dark;
  --bg: #070b16;
  --surface: #11182a;
  --surface-2: #18213a;
  --text: #f7f8fc;
  --muted: #98a3bd;
  --red: #ff405d;
  --gold: #ffc145;
  --blue: #5a8cff;
  --green: #41d992;
  --purple: #a277ff;
  --border: rgba(255,255,255,.09);
  --shadow: 0 18px 60px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgba(255,64,93,.16), transparent 34rem),
    radial-gradient(circle at 100% 12%, rgba(255,193,69,.12), transparent 30rem),
    var(--bg);
}
.hidden { display: none !important; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.legal-page { background: var(--bg); }
.legal-shell { width: min(760px, 100%); margin: 0 auto; padding: max(26px, env(safe-area-inset-top)) 20px 42px; }
.legal-brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 28px; color: white; font-size: 20px; font-weight: 900; text-decoration: none; }
.legal-brand img { width: 42px; height: 42px; border-radius: 12px; box-shadow: 0 6px 18px rgba(255,64,93,.2); }
.legal-brand span span { color: var(--gold); }
.legal-card { padding: clamp(24px, 6vw, 44px); border: 1px solid var(--border); border-radius: 22px; background: rgba(17,24,42,.94); box-shadow: var(--shadow); }
.legal-card h1 { letter-spacing: 0; }
.legal-card h2 { margin-top: 30px; font-size: 19px; letter-spacing: 0; }
.legal-card p, .legal-card li { color: #d6dcec; }
.legal-card ul { display: grid; gap: 9px; padding-left: 22px; }
.legal-card a { color: var(--gold); font-weight: 800; }
.legal-date { margin: 10px 0 0; color: var(--muted) !important; }
.legal-footer { display: flex; justify-content: space-between; gap: 16px; padding: 22px 4px 0; color: var(--muted); font-size: 14px; }
.legal-footer a { color: var(--gold); font-weight: 800; text-decoration: none; }

.app-shell { width: min(100%, 920px); margin: auto; min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 20px 12px;
  background: rgba(7,11,22,.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
}
.brand { display: flex; align-items: center; gap: 10px; color: white; text-decoration: none; font-weight: 900; font-size: 20px; }
.brand img { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 6px 18px rgba(255,64,93,.2); }
.brand span span { color: var(--gold); }
.profile-button { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255,193,69,.55); background: linear-gradient(145deg, #24304d, #11182a); font-weight: 900; cursor: pointer; }

.auth-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 480px);
  align-items: center;
  gap: clamp(28px, 8vw, 100px);
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: auto;
  padding: 38px;
}
.auth-visual { padding: 30px; }
.auth-visual img { width: 82px; height: 82px; margin-bottom: 30px; border-radius: 24px; box-shadow: 0 18px 50px rgba(255,64,93,.25); }
.auth-visual h1 { max-width: 650px; font-size: clamp(46px, 7vw, 86px); }
.auth-visual > p:last-child { max-width: 580px; color: #b6c0d7; font-size: 18px; }
.auth-card {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(17,24,42,.93);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 15px; background: rgba(255,255,255,.05); }
.auth-tabs button { min-height: 42px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; cursor: pointer; font-weight: 850; }
.auth-tabs button.active { color: white; background: var(--surface-2); box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.auth-heading { margin: 26px 0 20px; }
.auth-heading p { margin: 6px 0 0; color: var(--muted); }
.auth-card label { display: grid; gap: 8px; margin-top: 15px; color: #d6dcec; font-size: 13px; font-weight: 800; }
.auth-card input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: 0;
  color: white;
  background: #0c1221;
}
.auth-card input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,193,69,.11); }
.auth-error { min-height: 21px; margin: 12px 0 0; color: #ff8295; font-size: 13px; }
.auth-submit { width: 100%; margin-top: 8px; }
.auth-submit:disabled { opacity: .65; cursor: wait; }
.auth-submit.secondary-button { border: 1px solid rgba(255,255,255,.12); color: white; background: rgba(255,255,255,.06); }
.auth-note { margin: 14px 0 0; color: var(--muted); text-align: center; font-size: 12px; }
.auth-setup { padding-top: 22px; }
.auth-setup p { color: var(--muted); }
.profile-menu {
  position: fixed;
  z-index: 60;
  top: 70px;
  right: max(18px, calc((100vw - 900px) / 2));
  display: grid;
  min-width: 210px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #151d31;
  box-shadow: var(--shadow);
}
.profile-menu span { margin: 4px 0 14px; color: var(--muted); font-size: 12px; }
.profile-menu button { padding: 11px; border: 1px solid rgba(255,64,93,.25); border-radius: 12px; color: #ff8295; background: rgba(255,64,93,.08); cursor: pointer; }

main { padding: 18px 18px 112px; }
.page-enter { animation: enter .28s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
.eyebrow { margin: 0 0 5px; color: var(--gold); font-size: 12px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(31px, 8vw, 46px); line-height: 1.04; letter-spacing: -.04em; }
h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 30px 2px 14px; }
.section-head a { color: var(--gold); text-decoration: none; font-weight: 800; font-size: 14px; }

.hero {
  overflow: hidden;
  position: relative;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(255,64,93,.14), rgba(17,24,42,.94) 42%, rgba(90,140,255,.12));
  box-shadow: var(--shadow);
}
.hero::after { content: ""; position: absolute; width: 180px; height: 180px; right: -70px; top: -80px; border-radius: 50%; background: var(--gold); filter: blur(80px); opacity: .18; }
.hero-top { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; }
.hero p { max-width: 510px; margin: 10px 0 0; color: #c8d0e3; }
.progress-ring {
  --progress: 0deg;
  display: grid;
  place-items: center;
  width: 104px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--gold) var(--progress), rgba(255,255,255,.09) 0);
  box-shadow: 0 0 28px rgba(255,193,69,.2);
}
.progress-ring::before { content: ""; grid-area: 1/1; width: 80px; aspect-ratio: 1; border-radius: 50%; background: #11182a; }
.ring-label { grid-area: 1/1; position: relative; text-align: center; font-size: 11px; color: var(--muted); }
.ring-label strong { display: block; color: white; font-size: 24px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.primary-button, .secondary-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border: 0; border-radius: 15px;
  font-weight: 900; text-decoration: none; cursor: pointer;
}
.primary-button { color: #231b04; background: linear-gradient(135deg, var(--gold), #ffda6a); box-shadow: 0 10px 24px rgba(255,193,69,.22); }
.secondary-button { color: white; border: 1px solid var(--border); background: rgba(255,255,255,.06); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat-card { padding: 16px 12px; border: 1px solid var(--border); border-radius: 20px; background: rgba(17,24,42,.88); }
.stat-card span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.stat-card strong { font-size: 22px; }
.stat-card:nth-child(1) strong { color: var(--gold); }
.stat-card:nth-child(2) strong { color: var(--red); }
.stat-card:nth-child(3) strong { color: var(--green); }

.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.content-card {
  position: relative; overflow: hidden; min-height: 150px; padding: 18px;
  border: 1px solid var(--border); border-radius: 23px; background: var(--surface);
  cursor: pointer; transition: transform .18s ease, border-color .18s ease;
}
.content-card:hover { transform: translateY(-2px); border-color: rgba(255,193,69,.35); }
.content-card .icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 22px; border-radius: 13px; background: rgba(255,193,69,.13); color: var(--gold); font-weight: 900; }
.content-card h3 { margin: 0 0 5px; font-size: 17px; }
.content-card p { margin: 0; color: var(--muted); font-size: 13px; }

.lesson-list, .dialog-list { display: grid; gap: 12px; }
.lesson-card, .dialog-card, .word-card {
  border: 1px solid var(--border); border-radius: 22px; background: rgba(17,24,42,.88);
}
.lesson-card { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 16px; cursor: pointer; }
.lesson-number { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; color: #241b03; background: linear-gradient(145deg, var(--gold), #ffdc76); font-weight: 950; }
.lesson-card.completed .lesson-number { color: #041a10; background: var(--green); }
.lesson-card h3, .dialog-card h3 { margin: 0 0 4px; font-size: 16px; }
.lesson-card p, .dialog-card p { margin: 0; color: var(--muted); font-size: 13px; }
.lesson-meta { text-align: right; color: var(--muted); font-size: 12px; }

.search-wrap { position: sticky; top: 68px; z-index: 10; padding: 8px 0 14px; background: linear-gradient(var(--bg) 75%, transparent); }
.search { width: 100%; min-height: 50px; padding: 0 16px; color: white; border: 1px solid var(--border); border-radius: 16px; outline: 0; background: var(--surface); }
.search:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,193,69,.12); }
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding: 1px 0 10px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; padding: 8px 13px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: transparent; cursor: pointer; }
.chip.active { border-color: var(--gold); color: #211900; background: var(--gold); font-weight: 800; }
.word-list { display: grid; gap: 10px; }
.word-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 16px; }
.word-main { display: flex; align-items: baseline; gap: 9px; }
.word-main strong { font-size: 20px; }
.word-main span { color: var(--muted); }
.word-example { margin: 10px 0 0; color: #bbc5da; font-size: 13px; }
.audio-button { width: 44px; height: 44px; border: 1px solid rgba(90,140,255,.3); border-radius: 14px; color: #a9c1ff; background: rgba(90,140,255,.1); cursor: pointer; }
.audio-button.playing { color: #211900; background: var(--gold); border-color: var(--gold); }

.dialog-card { padding: 18px; cursor: pointer; }
.dialog-card header { display: flex; justify-content: space-between; gap: 16px; }
.level { padding: 5px 9px; align-self: start; border-radius: 999px; color: var(--green); background: rgba(65,217,146,.1); font-size: 11px; font-weight: 900; }
.dialog-lines { display: grid; gap: 10px; margin-top: 16px; }
.bubble { max-width: 88%; padding: 12px 14px; border-radius: 17px 17px 17px 5px; background: var(--surface-2); }
.bubble:nth-child(even) { justify-self: end; border-radius: 17px 17px 5px; background: rgba(90,140,255,.16); }
.bubble strong { display: block; margin-bottom: 4px; color: var(--gold); font-size: 11px; }
.bubble p { margin: 0; color: white; font-size: 14px; }
.bubble small { display: block; margin-top: 5px; color: var(--muted); }

.lesson-view .back-button { margin-bottom: 18px; }
.back-button { padding: 8px 0; border: 0; color: var(--gold); background: none; font-weight: 800; cursor: pointer; }
.lesson-content { display: grid; gap: 12px; margin-top: 22px; }
.lesson-block { padding: 18px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); }
.lesson-block h3 { margin: 0 0 8px; }
.example-block { display: grid; grid-template-columns: 1fr auto; gap: 12px; background: linear-gradient(140deg, rgba(90,140,255,.14), var(--surface)); }
.example-block .latin { margin: 0 0 6px; font-size: 20px; font-weight: 900; }
.example-block .turkish { margin: 0; color: var(--muted); }
.table-row { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.table-row:last-child { border: 0; }
.quiz-card { padding: 20px; border: 1px solid rgba(255,193,69,.2); border-radius: 22px; background: linear-gradient(145deg, rgba(255,193,69,.09), var(--surface)); }
.quiz-options { display: grid; gap: 9px; margin-top: 15px; }
.quiz-option { padding: 13px; text-align: left; border: 1px solid var(--border); border-radius: 14px; background: rgba(255,255,255,.03); cursor: pointer; }
.quiz-option.correct { border-color: var(--green); background: rgba(65,217,146,.16); }
.quiz-option.wrong { border-color: var(--red); background: rgba(255,64,93,.13); }

.tabbar {
  position: fixed; z-index: 30; left: 50%; bottom: 0; transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(4, 1fr);
  width: min(100%, 920px); padding: 9px 8px max(9px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: rgba(10,15,28,.92); backdrop-filter: blur(22px);
}
.tabbar a { display: grid; justify-items: center; gap: 4px; padding: 5px; color: #7f8ba5; text-decoration: none; font-size: 10px; font-weight: 750; }
.tabbar a.active { color: var(--gold); }
.tab-icon { display: grid; place-items: center; width: 28px; height: 24px; font-size: 20px; font-weight: 900; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 100px; transform: translate(-50%, 20px); padding: 12px 17px; border-radius: 14px; color: white; background: #26324d; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading-state, .empty-state { display: grid; place-items: center; min-height: 55vh; color: var(--muted); text-align: center; }
.loader { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.1); border-top-color: var(--gold); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 720px) {
  main { padding: 28px 30px 120px; }
  .topbar { padding-inline: 30px; }
  .hero { padding: 34px; }
  .card-grid { grid-template-columns: repeat(4, 1fr); }
  .word-list { grid-template-columns: repeat(2, 1fr); }
  .dialog-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 430px) {
  .hero-top { grid-template-columns: 1fr; }
  .progress-ring { position: absolute; right: 18px; top: 18px; width: 78px; }
  .progress-ring::before { width: 59px; }
  .ring-label strong { font-size: 18px; }
  .hero h1 { max-width: 240px; }
  .stat-grid { gap: 7px; }
  .stat-card strong { font-size: 19px; }
}

@media (max-width: 760px) {
  .auth-screen { display: block; padding: max(24px, env(safe-area-inset-top)) 18px 28px; }
  .auth-visual { padding: 18px 8px 28px; }
  .auth-visual img { width: 62px; height: 62px; margin-bottom: 20px; border-radius: 18px; }
  .auth-visual h1 { font-size: 39px; }
  .auth-visual > p:last-child { font-size: 15px; }
  .auth-card { padding: 21px; border-radius: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
