/* Norsk hver dag: mobile first, colors from the Norwegian flag. */

:root {
  --bg: #f4f1ec;
  --card: #ffffff;
  --ink: #14213d;
  --muted: #5d6679;
  --line: #e5dfd5;
  --primary: #ba0c2f;
  --on-primary: #ffffff;
  --navy: #00205b;
  --ok: #1d7a4b;
  --ok-soft: #e2f3e9;
  --bad: #b3261e;
  --bad-soft: #fbe8e6;
  --mark: #fff1c2;
  --s-neu: #c9d3e6;
  --s-aufbau: #7ea2d8;
  --s-sicher: #2f5fae;
  --s-meister: #00205b;
  --s-rest: #ece7df;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(20 33 61 / 6%), 0 8px 24px rgb(20 33 61 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1422;
    --card: #182137;
    --ink: #eef1f7;
    --muted: #9ca6bc;
    --line: #2a3553;
    --primary: #ff5a76;
    --on-primary: #1a0610;
    --navy: #9dbaff;
    --ok: #53d18f;
    --ok-soft: #133226;
    --bad: #ff8a80;
    --bad-soft: #3a1b1d;
    --mark: #4a3d12;
    --s-neu: #3a4868;
    --s-aufbau: #5277b8;
    --s-sicher: #7fa6f0;
    --s-meister: #c6d7ff;
    --s-rest: #222c45;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  min-height: 100dvh;
}

h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
p { margin: 0; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: .9rem; }
.error { color: var(--bad); font-size: .95rem; }
.warn { color: var(--bad); }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.row.gap { gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.left { text-align: left; }

.screen { display: flex; flex-direction: column; gap: 16px; }
.screen.center { min-height: 80dvh; justify-content: center; align-items: center; text-align: center; }
.screen.center > .stack, .screen.center > .card { width: 100%; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.card > h2 + * { margin-top: 8px; }

.logo { width: 72px; height: 72px; border-radius: 18px; }
.logo.small { width: 44px; height: 44px; border-radius: 12px; }
.big-emoji { font-size: 4rem; line-height: 1; }
.page-head { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.page-head.row { flex-direction: row; }

/* ---------- Buttons & inputs ---------- */

.primary, .secondary, .danger {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 0;
  font-weight: 650;
  transition: transform .08s ease, filter .15s ease;
}
.primary { background: var(--primary); color: var(--on-primary); }
.secondary { background: transparent; color: var(--navy); border: 2px solid var(--navy); }
.danger { background: transparent; color: var(--bad); border: 2px solid var(--bad-soft); }
.primary:active, .secondary:active, .option:active { transform: scale(.98); }
.primary:disabled { filter: grayscale(.6) opacity(.6); }

.link {
  background: none;
  border: 0;
  padding: 8px 4px;
  color: var(--navy);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
}

input[type=text], input:not([type]) {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--card);
  font-size: 1.15rem;
}
input:focus { border-color: var(--navy); outline: none; }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.segmented button {
  min-height: 48px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: transparent;
  font-weight: 650;
}
.segmented .active { border-color: var(--navy); background: var(--navy); color: var(--card); }

.switch { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.switch input { width: 22px; height: 22px; accent-color: var(--primary); }

/* ---------- Profiles ---------- */

.profiles { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.profile {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
}
.profile b, .profile small { display: block; }
.profile small { color: var(--muted); }
.avatar {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: var(--bg);
  font-size: 1.6rem;
}
.done { color: var(--ok); font-weight: 800; font-size: 1.3rem; }
.chev { color: var(--muted); font-size: 1.6rem; }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid label { position: relative; }
.emoji-grid input { position: absolute; opacity: 0; }
.emoji-grid span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid transparent;
  font-size: 1.4rem;
  background: var(--bg);
}
.emoji-grid input:checked + span { border-color: var(--primary); }
.emoji-grid input:focus-visible + span { outline: 3px solid var(--navy); }

.lock { font-size: 1.1rem; opacity: .7; }
.ok-note { color: var(--ok); font-weight: 600; }

/* ---------- PIN ---------- */

.pin-screen { position: relative; gap: 14px; }
.pin-screen > p { max-width: 340px; }
.pin-back { position: absolute; top: 0; left: 0; font-size: 1.8rem; }
.pin-dots { display: flex; gap: 18px; margin: 10px 0 0; }
.pin-dots i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--navy);
  transition: background .1s ease;
}
.pin-dots i.on { background: var(--navy); }
.pin-dots.shake { animation: shake .35s ease; }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.pin-error { min-height: 2.9em; max-width: 320px; }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 22px; }
.keypad button {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 1.7rem;
  font-weight: 500;
}
.keypad button:active { background: var(--s-rest); }
.keypad [data-del] { border: 0; background: transparent; box-shadow: none; font-size: 1.5rem; }

/* ---------- Home ---------- */

.home-head { display: flex; align-items: center; gap: 12px; padding-top: 4px; }
.home-head .avatar { background: var(--card); border: 1px solid var(--line); }
.home-head small { display: block; }

.streak { display: flex; flex-direction: column; gap: 14px; }
.streak-num { font-size: 1.1rem; }
.streak-num b { font-size: 1.8rem; margin: 0 4px; }
.flame { font-size: 1.5rem; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: .8rem; color: var(--muted); }
.week .day { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.week i { width: 26px; height: 26px; border-radius: 50%; background: var(--s-rest); display: block; }
.week .on i { background: var(--primary); }
.week .on i::after { content: "✓"; color: var(--on-primary); font-style: normal; font-weight: 800; font-size: .85rem; line-height: 26px; }
.week .today { color: var(--ink); font-weight: 700; }

.today-card { display: flex; flex-direction: column; gap: 10px; border-top: 5px solid var(--primary); }
.today-card .link { align-self: center; }

.stages { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 14px 0 12px; background: var(--s-rest); }
.stages span { display: block; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: .9rem; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend b { margin-left: auto; }
.legend i, .dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.s-neu { background: var(--s-neu); }
.s-aufbau { background: var(--s-aufbau); }
.s-sicher { background: var(--s-sicher); }
.s-meister { background: var(--s-meister); }
.s-rest { background: var(--s-rest); }

/* ---------- Word lists ---------- */

.word-list { list-style: none; margin: 8px 0 0; padding: 0; }
.word-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.word-list li:first-child { border-top: 0; }
.word-list li > span { flex: 1; min-width: 0; }
.word-list b, .word-list small { display: block; }
.word-list small { color: var(--muted); }
.word-list .locked { opacity: .45; }
details summary { display: flex; align-items: center; justify-content: space-between; list-style: none; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
details summary h2::before { content: "›"; display: inline-block; margin-right: 8px; transition: transform .15s; }
details[open] summary h2::before { transform: rotate(90deg); }

.say {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--bg);
  font-size: 1.15rem;
  vertical-align: middle;
}
.say.big { width: 56px; height: 56px; font-size: 1.5rem; }
.say.huge { width: 110px; height: 110px; font-size: 3rem; background: var(--card); border: 2px solid var(--line); }

/* ---------- Lesson ---------- */

.lesson { display: flex; flex-direction: column; gap: 18px; min-height: calc(100dvh - 40px); }
.lesson-top { display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; height: 12px; border-radius: 6px; background: var(--s-rest); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 6px; transition: width .3s ease; }

.exercise { display: flex; flex-direction: column; gap: 18px; padding-bottom: 240px; }
.kicker { color: var(--muted); font-weight: 650; font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; }
.prompt { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 120px; text-align: center; flex-wrap: wrap; }
.prompt h1 { font-size: 2rem; }
.prompt.sentence { flex-direction: column; min-height: 0; padding: 12px 0; }
.no { color: var(--navy); }

.word-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.word-card h1 { font-size: 2.2rem; }
.word-card .de { font-size: 1.2rem; }
.example { padding: 0 4px; display: flex; flex-direction: column; gap: 4px; }
.ex-no { font-size: 1.2rem; }
.ex-de { color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 4px; padding: 0 3px; }
.blank { display: inline-block; min-width: 3.5em; border-bottom: 3px solid var(--primary); color: var(--primary); font-weight: 700; text-align: center; }
.tip { background: var(--bg); border-radius: 14px; padding: 12px 14px; font-size: .95rem; }

.options { display: grid; gap: 10px; }
.option {
  min-height: 56px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--card);
  font-size: 1.1rem;
  text-align: left;
  transition: transform .08s ease, border-color .15s ease, background .15s ease;
}
.option.right { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option:disabled { color: inherit; }
.option:disabled:not(.right, .wrong) { opacity: .55; }

.letters { display: flex; gap: 8px; }
.letters button {
  width: 52px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--card);
  font-size: 1.2rem;
}

.mic-area { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 10px 0; text-align: center; }
.mic {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: 0;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 2.6rem;
  box-shadow: 0 6px 20px rgb(186 12 47 / 28%);
}
.mic.listening { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgb(186 12 47 / 45%); }
  50% { box-shadow: 0 0 0 18px rgb(186 12 47 / 0%); }
}

.feedback {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--card);
  border-top: 4px solid var(--ok);
  box-shadow: 0 -8px 30px rgb(0 0 0 / 12%);
  animation: rise .2s ease-out;
}
.feedback[hidden] { display: none; }
.feedback.ok { border-top-color: var(--ok); background: linear-gradient(var(--ok-soft), var(--card) 70%); }
.feedback.bad { border-top-color: var(--bad); background: linear-gradient(var(--bad-soft), var(--card) 70%); }
.fb-head { display: flex; align-items: center; justify-content: space-between; }
.fb-head strong { font-size: 1.35rem; }
.feedback.ok .fb-head strong { color: var(--ok); }
.feedback.bad .fb-head strong { color: var(--bad); }
.answer { font-size: 1.15rem; }
.ex-line { color: var(--muted); }
.feedback .primary { margin-top: 6px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }

/* ---------- Summary ---------- */

.summary .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px; }
.stats b { display: block; font-size: 1.4rem; }
.stats small { color: var(--muted); }

.url {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  font-size: .85rem;
  word-break: break-all;
  user-select: all;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
