/* ==========================================================
   VOCAB PRO WEB · Editorial Calm
   Шрифты: Newsreader (серифный, для чтения), DM Sans (UI)
   Палитра: тёплые кремовые и угольные тона, индиго-акцент
   ========================================================== */

:root {
  /* ===== ПАЛИТРА — СВЕТЛАЯ ТЕМА ===== */
  --bg:           #FAF7F2;   /* тёплый кремовый */
  --surface:      #FFFFFF;
  --surface-2:   #F4F1EB;   /* слегка темнее, для секций */
  --border:       #E7E2D9;
  --border-soft:  #EFEBE3;
  --text:         #1C1917;   /* тёплый чёрный */
  --text-soft:    #44403C;
  --muted:        #78716C;
  --accent:       #4F46E5;   /* индиго — фирменный из десктоп-версии */
  --accent-hover: #4338CA;
  --accent-soft:  rgba(79, 70, 229, 0.08);
  --de:           #1E40AF;   /* deeper blue для немецкого */
  --ru:           #15803D;   /* deeper green для русского */
  --hard:         #B91C1C;
  --learning:     #B45309;
  --known:        #15803D;
  --danger:       #DC2626;
  --warning:      #D97706;

  /* ===== ТИПОГРАФИКА ===== */
  --font-ui:    "DM Sans", system-ui, -apple-system, sans-serif;
  --font-read:  "Newsreader", "Georgia", "Times New Roman", serif;

  /* ===== ТЕНИ / РАДИУСЫ ===== */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --shadow-sm:  0 1px 2px rgba(28, 25, 23, 0.04), 0 1px 0 rgba(28, 25, 23, 0.02);
  --shadow:     0 4px 12px rgba(28, 25, 23, 0.06), 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-lg:  0 8px 28px rgba(28, 25, 23, 0.08);

  /* ===== ОТСТУПЫ ===== */
  --pad:        16px;
  --pad-sm:     12px;
  --pad-lg:     20px;
}

[data-theme="dark"] {
  --bg:           #1B1918;
  --surface:      #252220;
  --surface-2:    #2E2A28;
  --border:       #3A3633;
  --border-soft:  #2F2C29;
  --text:         #F5F0E6;
  --text-soft:    #D6CFC4;
  --muted:        #9A938A;
  --accent:       #818CF8;
  --accent-hover: #A5B4FC;
  --accent-soft:  rgba(129, 140, 248, 0.14);
  --de:           #60A5FA;
  --ru:           #4ADE80;
  --hard:         #F87171;
  --learning:     #FBBF24;
  --known:        #4ADE80;
}

/* ===== БАЗА ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* safe area для айфонов с челкой / индикатором */
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
  min-height: 100vh;
  /* отключим зум двойным тапом */
  touch-action: manipulation;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 16px; }
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea { resize: vertical; font-family: var(--font-read); line-height: 1.6; }
select { -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2378716C' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px;
}

/* ===== ШАПКА ===== */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px var(--pad);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 24px; }
.brand h1 {
  font-family: var(--font-read);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.icon-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 18px;
  color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }

/* ===== ТАБ-БАР ===== */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 20;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
}
.tab-link {
  flex: 1; max-width: 120px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px;
  background: transparent; border: none;
  color: var(--muted);
  font-size: 11px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.tab-link.active { color: var(--accent); }
.tab-link.active .tab-icon { transform: scale(1.05); }
.tab-icon {
  font-size: 22px;
  transition: transform 0.2s;
}
.tab-label { font-weight: 500; }

/* ===== ГЛАВНАЯ ОБЛАСТЬ ===== */
.app-main { padding: var(--pad); }
.tab { display: flex; flex-direction: column; gap: var(--pad); }
.tab[hidden] { display: none; }

/* ==========================================================
   ВКЛАДКА: ЧТЕНИЕ
   ========================================================== */

.translate-panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.tr-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.tr-title {
  font-size: 13px; color: var(--muted);
  font-weight: 500; letter-spacing: 0.02em;
}
.auto-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.auto-toggle input { width: auto; }

.tr-original {
  font-family: var(--font-read);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
  word-break: break-word;
}
.tr-translated {
  font-family: var(--font-read);
  font-size: 17px;
  color: var(--text);
  word-break: break-word;
}
.tr-translated.placeholder {
  color: var(--muted);
  font-style: italic;
  font-size: 15px;
}
.tr-translated.error { color: var(--danger); }
.tr-explanation {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.tr-explanation strong { color: var(--text); }

.tr-actions {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.tr-provider {
  font-size: 11px; color: var(--muted);
  margin-left: 2px;
}

/* ===== Зона чтения ===== */
.reading-zone {
  display: flex; flex-direction: column; gap: 6px;
}
#read-text {
  min-height: 240px;
  font-size: 17px;
}
.reading-meta {
  font-size: 12px; color: var(--muted);
  padding: 0 4px;
}

.reading-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}
.reading-secondary {
  display: flex; gap: 8px;
}

/* ==========================================================
   ВКЛАДКА: ТРЕНИРОВКА
   ========================================================== */

.training-progress {
  display: flex; flex-direction: column; gap: 6px;
}
.progress-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}
.progress-text {
  font-size: 12px; color: var(--muted);
  text-align: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  min-height: 260px;
  text-align: center;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.card-empty { color: var(--muted); }
.card-empty p:first-child { font-family: var(--font-read); font-size: 18px; margin-bottom: 6px; color: var(--text); }
.card-empty .muted { font-size: 14px; }
.card-content { width: 100%; }
.card-german {
  font-family: var(--font-read);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  color: var(--text);
}
.card-transcription {
  font-family: var(--font-read);
  font-size: 16px;
  font-style: italic;
  color: var(--muted);
  margin-bottom: 18px;
}
.card-russian {
  font-family: var(--font-read);
  font-size: 20px;
  color: var(--text);
  margin-bottom: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.card-example {
  font-size: 14px;
  font-style: italic;
  color: var(--text-soft);
  margin-bottom: 12px;
}
.card-tags {
  font-size: 12px;
  color: var(--muted);
}

.training-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.training-mark {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.mark-btn {
  min-height: 52px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.1s, filter 0.15s;
}
.mark-btn:active { transform: scale(0.97); }
.mark-hard     { background: #FEE2E2; color: var(--hard); }
.mark-learning { background: #FEF3C7; color: var(--learning); }
.mark-known    { background: #DCFCE7; color: var(--known); }

[data-theme="dark"] .mark-hard     { background: rgba(248, 113, 113, 0.15); color: #FCA5A5; }
[data-theme="dark"] .mark-learning { background: rgba(251, 191, 36, 0.15); color: #FCD34D; }
[data-theme="dark"] .mark-known    { background: rgba(74, 222, 128, 0.15); color: #86EFAC; }

.training-nav {
  display: flex; justify-content: space-between; gap: 8px;
}

/* ==========================================================
   ВКЛАДКА: НАСТРОЙКИ
   ========================================================== */

.settings-group {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: var(--pad);
  display: flex; flex-direction: column; gap: 12px;
}
.settings-group h2 {
  font-family: var(--font-read);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
  letter-spacing: -0.01em;
}
.muted-group {
  text-align: center;
  background: transparent;
  border: none;
  color: var(--muted);
}

.field {
  display: flex; flex-direction: column; gap: 6px;
}
.field label {
  font-size: 13px; color: var(--muted);
  font-weight: 500;
}
.field-radio { display: flex; flex-direction: column; gap: 6px; }
.field-radio > label {
  font-size: 13px; color: var(--muted);
  font-weight: 500;
}
.radio-row {
  display: flex; flex-wrap: wrap; gap: 14px;
}
.radio-row label {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--text);
  cursor: pointer;
}
.radio-row input { width: auto; }

.input-with-button {
  display: flex; gap: 8px; align-items: stretch;
}
.input-with-button input { flex: 1; }
.input-with-button button { flex-shrink: 0; }

/* ==========================================================
   КНОПКИ
   ========================================================== */

.btn {
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s, transform 0.08s, filter 0.15s;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { background: var(--muted); border-color: var(--muted); box-shadow: none; }

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-soft);
}
.btn-accent:hover { filter: brightness(0.96); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
  min-height: 40px;
  padding: 8px 14px;
  font-size: 14px;
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { filter: brightness(0.93); }

.btn-small {
  min-height: 38px;
  padding: 7px 14px;
  font-size: 13px;
}

/* ==========================================================
   TOAST
   ========================================================== */

.toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  max-width: 90%;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ==========================================================
   АДАПТИВНОСТЬ ПОД БОЛЬШИЕ ЭКРАНЫ
   ========================================================== */

@media (min-width: 720px) {
  .app-header { padding: 16px 28px; }
  .app-main {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px;
  }
  .brand h1 { font-size: 24px; }
  .card-german { font-size: 38px; }
  .tab-bar {
    max-width: 760px;
    margin: 0 auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

@media (min-width: 1024px) {
  .app-main { max-width: 920px; }
}

/* ===== Скрывать чекбокс при отключенной авто-теме ===== */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
