:root {
  --bg: #0a0810;
  --s1: #130f1c;
  --s2: #181321;
  --text: #e4e0ea;
  --dim: #8a8296;
  --w: #fff;
  --border: #2b2338;
  --acc: #c026d3;
  --acc2: #a855f7;
  --acc3: #ec4899;
  --grad: linear-gradient(135deg, #c084fc, #e879f9 55%, #f472b6);
  --glow: 0 0 18px rgba(192, 132, 252, 0.35);
  --danger: #fb7185;
  --ok: #34d399;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --tab: 64px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
}

img,
video {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

input[type="text"] {
  width: 100%;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
}

input[type="text"]:focus {
  border-color: #6d28d9;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.25);
}

input[type="text"]::placeholder {
  color: var(--dim);
}

:focus-visible {
  outline: 2px solid #c084fc;
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

#app {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

@media (min-width: 481px) {
  #app {
    border-inline: 1px solid var(--border);
    box-shadow: 0 0 80px rgba(192, 132, 252, 0.08);
  }
}

.view {
  display: none;
  min-height: 100dvh;
  padding:
    calc(12px + var(--safe-t))
    calc(16px + var(--safe-r))
    calc(var(--tab) + 18px + var(--safe-b))
    calc(16px + var(--safe-l));
}

.view.is-on {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.is-neu .tabbar,
body.is-neu #view-neu {
  /* capture uses its own chrome */
}

#view-neu.is-on {
  padding: 0;
  min-height: 100dvh;
  overflow: hidden;
}

#view-lernen.is-on {
  padding: 0;
  overflow: hidden;
}

/* ——— Brand / headers ——— */

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand p {
  margin: 6px 0 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mono {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

/* ——— Buttons ——— */

.btn {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--s1);
}

.btn svg {
  flex-shrink: 0;
}

.btn-grad {
  background: var(--grad);
  color: #1a0b22;
  border: 0;
  box-shadow: var(--glow);
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  background: #3a1520;
  border-color: #5b2432;
  color: var(--danger);
}

.btn-wide {
  width: 100%;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--s1);
  border: 1px solid var(--border);
  color: var(--text);
  flex-shrink: 0;
}

.icon-btn.danger {
  color: var(--danger);
}

/* ——— Sortiment ——— */

.cta-row {
  margin-bottom: 18px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tile-wrap {
  position: relative;
}

.tile {
  width: 100%;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  min-height: 44px;
  text-align: left;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.tile:active {
  transform: scale(0.985);
}

.tile-img {
  aspect-ratio: 3 / 4;
  width: 100%;
  object-fit: cover;
  background: var(--s2);
}

.tile-meta {
  padding: 10px 12px 12px;
}

.tile-title {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-date {
  margin-top: 3px;
}

.tile-del {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(10, 8, 16, 0.72);
  border: 1px solid var(--border);
  color: var(--w);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
}

.empty,
.status {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 32px 8px 64px;
  color: var(--dim);
}

.empty h2,
.status h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.2rem;
}

.empty p,
.status p {
  margin: 0;
  max-width: 28ch;
}

.empty-mark {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: var(--s1);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  box-shadow: var(--glow);
}

.count-chip {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  border: 1px solid var(--border);
  background: var(--s1);
  border-radius: 999px;
  padding: 8px 10px;
  white-space: nowrap;
}

/* ——— Tab bar ——— */

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  height: calc(var(--tab) + var(--safe-b));
  padding: 6px 12px var(--safe-b);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(10, 8, 16, 0.88);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
  z-index: 20;
}

body.is-neu .tabbar {
  display: none;
}

.tab {
  min-height: 52px;
  border-radius: 14px;
  color: var(--dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-weight: 600;
  font-size: 0.78rem;
}

.tab svg {
  opacity: 0.85;
}

.tab.is-on {
  color: var(--w);
  background: var(--s2);
}

.tab.is-on svg {
  color: #e879f9;
}

/* ——— Lernen ——— */

.learn {
  position: relative;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    calc(10px + var(--safe-t))
    calc(12px + var(--safe-r))
    calc(var(--tab) + 10px + var(--safe-b))
    calc(12px + var(--safe-l));
  touch-action: none;
  user-select: none;
}

.learn-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 3;
}

.learn-stage {
  position: relative;
  flex: 1;
  margin: 12px 0 10px;
  border-radius: 22px;
  overflow: hidden;
  background: var(--s1);
  border: 1px solid var(--border);
}

.learn-card {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--s1);
  will-change: transform;
}

.learn-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #09070f;
}

.learn-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 80ms linear;
  z-index: 2;
}

.learn-hint span {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(10, 8, 16, 0.72);
  border: 1px solid var(--border);
  color: var(--w);
  box-shadow: var(--glow);
}

.learn-hint.is-show {
  opacity: 1;
}

.learn-hint.dir-right {
  background: linear-gradient(90deg, transparent, rgba(236, 72, 153, 0.18));
}
.learn-hint.dir-left {
  background: linear-gradient(270deg, transparent, rgba(168, 85, 247, 0.18));
}
.learn-hint.dir-up {
  background: linear-gradient(0deg, transparent, rgba(192, 132, 252, 0.2));
}
.learn-hint.dir-down {
  background: linear-gradient(180deg, transparent, rgba(192, 132, 252, 0.2));
}

.learn-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.side-pill {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--s2);
  color: var(--text);
}

.bounce-x {
  animation: bounceX 280ms ease;
}
.bounce-y {
  animation: bounceY 280ms ease;
}

@keyframes bounceX {
  0% { transform: translateX(0); }
  40% { transform: translateX(18px); }
  100% { transform: translateX(0); }
}
@keyframes bounceY {
  0% { transform: translateY(0); }
  40% { transform: translateY(-18px); }
  100% { transform: translateY(0); }
}

/* ——— Capture ——— */

.cap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #05040a;
  padding-bottom: var(--safe-b);
}

.cap-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 12px 10px;
  gap: 8px;
}

.cap-top h2 {
  margin: 0;
  font-size: 1.05rem;
}

.cap-stage {
  position: relative;
  flex: 1;
  margin: 0 12px;
  border-radius: 22px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  min-height: 280px;
}

.cap-stage video,
.cap-stage img.shot {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.frame {
  position: absolute;
  inset: 10%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 16px;
  box-shadow: 0 0 0 999px rgba(5, 4, 10, 0.28);
  pointer-events: none;
}

.cap-actions {
  padding: 16px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shutter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shutter {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--w);
  box-shadow: var(--glow);
  position: relative;
  flex-shrink: 0;
}

.shutter::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 4px solid #1a0b22;
}

.shutter:active {
  transform: scale(0.96);
}

.cap-side {
  min-width: 88px;
  text-align: center;
}

.review {
  padding: 8px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.review-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.review-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  padding: 0;
  text-align: left;
}

.review-card img {
  aspect-ratio: 3 / 4;
  width: 100%;
  object-fit: cover;
}

.review-card span {
  display: block;
  padding: 10px 10px 12px;
  font-weight: 600;
  font-size: 0.9rem;
}

.cam-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: var(--s1);
  color: var(--dim);
}

.cam-fallback h3 {
  margin: 0;
  color: var(--text);
}

.cam-fallback p {
  margin: 0;
}

/* ——— Toast / modal ——— */

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tab) + 16px + var(--safe-b));
  z-index: 50;
  background: var(--s2);
  border: 1px solid var(--border);
  color: var(--w);
  padding: 12px 16px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: var(--glow);
  pointer-events: none;
  max-width: calc(100% - 32px);
}

body.is-neu .toast {
  bottom: calc(20px + var(--safe-b));
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(5, 4, 10, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px calc(16px + var(--safe-b));
}

.sheet {
  width: min(480px, 100%);
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 20px 18px 16px;
}

.sheet h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.sheet p {
  margin: 0 0 16px;
  color: var(--dim);
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (prefers-reduced-motion: reduce) {
  .bounce-x,
  .bounce-y,
  .tile:active,
  .shutter:active {
    animation: none;
    transform: none;
  }
}
