/* Türkçe — чёрный, зелёный, фиолетовый. Строгий минимализм. */
:root {
  --bg: #0a0a0b;
  --surface: #131315;
  --surface-2: #1b1b1e;
  --line: #2a2a2f;
  --text: #f4f4f5;
  --muted: #8b8b94;
  --green: #2ee59d;
  --green-dim: rgba(46, 229, 157, 0.14);
  --purple: #a07cff;
  --purple-dim: rgba(160, 124, 255, 0.16);
  --radius: 14px;
  --font: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; min-height: 100dvh; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- Каркас ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px 80px; }
header.top {
  position: sticky; top: 0; z-index: 10; background: rgba(10, 10, 11, 0.92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.top-in { max-width: 760px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 22px; letter-spacing: -0.03em; text-decoration: none; display: flex; align-items: baseline; gap: 10px; }
.brand small { font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: 0; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; transform: translateY(-2px); }
nav.tabs { display: flex; gap: 4px; margin-left: auto; }
nav.tabs button {
  background: none; border: 0; padding: 8px 12px; border-radius: 999px; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 14px;
}
nav.tabs button.on { color: var(--bg); background: var(--text); }
.statline { width: 100%; display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.statline b { color: var(--text); font-weight: 600; }
.statline .g { color: var(--green); }
.statline .p { color: var(--purple); }

h1 { font-size: clamp(34px, 7vw, 56px); letter-spacing: -0.04em; line-height: 1; margin: 36px 0 8px; font-weight: 800; }
h2 { font-size: 20px; letter-spacing: -0.02em; margin: 28px 0 12px; font-weight: 700; }
.lead { color: var(--muted); margin: 0 0 24px; line-height: 1.5; }

/* ---------- Элементы управления ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); padding: 11px 18px; border-radius: 999px; cursor: pointer;
  font-weight: 600; font-size: 15px; transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap;
}
.btn:hover { border-color: #3a3a40; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.green { background: var(--green); color: #04150d; border-color: var(--green); }
.btn.purple { background: var(--purple); color: #120a24; border-color: var(--purple); }
.btn.ghost-green { color: var(--green); border-color: rgba(46, 229, 157, .45); background: transparent; }
.btn.ghost-purple { color: var(--purple); border-color: rgba(160, 124, 255, .5); background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.danger { color: #ff6b6b; border-color: rgba(255, 107, 107, .4); background: transparent; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

label.f { display: block; font-size: 12px; color: var(--muted); margin: 16px 0 6px; letter-spacing: .02em; text-transform: uppercase; }
input.in, textarea.in, select.in {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 16px; outline: none;
}
input.in:focus, textarea.in:focus, select.in:focus { border-color: var(--purple); }
textarea.in { min-height: 140px; resize: vertical; line-height: 1.5; }
select.in.inline { width: auto; padding: 8px 12px; font-size: 14px; border-radius: 999px; }
input.big { font-size: 22px; font-weight: 600; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { background: none; border: 0; padding: 8px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- Теги ---------- */
.tagbox { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.tagbox:focus-within { border-color: var(--purple); }
.tagbox input { border: 0; background: none; outline: none; flex: 1; min-width: 120px; padding: 4px 6px; font-size: 15px; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--purple-dim); color: var(--purple); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.tag button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; font-size: 14px; line-height: 1; opacity: .7; }
.tag.static { background: transparent; box-shadow: inset 0 0 0 1px rgba(160, 124, 255, .35); }
.tag.add { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; }

/* ---------- Учить: карточка ---------- */
.study-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 28px 0 18px; }
.progress { height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 22px; }
.progress i { display: block; height: 100%; width: 0; background: var(--green); transition: width .25s; }
.stage { position: relative; height: min(62vh, 460px); min-height: 320px; perspective: 1400px; touch-action: none; user-select: none; -webkit-user-select: none; }
.card {
  position: absolute; inset: 0; border-radius: 24px; cursor: grab; transform-style: preserve-3d;
  transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}
.card.dragging { transition: none; cursor: grabbing; }
.card .face {
  position: absolute; inset: 0; border-radius: 24px; background: var(--surface); border: 1px solid var(--line);
  backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden;
}
.card .back { transform: rotateY(180deg); }
.card.flipped .inner { transform: rotateY(180deg); }
.card .inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
.face .top { position: absolute; top: 24px; left: 26px; right: 26px; z-index: 1; }
.face .lang { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
/* Центр карточки: занимает всю площадь, содержимое — ровно посередине; если не помещается — прокрутка без обрезки сверху */
.face .center { position: absolute; inset: 64px 26px 64px; overflow-y: auto; display: flex; flex-direction: column; }
.face .content { margin: auto 0; text-align: center; width: 100%; }
.face .word { font-size: clamp(30px, 7vw, 52px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.08; overflow-wrap: anywhere; }
.face .sub { font-size: 18px; color: var(--muted); margin-top: 10px; }
.face .hint { position: absolute; left: 0; right: 0; bottom: 22px; text-align: center; color: var(--muted); font-size: 13px; }
.face .exs .ex { font-size: 16px; }
.face .exs .ex:first-child { border-top: 0; }
.back .note { color: var(--muted); font-size: 15px; line-height: 1.5; margin: 16px auto 0; max-width: 520px; }
.exs { margin: 22px auto 0; max-width: 520px; border-top: 1px solid var(--line); }
.face .word.long { font-size: clamp(24px, 5vw, 38px); }
.ex { border-top: 1px solid var(--line); padding: 10px 0; font-size: 15px; line-height: 1.45; }
.ex b { font-weight: 600; display: block; }
.ex span { color: var(--muted); display: block; }
.examples-list .ex, .ai .ex { text-align: left; }
.boxdots { display: flex; gap: 5px; justify-content: center; }
.boxdots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.boxdots i.on { background: var(--green); }
.card .tint { position: absolute; inset: 0; border-radius: 24px; pointer-events: none; opacity: 0; transition: opacity .1s; z-index: 3; }
.card .tint.yes { background: var(--green-dim); box-shadow: inset 0 0 0 2px var(--green); }
.card .tint.no { background: var(--purple-dim); box-shadow: inset 0 0 0 2px var(--purple); }
.card .stamp { position: absolute; top: 22px; font-weight: 800; font-size: 15px; letter-spacing: .1em; text-transform: uppercase; opacity: 0; z-index: 4; padding: 6px 12px; border-radius: 8px; }
.card .stamp.yes { right: 22px; color: var(--green); box-shadow: inset 0 0 0 2px var(--green); }
.card .stamp.no { left: 22px; color: var(--purple); box-shadow: inset 0 0 0 2px var(--purple); }
.answer { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; margin-top: 18px; }
.answer .btn { padding: 15px 10px; }
.keys { text-align: center; color: var(--muted); font-size: 12px; margin-top: 12px; }
.empty { text-align: center; padding: 70px 10px; color: var(--muted); line-height: 1.6; }
.empty b { display: block; color: var(--text); font-size: 26px; letter-spacing: -0.02em; margin-bottom: 8px; }
.summary { display: flex; gap: 14px; justify-content: center; margin: 18px 0 26px; }
.summary div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 22px; text-align: center; min-width: 120px; }
.summary b { display: block; font-size: 34px; letter-spacing: -0.03em; }

/* ---------- ИИ-подсказка ---------- */
.ai { margin-top: 18px; border: 1px solid rgba(160, 124, 255, .35); border-radius: var(--radius); padding: 16px; background: linear-gradient(180deg, rgba(160, 124, 255, .07), transparent); }
.ai .head { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--purple); margin-bottom: 10px; font-weight: 700; }
.ai .line { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 6px 0; }
.ai .line .k { color: var(--muted); font-size: 13px; min-width: 92px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--green); width: 18px; height: 18px; flex: none; }
.check span { color: var(--muted); }
.examples-list .ex { display: flex; gap: 10px; align-items: flex-start; }
.examples-list .ex div { flex: 1; }

/* ---------- Таблица пакетного добавления и словарь ---------- */
.batch { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.batch .bhead { display: flex; gap: 10px; align-items: center; padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; font-size: 14px; }
.brow { display: grid; grid-template-columns: 28px 1fr 30px; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.brow:last-child { border-bottom: 0; }
.brow input[type=text] { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 8px; width: 100%; font-size: 15px; outline: none; }
.brow input[type=text]:focus { border-color: var(--purple); background: var(--surface); }
.brow input[type=checkbox] { accent-color: var(--green); width: 18px; height: 18px; }
.brow .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.brow .dup { font-size: 11px; color: var(--purple); grid-column: 2 / 3; margin: -6px 0 0 8px; }
.brow.off { opacity: .45; }
.icon-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 12px; }
.filters .in.search { flex: 1 1 220px; width: auto; padding: 10px 14px; font-size: 15px; border-radius: 999px; }
.count { color: var(--muted); font-size: 13px; margin: 6px 0 10px; }
.list .item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list .item:hover { background: var(--surface); }
.list .item .w { font-weight: 700; font-size: 17px; }
.list .item .t { color: var(--muted); }
.list .item .tags { grid-column: 1 / 3; display: flex; gap: 6px; flex-wrap: wrap; }
.list .item .boxdots { justify-content: flex-end; align-self: center; }
.mastered { color: var(--green); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.drop { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 34px 18px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--green); background: var(--green-dim); color: var(--text); }
.drop b { color: var(--text); display: block; font-size: 17px; margin-bottom: 4px; }
.photo-preview { max-width: 100%; max-height: 320px; border-radius: 12px; display: block; margin: 14px auto 0; }
.help { color: var(--muted); font-size: 13px; line-height: 1.55; margin-top: 8px; }
.help code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; color: var(--text); }
.map { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }

/* ---------- Модальное окно ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .7); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); border: 1px solid var(--line); border-radius: 22px 22px 0 0; width: 100%; max-width: 760px; max-height: 92vh; overflow-y: auto; padding: 22px 20px calc(30px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 22px; } }

/* ---------- Вход, уведомления, загрузка ---------- */
.login { max-width: 420px; margin: 16vh auto 0; padding: 0 20px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 100; max-width: calc(100% - 32px); text-align: center; }
.toast.err { background: #ff6b6b; color: #1a0505; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .stage { height: min(52vh, 440px); min-height: 300px; }
  h1 { margin-top: 26px; }
  .study-bar { margin: 18px 0 14px; }
  nav.tabs { margin-left: 0; width: 100%; }
  nav.tabs button { flex: 1; }
  .brow .pair { grid-template-columns: 1fr; gap: 0; }
  .brow .pair input.ru { color: var(--muted); }
  .answer .btn { font-size: 14px; }
}
