/* Stickywall – Aussehen. Farben ganz oben, damit sie sich leicht ändern lassen. */
:root {
  --bg: #e9e9ee;            /* Fläche um die Wand */
  --wall: #ffffff;          /* die Wand selbst */
  --surface: #ffffff;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --accent: #ff375f;        /* Akzentfarbe der Marke */
  --accent-press: #e62a50;
  --danger: #d70015;
  --glass: rgba(250, 250, 252, 0.72);
  --glass-edge: rgba(255, 255, 255, 0.6);
  --r-lg: 22px; --r-md: 16px; --r-sm: 12px;
  --font: -apple-system, "SF Pro Text", BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-display: -apple-system, "SF Pro Display", BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 100%/1.4 var(--font);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none;
}
input { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Milchglas ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}

/* ---------- Kopfzeile ---------- */
.top {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  padding: calc(var(--safe-top) + 10px) 20px 12px;
  /* weicher Übergang statt harter Linie */
  -webkit-mask-image: linear-gradient(#000 calc(100% - 8px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 8px), transparent);
}
.top-row { display: flex; align-items: center; gap: 8px; }
.brand {
  font-family: var(--font-display);
  font-size: 1.375rem; font-weight: 700; letter-spacing: -0.022em; line-height: 1.1;
}
.badge {
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.01em;
  color: #b25000; background: rgba(255, 149, 0, 0.16);
  padding: 3px 8px; border-radius: 999px;
}
.stats { margin-top: 4px; display: flex; align-items: baseline; gap: 6px; }
.stats-num { font-size: 1.0625rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stats-label { font-size: 0.8125rem; color: var(--text-2); letter-spacing: 0.005em; }

/* ---------- Die Wand ---------- */
.stage {
  position: fixed; inset: 0;
  touch-action: none;
  overflow: hidden;
  cursor: grab;
}
.stage:active { cursor: grabbing; }
.wall {
  position: absolute; left: 0; top: 0;
  transform-origin: 0 0;
  background: var(--wall);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 12px 48px rgba(0, 0, 0, 0.08);
  --inv: 1;
}
.wall canvas { display: block; width: 100%; height: 100%; }
.wall canvas.pixelated { image-rendering: pixelated; }
.grid {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.07) calc(1px * var(--inv)), transparent 0),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.07) calc(1px * var(--inv)), transparent 0);
  background-size: 10px 10px;
  transition: opacity 200ms ease;
}

/* Auswahl */
.select {
  position: absolute;
  outline: calc(2px * var(--inv)) solid var(--accent);
  background: rgba(255, 55, 95, 0.1);
  box-shadow: 0 0 0 100000px rgba(0, 0, 0, 0.16);
  touch-action: none;
}
.select.active { background: rgba(255, 55, 95, 0.18); }
.select-move { position: absolute; inset: 0; cursor: move; touch-action: none; }
.select-handle {
  position: absolute; right: 0; bottom: 0;
  width: calc(26px * var(--inv)); height: calc(26px * var(--inv));
  transform: translate(50%, 50%);
  border-radius: 50%;
  background: #fff;
  border: calc(2px * var(--inv)) solid var(--accent);
  box-shadow: 0 calc(1px * var(--inv)) calc(6px * var(--inv)) rgba(0, 0, 0, 0.25);
  cursor: nwse-resize; touch-action: none;
}
.select-handle::before { content: ""; position: absolute; inset: calc(-12px * var(--inv)); }

.empty {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  text-align: center; pointer-events: none;
}
.empty-title { margin: 0; font-family: var(--font-display); font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; }
.empty-text { margin: 4px 0 0; color: var(--text-2); font-size: 0.9375rem; }

/* ---------- Untere Leiste ---------- */
.bottom {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  box-shadow: inset 0 0.5px 0 var(--glass-edge), 0 -0.5px 0 rgba(0, 0, 0, 0.06);
}
#barSelect { display: flex; align-items: center; gap: 12px; }
.select-info { flex: 1; min-width: 0; }
.select-price { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.select-size { font-size: 0.8125rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.select-over { font-size: 0.8125rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-over.is-over { color: var(--accent); font-weight: 600; }
.select-actions { display: flex; gap: 8px; }

/* ---------- Knöpfe ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border-radius: 14px;
  font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em;
  transition: transform 100ms ease-out, background-color 100ms ease-out, opacity 150ms;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-press); }
.btn-secondary { background: var(--fill); color: var(--text); }
.btn-secondary:active { background: var(--fill-strong); }
.btn-big { height: 54px; width: 100%; font-size: 1.0625rem; }
.btn-full { width: 100%; }
.btn.busy { pointer-events: none; opacity: 0.7; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--fill); flex: none;
  transition: transform 100ms ease-out;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 14px; height: 14px; stroke: var(--text-2); stroke-width: 2.4; stroke-linecap: round; fill: none; }

/* ---------- Infokarte ---------- */
.info {
  position: fixed; left: 12px; right: 12px; z-index: 11;
  bottom: calc(90px + var(--safe-bottom));
  padding: 16px;
  border-radius: var(--r-lg);
  box-shadow: inset 0 0.5px 0 var(--glass-edge), 0 8px 32px rgba(0, 0, 0, 0.14);
  opacity: 0; transform: translateY(8px) scale(0.98);
  transform-origin: 50% 100%;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.info.show { opacity: 1; transform: none; }
.info-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.info-name { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; word-break: break-word; }
.info-meta { font-size: 0.8125rem; color: var(--text-2); margin-top: 2px; }
.info-caption { margin: 10px 0 0; font-size: 1rem; }
.info .btn { margin-top: 14px; }

/* ---------- Fenster von unten ---------- */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.32); opacity: 0; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-height: calc(100dvh - var(--safe-top) - 24px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.18);
  transform: translate3d(0, 100%, 0);
  will-change: transform;
}
.sheet.fade { transition: opacity 200ms ease; }
.sheet-grab { flex: none; height: 22px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.sheet-grab span { width: 36px; height: 5px; border-radius: 3px; background: rgba(60, 60, 67, 0.3); }
.sheet-body {
  overflow-y: auto; overscroll-behavior: contain;
  padding: 0 20px calc(20px + var(--safe-bottom));
}
.sheet-title {
  margin: 2px 0 14px;
  font-family: var(--font-display); font-size: 1.375rem; font-weight: 700; letter-spacing: -0.022em; line-height: 1.15;
  touch-action: none;
}

/* Segment-Umschalter wie in iOS */
.segmented {
  position: relative; display: flex; padding: 2px;
  background: var(--fill); border-radius: 9px;
  --i: 0;
}
.segmented button {
  position: relative; z-index: 1; flex: 1; height: 32px;
  font-size: 0.875rem; font-weight: 500;
  transition: transform 100ms ease-out;
}
.segmented button[aria-selected="true"] { font-weight: 600; }
.segmented button:active { transform: scale(0.96); }
.seg-thumb {
  position: absolute; top: 2px; left: 2px; bottom: 2px;
  width: calc((100% - 4px) / 3);
  background: #fff; border-radius: 7px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  transform: translateX(calc(var(--i) * 100%));
  transition: transform 280ms cubic-bezier(0.25, 0.9, 0.3, 1);
}

.preview-wrap {
  margin-top: 14px; padding: 14px;
  min-height: 120px;
  display: grid; place-items: center;
  background: var(--bg); border-radius: var(--r-md);
}
#preview {
  display: block; background: var(--wall);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 2px 10px rgba(0, 0, 0, 0.06);
  touch-action: none;
}

.panel { margin-top: 14px; }
.row-label {
  margin: 16px 0 8px;
  font-size: 0.8125rem; font-weight: 600; color: var(--text-2); letter-spacing: 0.005em;
}
.panel > .row-label:first-child { margin-top: 0; }
.field {
  width: 100%; height: 46px; padding: 0 14px;
  border: 0; border-radius: var(--r-sm);
  background: var(--fill);
  font: 400 1.0625rem var(--font); color: var(--text);
  outline: none;
}
.field:focus { box-shadow: 0 0 0 2px var(--accent); }
.field::placeholder { color: #8e8e93; }
.panel .field + .row-label { margin-top: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips-spacer { flex: 1; }
.chip {
  height: 34px; padding: 0 14px; border-radius: 17px;
  background: var(--fill); font-size: 0.9375rem; font-weight: 500;
  transition: transform 100ms ease-out, background-color 120ms;
}
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"] { background: var(--text); color: #fff; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 100ms ease-out, box-shadow 120ms;
}
.swatch:active { transform: scale(0.9); }
.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 0 0 2px #fff, 0 0 0 4px var(--text); }
.swatch-none {
  background: #fff linear-gradient(135deg, transparent calc(50% - 1px), var(--danger) calc(50% - 1px), var(--danger) calc(50% + 1px), transparent calc(50% + 1px));
}

.file-btn { position: relative; }
.hint { margin: 8px 0 0; font-size: 0.8125rem; color: var(--text-2); line-height: 1.35; }
.hint.center { text-align: center; }
.error { margin: 14px 0 0; color: var(--danger); font-size: 0.9375rem; font-weight: 500; }
#pay { margin-top: 20px; }
.express { margin-top: 20px; min-height: 52px; }
.express + #pay { margin-top: 10px; }
.overlay-msg { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(245,245,247,.7); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); font-weight: 600; }

/* ---------- Kurze Meldung ---------- */
.toast {
  position: fixed; z-index: 30; left: 50%;
  top: calc(var(--safe-top) + 84px);
  transform: translate(-50%, -8px);
  padding: 10px 16px; border-radius: 999px;
  background: rgba(29, 29, 31, 0.86); color: #fff;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.005em;
  white-space: nowrap; opacity: 0;
  transition: opacity 200ms ease, transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Barrierefreiheit ---------- */
@media (prefers-reduced-motion: reduce) {
  .info, .toast { transition: opacity 200ms ease; transform: none !important; }
  .toast { transform: translateX(-50%) !important; }
  .seg-thumb { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .glass { background: #fafafc; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .top { -webkit-mask-image: none; mask-image: none; box-shadow: 0 0.5px 0 rgba(0, 0, 0, 0.12); }
}
@media (prefers-contrast: more) {
  .glass { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .bottom, .info { box-shadow: 0 0 0 1px var(--text); }
  :root { --text-2: #3a3a3c; --fill: rgba(118, 118, 128, 0.24); }
}
@media (hover: hover) {
  .btn-secondary:hover { background: var(--fill-strong); }
}

.chip.font-elegant { font-family: "New York", "Iowan Old Style", Georgia, serif; font-style: italic; }
.chip.font-round { font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif; font-weight: 700; }
.chip.font-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.875rem; }

/* Schutz vor dem Überkleben */
.chip .chip-extra { font-weight: 400; opacity: 0.6; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .chip-extra { opacity: 0.75; }
.zone {
  position: absolute; pointer-events: none;
  background: repeating-linear-gradient(45deg, rgba(29, 29, 31, 0.28) 0 calc(4px * var(--inv)), transparent 0 calc(9px * var(--inv)));
  outline: calc(1.5px * var(--inv)) solid rgba(29, 29, 31, 0.55);
}
.select.blocked { outline-color: #8e8e93; background: rgba(142, 142, 147, 0.18); }
.select-over.is-blocked { color: var(--danger); font-weight: 600; }
.info-protect { margin-top: 8px; font-size: 0.875rem; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.info-protect svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
