/* Falar — веб-версия. Токены из DESIGN_SPEC.md (Claude design language). */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
::-webkit-scrollbar { width: 0; height: 0; }

:root {
  --page: #C6C3BA; --canvas: #FAF9F5; --surface: #FFFFFF; --sunk: #F0EEE6; --border: #E8E5DC;
  --t1: #1F1E1B; --t2: #6B6862; --t3: #9B978D;
  --accent: #D97757; --accent-press: #C25E3F; --accent-sunk: #F5E6DF;
  --success: #4F7A52; --success-sunk: #E5EFE3; --error: #C2553D; --error-sunk: #F7E4DE;
  --warning: #C99A3F; --lock: #B8B4A8;
  --shadow: 0 4px 16px rgba(31,30,27,.06); --shadow-lg: 0 10px 34px rgba(31,30,27,.12);
}
[data-theme="dark"] {
  --page: #100F0E; --canvas: #1B1A17; --surface: #26241F; --sunk: #1F1E1A; --border: #36332C;
  --t1: #F2F0E9; --t2: #A8A398; --t3: #7E7A70;
  --accent: #E08763; --accent-press: #C9714F; --accent-sunk: #3A2B24;
  --success: #7FA67F; --success-sunk: #28332A; --error: #D77A62; --error-sunk: #3A2622;
  --warning: #D2A85A; --lock: #5C584F;
  --shadow: none; --shadow-lg: none;
}

html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, -apple-system, "Segoe UI", system-ui, sans-serif;
  background: var(--page); color: var(--t1);
  transition: background .3s;
  touch-action: manipulation;          /* без двойного тапа на зум по всему сайту */
}
.serif { font-family: Lora, Georgia, serif; }

#app {
  max-width: 430px; margin: 0 auto; min-height: 100dvh;
  background: var(--canvas); display: flex; flex-direction: column;
  position: relative; transition: background .3s;
}
@media (min-width: 480px) {
  #app { margin: 24px auto; min-height: calc(100dvh - 48px); border-radius: 36px; box-shadow: var(--shadow-lg); overflow: hidden; }
}

.screen { flex: 1; overflow-y: auto; padding: 22px 20px 110px; animation: fadeup .3s ease-out; }
.screen.no-tab { padding-bottom: 30px; }
@keyframes fadeup { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes reveal { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.18); opacity: .7; } }
@keyframes ping { 0% { transform: scale(.7); opacity: .65; } 100% { transform: scale(1.7); opacity: 0; } }
@keyframes toastup { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

h1 { font-family: Lora, Georgia, serif; font-weight: 600; font-size: 28px; line-height: 1.15; margin: 0; }
h2 { font-family: Lora, Georgia, serif; font-weight: 500; font-size: 18px; margin: 0; }
.sub { font-size: 14px; color: var(--t2); margin-top: 4px; line-height: 1.45; }

/* ---------- базовые компоненты ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 18px; box-shadow: var(--shadow);
}
.tappable { cursor: pointer; transition: transform .12s; user-select: none; }
.tappable:active { transform: scale(.985); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; width: 100%; border-radius: 14px; border: none; cursor: pointer;
  font: 600 16px Inter, sans-serif; transition: transform .12s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn, .icon-btn, .tappable, .gword, .seg button, .chip { touch-action: manipulation; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-press); }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--t1); }
.btn-success { background: var(--success); color: #fff; }
.btn-text { background: none; color: var(--accent); }
.btn[disabled] { background: var(--sunk); color: var(--t3); cursor: default; }
.btn[disabled]:active { transform: none; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 99px; background: var(--sunk);
  border: none; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--t1); flex: none;
}
.icon-btn:active { transform: scale(.94); }

.pill {
  height: 26px; padding: 0 11px; border-radius: 99px; font-size: 12.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px;
}
.pill-accent { background: var(--accent-sunk); color: var(--accent); }
.pill-sunk { background: var(--sunk); color: var(--t2); }

.seg { display: flex; background: var(--sunk); border-radius: 12px; padding: 4px; gap: 3px; }
.seg button {
  flex: 1; height: 38px; border: none; border-radius: 10px; background: transparent;
  color: var(--t2); font: 500 13.5px Inter, sans-serif; cursor: pointer; white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }

.progressbar { flex: 1; height: 8px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.progressbar > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease-out; }

.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- таббар ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; padding: 7px 24px calc(10px + env(safe-area-inset-bottom));
}
@media (min-width: 480px) { .tabbar { bottom: 24px; border-radius: 0 0 36px 36px; } }
.tabbar button {
  flex: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 0; color: var(--t3); font: 500 11px Inter, sans-serif;
}
.tabbar button.on { color: var(--accent); }

/* ---------- урок / дорожка ---------- */
.lesson-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.lesson-card.locked { opacity: .6; }
.lesson-card.current { border: 1.5px solid var(--accent); }
.lesson-num {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px; background: var(--sunk); color: var(--t2);
}
.status-dot { width: 26px; height: 26px; border-radius: 99px; display: flex; align-items: center; justify-content: center; flex: none; }
.miniprog { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.miniprog .bar { flex: 1; height: 5px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.miniprog .bar > div { height: 100%; border-radius: 99px; background: var(--accent); }
.miniprog span { font-size: 11px; color: var(--t3); }

/* ---------- теория ---------- */
.note-block {
  background: var(--accent-sunk); border-radius: 14px; padding: 13px 15px;
  font-size: 14.5px; line-height: 1.5; color: var(--t1); margin: 12px 0;
}
.vtable { display: grid; grid-template-columns: 34px 1fr 1fr 1fr; gap: 6px; align-items: stretch; }
.vtable .head { font-size: 11px; color: var(--t3); font-weight: 500; text-align: center; align-self: center; }
.vtable .sign {
  width: 26px; height: 26px; border-radius: 8px; background: var(--sunk); color: var(--t2);
  font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: center; align-self: center;
}
.vcell {
  background: var(--sunk); color: var(--t1); border: none; border-radius: 11px;
  padding: 11px 4px; text-align: center; font: 500 13.5px Inter, sans-serif;
  cursor: pointer; transition: all .18s;
}
.vcell.on { background: var(--accent); color: #fff; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 13px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border);
  font: 500 14px Inter, sans-serif; color: var(--t1); cursor: pointer;
}
.chip:active { transform: scale(.95); }

/* ---------- практика ---------- */
.phrase-ru { font-size: 23px; line-height: 1.35; font-weight: 400; }
.phrase-pt { font-size: 27px; line-height: 1.3; font-weight: 500; letter-spacing: .01em; }
.hint { font-size: 13px; color: var(--t3); }

.tile {
  padding: 10px 14px; border-radius: 11px; font: 500 17px Inter, sans-serif;
  cursor: grab; border: 1px solid var(--border); background: var(--surface); color: var(--t1);
  touch-action: none;                  /* нужно для перетаскивания плиток */
  user-select: none;
}
.tile:active { transform: scale(.95); }
.tile.dragging { opacity: .3; }
.drag-clone {
  position: fixed; z-index: 100; pointer-events: none; cursor: grabbing;
  box-shadow: var(--shadow-lg); margin: 0;
}
.ins-caret {
  width: 3px; align-self: stretch; min-height: 34px; flex: none;
  background: var(--accent); border-radius: 2px; margin: 0 -3px;
}
.tile.in-slot { background: var(--accent-sunk); color: var(--accent); border-color: transparent; }
.tile.ok { background: var(--success-sunk); color: var(--success); border-color: transparent; }
.tile.bad { background: var(--error-sunk); color: var(--error); border-color: transparent; }
.tile.ghost { background: var(--sunk); color: transparent; border-color: transparent; pointer-events: none; }

.histbar { height: 10px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.slotzone {
  min-height: 58px; border-radius: 14px; background: var(--sunk);
  border: 1.5px dashed var(--border); padding: 10px;
  display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
}
.bankzone { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; }

.bigbtn {
  width: 96px; height: 96px; border-radius: 99px; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.bigbtn:active { transform: scale(.95); }

.word-ok { color: var(--success); font: 500 22px Inter, sans-serif; }
.word-bad { color: var(--error); font: 500 22px Inter, sans-serif; }
.word-dim { color: var(--t3); font: 500 22px Inter, sans-serif; text-decoration: line-through; }

.playing { animation: pulse .9s ease-in-out infinite; }

/* ---------- разное ---------- */
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.statgrid .card { padding: 16px; }
.statnum { font-family: Lora, Georgia, serif; font-size: 26px; font-weight: 600; }
.statlabel { font-size: 12.5px; color: var(--t2); margin-top: 2px; }

.settings-group { border-radius: 18px; overflow: hidden; padding: 0; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--border); font-size: 15px;
}
.settings-row:last-child { border-bottom: none; }
.settings-col { padding: 15px 18px; border-bottom: 1px solid var(--border); }
.settings-col:last-child { border-bottom: none; }
.group-label { font-size: 13px; color: var(--t3); font-weight: 500; padding: 0 4px 8px; }

.toggle { width: 46px; height: 28px; border-radius: 99px; border: none; cursor: pointer; position: relative; background: var(--border); flex: none; }
.toggle.on { background: var(--accent); }
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 99px; background: #fff; transition: left .18s;
}
.toggle.on::after { left: 21px; }

select, input[type="range"] { accent-color: var(--accent); }
select {
  background: var(--sunk); border: none; border-radius: 10px; padding: 8px 10px;
  font: 500 13px Inter, sans-serif; color: var(--t1); max-width: 190px;
}

.toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%);
  background: var(--t1); color: var(--canvas); padding: 11px 18px; border-radius: 99px;
  font-size: 14px; z-index: 99; animation: toastup .25s ease-out; max-width: 86vw; text-align: center;
}

.overlay {
  position: fixed; inset: 0; background: rgba(20,18,15,.45); z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 430px; background: var(--surface);
  border-radius: 28px 28px 0 0; padding: 12px 24px calc(34px + env(safe-area-inset-bottom));
  animation: reveal .3s ease-out;
}
.sheet-handle { width: 40px; height: 5px; border-radius: 99px; background: var(--border); margin: 0 auto 20px; }

.gword { cursor: pointer; border-bottom: 1px dashed var(--t3); padding-bottom: 1px; }
.gword:active { color: var(--accent); border-bottom-color: var(--accent); }
.gloss-pop {
  position: fixed; z-index: 95; background: var(--t1); color: var(--canvas);
  padding: 7px 8px 7px 13px; border-radius: 12px; font: 600 17px Inter, sans-serif;
  display: flex; align-items: center; gap: 6px; box-shadow: var(--shadow-lg); max-width: 84vw;
}
.gloss-pop .gloss-spk {
  background: none; border: none; color: var(--canvas); cursor: pointer;
  padding: 4px; display: flex; opacity: .75; touch-action: manipulation;
}

.ring-wrap { position: relative; display: inline-block; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
