/* KI-Dojo — design tokens from florianschaefer.de (dark), Montserrat + Spline Sans Mono. */

@font-face {
  font-family: 'Montserrat';
  src: url('/fonts/montserrat-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: 'Montserrat';
  src: url('/fonts/montserrat-italic-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Spline Sans Mono';
  src: url('/fonts/spline-sans-mono-latin.woff2') format('woff2');
  font-weight: 400 500;
  font-display: swap;
}

:root {
  --bg: #0f141b;
  --bg-2: #141c28;
  --surface: #19222f;
  --surface-2: #1f2a3a;
  --navy: #283952;
  --gold: #EBCC92;
  --gold-deep: #caa863;
  --text: #e8e9ec;
  --muted: #98a3b3;
  --muted-2: #727e8f;
  --hairline: rgba(235, 204, 146, .14);
  --hairline-cool: rgba(255, 255, 255, .08);
  --ok: #3ad07a;
  --bad: #e07070;
  --radius: 16px;
  --ease: cubic-bezier(.2, .6, .2, 1);
  --tabbar-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

/* film grain (static, cheap) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: url('/img/grain.png');
  opacity: .04;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 999;
}

img { max-width: 100%; }
button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  appearance: none;          /* iOS Safari wuerde sonst weisse System-Buttons malen */
  -webkit-appearance: none;
  border-radius: 0;
  text-align: inherit;
}
a { color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

h1, h2, h3 { font-weight: 800; line-height: 1.15; letter-spacing: -.02em; color: #fff; text-wrap: balance; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

.eyebrow {
  font-family: 'Spline Sans Mono', monospace;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
}
.muted { color: var(--muted); }
.mono { font-family: 'Spline Sans Mono', monospace; font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 14px calc(var(--tabbar-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.screen.full { padding-bottom: 24px; }
.screen.center { justify-content: center; align-items: center; text-align: center; }

/* ---------- cards ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hairline-cool);
  border-radius: var(--radius);
  padding: 22px 18px;
  overflow: hidden;
}
.card::before { /* gold hairline top (signature detail) */
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(235, 204, 146, .4), transparent);
}
.card.flat::before { display: none; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > * { margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  min-height: 56px;
  padding: 14px 28px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: transform .15s var(--ease);
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-gold {
  background: var(--gold);
  color: #1a1206;
  box-shadow: 0 10px 30px -10px rgba(235, 204, 146, .4);
}
.btn-ghost { background: transparent; color: var(--text); border-color: var(--hairline-cool); }
.btn-line { background: none; color: var(--muted); min-height: 44px; font-weight: 600; }

/* ---------- forms ---------- */
input:not([type=checkbox]):not([type=radio]), textarea, select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--hairline-cool);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 1rem;              /* nie unter 16px, sonst zoomt iOS beim Antippen */
  padding: 14px 16px;
  min-height: 54px;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted-2); opacity: 1; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(235, 204, 146, .12);
}
/* autofill would otherwise paint fields white on the dark ground */
input:-webkit-autofill, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 100px var(--bg-2) inset;
  caret-color: var(--text);
  border: 1px solid var(--hairline-cool);
}
.hint { font-size: .8rem; color: var(--muted-2); }

/* ---------- kito ---------- */
.kito { display: block; margin: 0 auto; height: auto; }
.kito-s { width: 76px; }
.kito-m { width: 130px; }
.kito-l { width: 190px; }
.bubble {
  background: var(--surface-2);
  border: 1px solid var(--hairline-cool);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: .95rem;
  position: relative;
}

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-2);
  border-top: 1px solid var(--hairline-cool);
  display: flex;
  z-index: 50;
}
.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: .68rem;
  font-weight: 600;
  color: var(--muted);
}
.tabbar button.on { color: var(--gold); }
.tabbar svg { width: 24px; height: 24px; }

/* ---------- status row (home) ---------- */
.statusrow { display: flex; align-items: center; gap: 14px; }
.statusrow .stat { display: flex; align-items: center; gap: 7px; font-weight: 700; }
.statusrow .flame { font-size: 1.3rem; }
.statusrow img { width: 52px; height: 52px; border-radius: 50%; background: var(--navy); margin-left: auto; }
.goalring { font-family: 'Spline Sans Mono', monospace; font-size: .8rem; color: var(--muted); }

/* ---------- belt path ---------- */
.stufe-head { padding: 18px 2px 4px; }
.beltcard {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--hairline-cool);
  border-radius: 14px;
  padding: 14px 16px;
  width: 100%;
  text-align: left;
}
.beltcard .swatch { width: 10px; height: 40px; border-radius: 4px; flex: none; }
.beltcard .name { font-weight: 700; color: #fff; }
.beltcard .sub { font-size: .8rem; color: var(--muted); }
.beltcard.locked { opacity: .55; }
.beltcard .lock { margin-left: auto; color: var(--muted-2); }

.unitlist { display: flex; flex-direction: column; }
.unit {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
  padding: 9px 0;
  width: 100%;
  text-align: left;
}
.unit .dot {
  width: 60px; height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Spline Sans Mono', monospace;
  font-weight: 500;
  background: var(--surface);
  border: 2px solid var(--hairline-cool);
  color: var(--muted);
  position: relative;
}
.unit .titel { font-weight: 600; color: var(--text); }
.unit .sub { font-size: .78rem; color: var(--muted-2); }
/* states are exclusive: active wins (else-if in JS) */
.unit.active .dot {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 0 4px rgba(235, 204, 146, .12);
  animation: pulse 2.4s infinite;
}
.unit.done .dot { background: var(--beltcolor, var(--navy)); border-color: transparent; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.unit.locked { opacity: .5; }
.unit.exam .dot { border-width: 3px; border-style: double; width: 64px; height: 64px; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(235, 204, 146, .12); }
  50% { box-shadow: 0 0 0 8px rgba(235, 204, 146, .05); }
}
@media (prefers-reduced-motion: reduce) {
  .unit.active .dot { animation: none; }
  * { transition: none !important; }
}

/* ---------- lesson flow ---------- */
.flowtop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 2px;
}
.flowtop .x { font-size: 1.5rem; color: var(--muted); padding: 8px 12px; margin-left: -12px; }
.progress7 { display: flex; gap: 5px; flex: 1; }
.progress7 span { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-2); }
.progress7 span.on { background: var(--gold); }

.lesson-body { font-size: 1.05rem; line-height: 1.65; display: flex; flex-direction: column; gap: 14px; }
.lesson-body h3 { margin-top: 8px; }
.lesson-body ul { padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.lesson-body blockquote {
  background: var(--bg-2);
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  padding: 12px 14px;
  font-size: .95rem;
}
.example { display: flex; flex-direction: column; gap: 10px; }
.example .ex {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: .92rem;
  border: 1px solid var(--hairline-cool);
}
.example .ex b { display: block; font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 4px; }
.example .bad b { color: var(--bad); }
.example .good b { color: var(--ok); }

.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; padding: 12px 15px; border-radius: 16px; font-size: .97rem; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--navy); border-bottom-right-radius: 4px; }
.msg.kito { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--hairline-cool); border-bottom-left-radius: 4px; }

.fb { display: flex; flex-direction: column; gap: 12px; }
.fb .part { border-radius: 12px; padding: 13px 15px; border: 1px solid var(--hairline-cool); font-size: .95rem; }
.fb .lob { border-color: rgba(58, 208, 122, .3); }
.fb .verb { border-color: var(--hairline); }
.fb b { display: block; font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-bottom: 5px; }
.fb .lob b { color: var(--ok); }

/* quiz */
.qopt {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--hairline-cool);
  border-radius: 12px;
  padding: 15px 16px;
  min-height: 56px;
  margin-bottom: 10px;
  font-size: .97rem;
  transition: transform .12s var(--ease);
}
.qopt:active { transform: scale(.98); }
.qopt.right { border-color: var(--ok); background: rgba(58, 208, 122, .08); }
.qopt.wrong { border-color: var(--bad); background: rgba(224, 112, 112, .08); }
.qexplain { font-size: .88rem; color: var(--muted); padding: 4px 2px 0; }

/* celebration */
.celebrate { text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.beltband { height: 12px; border-radius: 99px; width: 70%; }

/* profile */
.plist { display: flex; flex-direction: column; gap: 12px; }
.prow { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.prow .grow { flex: 1; }
.gallery { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.gallery img { border-radius: 12px; background: var(--bg-2); width: 100%; }
.gallery img.off { filter: grayscale(1) brightness(.5); }
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1;
  min-height: 48px;
  border: 1px solid var(--hairline-cool);
  border-radius: 10px;
  font-weight: 700;
}
.seg button.on { border-color: var(--gold); color: var(--gold); }
.danger { color: var(--bad); }

/* misc */
.toast {
  position: fixed;
  left: 14px; right: 14px;
  bottom: calc(var(--tabbar-h) + 16px);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 13px 16px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .92rem;
  box-shadow: 0 18px 50px -20px rgba(0, 0, 0, .6);
}
.offline {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--navy);
  color: #fff;
  font-size: .82rem;
  text-align: center;
  padding: 7px;
  z-index: 100;
}
.spin { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; padding: 24px 0; }
.wizard-dots { display: flex; gap: 7px; justify-content: center; }
.wizard-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-2); }
.wizard-dots span.on { background: var(--gold); }

@media (min-width: 900px) { /* desktop: same tab bar as a slim left rail */
  .tabbar {
    top: 0; bottom: 0; right: auto;
    width: 92px; height: auto;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    border-top: none;
    border-right: 1px solid var(--hairline-cool);
    padding-bottom: 0;
  }
  .tabbar button { flex: none; height: 72px; }
  .screen { padding-left: 110px; padding-bottom: 40px; max-width: 800px; }
}

/* score badge */
.scorebadge {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  font-family: 'Spline Sans Mono', monospace;
}
.scorebadge .jetzt { font-size: 2.2rem; font-weight: 600; color: var(--gold); }
.scorebadge .vorher { font-size: 1.3rem; color: var(--muted-2); text-decoration: line-through; }
.scorebadge .pfeil { color: var(--muted); }
.scorebadge .von { font-size: .75rem; color: var(--muted); letter-spacing: .08em; }

/* daily training card */
.dailycard {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--hairline);
  width: 100%;
  text-align: left;
}
.dailycard.done { opacity: .7; border-color: var(--hairline-cool); }

/* gentle screen transition */
#app > .screen { animation: viewin .22s var(--ease); }
@keyframes viewin {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  #app > .screen { animation: none; }
}

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; }
