:root {
  --bg: #faf7f2;
  --bg-soft: #f1ece2;
  --panel: #ffffff;
  --border: #e6dfd0;
  --text: #1a1714;
  --muted: #6b6157;
  --accent: #c8102e;        /* Austria red */
  --accent-hover: #a30d24;
  --accent-soft: #c8102e1a;
  --ok: #2e7d32;
  --bad: #b00020;
  --warn: #c77700;
  --gold: #d4a017;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: "Iowan Old Style", "Georgia", "Times New Roman", serif; min-height: 100vh; }
body { font-size: 16px; line-height: 1.5; }

/* Header */
header { padding: 28px 36px 0; }
.brand h1 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -.2px; }
.brand .flag { font-size: 22px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 22px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; padding: 10px 16px; font: inherit; font-size: 14px;
  color: var(--muted); cursor: pointer; position: relative; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Main / panels */
main { padding: 24px 36px 60px; max-width: 1080px; }
.panel { display: block; }
.panel.hidden { display: none; }

/* Cards */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card.wide { grid-column: 1 / -1; }
.card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; letter-spacing: .2px; text-transform: uppercase; color: var(--muted); }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card .row h3 { margin: 0; }

.cards-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat-card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.stat-card .sub-value { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Buttons */
.btn {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 14px; font: inherit; font-size: 14px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #ebe5d5; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--bg-soft); }
.btn.ok { background: #e9f3ea; border-color: #c4dec7; }
.btn.bad { background: #fbeaec; border-color: #f1c1c7; color: #6f1220; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Inputs */
.input {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font: inherit; font-size: 15px; color: var(--text); resize: vertical;
}
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.input.small { padding: 7px 10px; font-size: 14px; }
textarea.input { line-height: 1.55; font-family: "Iowan Old Style", "Georgia", serif; }

/* Prompt box */
.prompt-box { background: var(--bg-soft); border-radius: 6px; padding: 12px 14px; margin-bottom: 10px; font-size: 16px; }
.prompt-box strong { color: var(--accent); }
.prompt-box .en { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; font-style: italic; }

/* Vocab card */
.vocab-card {
  background: linear-gradient(135deg, #fff 0%, #faf7f2 100%);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 32px 24px; text-align: center; min-height: 140px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 14px;
}
.vocab-de { font-size: 32px; font-weight: 600; }
.vocab-en { font-size: 18px; color: var(--muted); }
.vocab-notes { font-size: 13px; color: var(--muted); font-style: italic; max-width: 70%; }
.vocab-empty { color: var(--muted); font-style: italic; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 6px; }
.list-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 12px; border-radius: 6px; background: var(--bg-soft); cursor: pointer;
  transition: background .12s;
}
.list-item:hover { background: #ebe5d5; }
.list-item .meta { color: var(--muted); font-size: 12px; }
.list-item .body { flex: 1; }
.list-item .body .preview { color: var(--muted); font-size: 13px; margin-top: 2px; max-height: 2.6em; overflow: hidden; }

/* Feedback rendering */
.fb-section { margin-bottom: 14px; }
.fb-section h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: .4px; }
.score-bar { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.score-num { font-size: 32px; font-weight: 600; color: var(--accent); }
.cefr-pill { display: inline-block; background: var(--accent); color: #fff; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.error-row { padding: 8px 10px; border-left: 3px solid var(--bad); background: #fff5f5; margin-bottom: 6px; border-radius: 4px; }
.error-row .orig { text-decoration: line-through; color: var(--bad); }
.error-row .fix { color: var(--ok); font-weight: 600; margin-left: 8px; }
.error-row .type { display: inline-block; font-size: 11px; text-transform: uppercase; color: var(--muted); background: var(--bg-soft); padding: 1px 6px; border-radius: 4px; margin-left: 8px; }
.error-row .expl { color: var(--muted); font-size: 13px; margin-top: 4px; }
.diff-block { background: var(--bg-soft); padding: 10px 12px; border-radius: 6px; font-size: 14px; line-height: 1.6; }
.bullets { margin: 0; padding-left: 18px; }
.bullets li { margin-bottom: 4px; }

/* Settings form */
form#settings-form { display: grid; gap: 14px; max-width: 480px; }
form#settings-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
form#settings-form input, form#settings-form select {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font: inherit; font-size: 15px; color: var(--text);
}

/* Utilities */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; }

/* Practice overlay (Intensive Shadow + Fast Review) */
.practice-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.practice-overlay.hidden { display: none; }
.practice-modal { background: var(--panel); border-radius: 12px; padding: 22px 26px; max-width: 720px; width: 100%; box-shadow: var(--shadow); max-height: 92vh; overflow-y: auto; }
.practice-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.practice-mode-label { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.practice-progress { margin-top: 2px; }
.practice-card { background: linear-gradient(135deg, #fff 0%, #faf7f2 100%); border: 1px solid var(--border); border-radius: 10px; padding: 24px; }
.practice-de { font-size: 28px; line-height: 1.3; font-weight: 600; text-align: center; margin-bottom: 8px; }
.practice-en { font-size: 16px; text-align: center; margin-bottom: 4px; }
.practice-notes { font-style: italic; text-align: center; margin-bottom: 12px; }
.practice-playcount { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0; }
audio#practice-audio { display: block; margin: 10px auto; width: 100%; }

/* Inline play icons next to sentences in the island list */
.inline-play { cursor: pointer; opacity: .6; margin-left: 6px; font-size: 14px; user-select: none; transition: opacity .12s, transform .12s; display: inline-block; }
.inline-play:hover { opacity: 1; transform: scale(1.15); }
.inline-play:active { transform: scale(.95); }

/* Toast notifications (non-blocking confirmations) */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1a1714; color: #faf7f2; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.18);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 200; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------------------ */
/* Mobile (≤720px) — phone-friendly overrides                          */
/* ------------------------------------------------------------------ */
@media (max-width: 720px) {
  body { font-size: 15px; }

  header { padding: 18px 14px 0; }
  .brand h1 { font-size: 22px; }
  .brand .flag { font-size: 18px; }
  .sub { font-size: 13px; }

  /* Tab nav — horizontal scroll instead of wrap, larger tap targets */
  .tabs {
    margin-top: 14px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    padding: 12px 14px;
    font-size: 14px;
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 44px;
  }

  /* Main content — full width with comfortable margins */
  main { padding: 16px 12px 80px; max-width: 100%; }

  .card { padding: 14px 14px; margin-bottom: 12px; border-radius: 8px; }
  .card h3 { font-size: 14px; }
  .card .row { gap: 8px; }

  /* Stack the daily-plan inline 3-column grid */
  #daily-plan-grid { grid-template-columns: 1fr !important; gap: 14px !important; }

  /* Buttons — bigger tap targets */
  .btn { padding: 10px 14px; font-size: 14px; min-height: 40px; }
  .btn-row { gap: 6px; }

  /* Inputs — slightly larger text to avoid mobile-browser autozoom; full width */
  .input { padding: 11px 12px; font-size: 16px; }
  .input.small { padding: 9px 11px; font-size: 15px; }

  /* Vocab card — keep impactful but a touch smaller */
  .vocab-card { padding: 24px 16px; min-height: 120px; }
  .vocab-de { font-size: 26px; }
  .vocab-en { font-size: 16px; }
  .vocab-notes { max-width: 92%; }

  /* Practice modal — almost full screen on mobile */
  .practice-overlay { padding: 8px; }
  .practice-modal { padding: 16px 14px; border-radius: 10px; max-height: 96vh; }
  .practice-card { padding: 18px 14px; }
  .practice-de { font-size: 22px; }
  .practice-en { font-size: 15px; }

  /* Settings form */
  form#settings-form { max-width: 100%; }

  /* Stat cards — denser */
  .cards-row { gap: 10px; margin-bottom: 12px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .value { font-size: 22px; }

  /* All rows wrap on mobile so input fields + buttons cascade cleanly */
  .row { flex-wrap: wrap; }
  .list-item { flex-wrap: wrap; }
  .list-item .meta { font-size: 11px; }

  /* Phrase card on mobile — match vocab-card mobile sizing */
  #phrase-card { min-height: 140px !important; padding: 20px 14px; }
}

/* Extra-narrow phones (≤380px) — Galaxy S-series, small Androids */
@media (max-width: 380px) {
  header { padding: 14px 12px 0; }
  main { padding: 14px 10px 80px; }
  .brand h1 { font-size: 20px; }
  .tab { padding: 11px 12px; font-size: 13px; }
  .vocab-de { font-size: 24px; }
}
