:root {
  --bg: #0a0a0e;
  --bg-elev: #121218;
  --card: #16161e;
  --card-2: #1e1e28;
  --line: #26262f;
  --txt: #f4f4f8;
  --dim: #9797a8;
  --dim-2: #6e6e7d;
  --acc: #7c5cff;
  --acc-2: #a78bfa;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --pad: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

svg { width: 20px; height: 20px; flex: none; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

body { min-height: 100vh; min-height: 100dvh; }

.app { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--safe-b) + 28px); }

button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:active { transform: scale(.985); }
input { font-family: inherit; }

/* ---------------------------------------------------------------- Header */
.hdr {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--safe-t) + 14px) max(var(--pad), calc((100% - 1080px) / 2)) 12px;
  background: rgba(10, 10, 14, .78);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, .05);
  display: flex;
  align-items: center;
  gap: 12px;
}
.hdr h1 {
  font-size: 21px;
  line-height: 1.15;
  font-weight: 700;
  margin: 0;
  letter-spacing: -.02em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hdr .sub { display: block; font-size: 12px; font-weight: 500; color: var(--dim); letter-spacing: 0; margin-top: 2px; }
.icon-btn {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  transition: background .18s ease;
}
.icon-btn:active { background: var(--card-2); }
.icon-btn svg { width: 19px; height: 19px; stroke: var(--txt); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 14px;
  padding: 16px var(--pad) 0;
  max-width: 1080px;
  margin: 0 auto;
}
@media (min-width: 620px) { .grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 18px; } }

.card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-align: left;
  animation: rise .32s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card:active .thumb { transform: scale(.965); }

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  overflow: hidden;
  background: linear-gradient(150deg, #1b1b25, #14141b);
  border: 1px solid rgba(255, 255, 255, .06);
  transition: transform .16s ease;
  display: grid;
  place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; position: absolute; inset: 0; }
.thumb .ini {
  font-size: 30px;
  font-weight: 700;
  color: #3e3e50;
  letter-spacing: -.03em;
}
/* Kleines Bild der zugewiesenen Audiodatei in der Ecke der Figur-Kachel */
.thumb .inset {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 42%;
  max-width: 64px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: #0b0b10;
  border: 2px solid rgba(10, 10, 14, .92);
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .95);
  display: grid;
  place-items: center;
}
.thumb .inset .ini { font-size: 15px; }
.badge {
  position: absolute;
  left: 8px; bottom: 8px;
  padding: 3px 7px;
  font-size: 10.5px;
  font-weight: 650;
  border-radius: 7px;
  background: rgba(8, 8, 12, .78);
  backdrop-filter: blur(8px);
  color: #e8e8f0;
  letter-spacing: .01em;
}
.badge.cloud { left: auto; right: 8px; color: var(--warn); }

.card .t {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .s {
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: -3px;
}

/* --------------------------------------------------------------- Detail */
.detail { padding: 22px var(--pad) 0; max-width: 1080px; margin: 0 auto; }
.hero { display: flex; gap: 18px; align-items: flex-start; }
.hero .thumb { width: 128px; flex: none; border-radius: var(--r-lg); box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .9); }
.hero .meta { min-width: 0; padding-top: 2px; }
.hero h2 {
  margin: 0 0 6px;
  font-size: 21px;
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: -.025em;
}
.hero .fig {
  font-size: 12.5px;
  color: var(--acc-2);
  font-weight: 600;
  margin-bottom: 8px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 8px;
  background: var(--card-2);
  color: var(--dim);
  border: 1px solid var(--line);
}
.chip.warn { color: var(--warn); border-color: rgba(251, 191, 36, .25); background: rgba(251, 191, 36, .08); }
.chip.ok { color: var(--ok); border-color: rgba(52, 211, 153, .22); background: rgba(52, 211, 153, .08); }

.section { margin-top: 26px; }
.section.tight { margin-top: 24px; }

.assigned {
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--card);
  border: 1px solid var(--line);
}
.assigned .thumb { width: 56px; height: 56px; aspect-ratio: auto; border-radius: 12px; flex: none; }
.assigned .thumb .ini { font-size: 17px; }
.assigned .abody { min-width: 0; }
.assigned .at { font-size: 14.5px; font-weight: 650; line-height: 1.3; }
.assigned .as { font-size: 12px; color: var(--dim); margin-top: 3px; }
.empty.small { padding: 20px 16px; font-size: 13.5px; }
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim-2);
  margin: 0 0 10px 2px;
}
.rows { border-radius: var(--r-md); background: var(--card); border: 1px solid var(--line); overflow: hidden; }
.row { display: flex; gap: 10px; padding: 12px 14px; font-size: 13px; align-items: baseline; }
.row + .row { border-top: 1px solid var(--line); }
.row .k { color: var(--dim); flex: none; }
.row .v { margin-left: auto; text-align: right; word-break: break-word; font-weight: 550; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 17px;
  border-radius: var(--r-md);
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -.01em;
  background: var(--acc);
  color: #fff;
  box-shadow: 0 10px 30px -12px rgba(124, 92, 255, .8);
  transition: transform .14s ease, background .14s ease;
}
.btn:active { background: #6d4dfa; }
.btn svg { stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn.ghost { background: var(--card); border: 1px solid var(--line); box-shadow: none; color: var(--txt); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.back {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 14px; font-weight: 600; color: var(--dim);
  padding: 6px 2px; margin-bottom: 6px;
}
.back svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- Suche */
.searchbar {
  position: sticky;
  top: 0;
  z-index: 15;
  padding: calc(var(--safe-t) + 12px) max(var(--pad), calc((100% - 1080px) / 2)) 12px;
  background: rgba(10, 10, 14, .86);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.searchbar form { display: flex; gap: 10px; align-items: center; }
.field {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.field svg {
  position: absolute; left: 13px; width: 17px; height: 17px;
  stroke: var(--dim-2); fill: none; stroke-width: 2.2; stroke-linecap: round; pointer-events: none;
}
.field input {
  width: 100%;
  padding: 13px 14px 13px 39px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--txt);
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.field input::placeholder { color: var(--dim-2); }
.field input:focus { border-color: rgba(124, 92, 255, .55); background: var(--bg-elev); }
.field input::-webkit-search-cancel-button,
.field input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

.hits { padding: 6px var(--pad) 0; max-width: 1080px; margin: 0 auto; }
.hit {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 9px 0;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, .045);
  animation: rise .22s ease both;
}
.hit .thumb { width: 54px; height: 54px; aspect-ratio: auto; border-radius: 11px; flex: none; }
.hit .thumb .ini { font-size: 17px; }
.hit .body { min-width: 0; flex: 1; }
.hit .body .t { font-size: 14px; font-weight: 600; line-height: 1.28; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hit .body .s { font-size: 12px; color: var(--dim); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hit .body .s b { color: var(--dim-2); font-weight: 500; }
.hit .dur { font-size: 11.5px; color: var(--dim-2); font-variant-numeric: tabular-nums; flex: none; }
#more { height: 1px; }
.hit:active { background: rgba(255, 255, 255, .03); }

.empty { text-align: center; color: var(--dim); padding: 48px 24px; font-size: 14px; line-height: 1.6; }
.empty b { display: block; color: var(--txt); font-size: 15px; margin-bottom: 6px; }

/* ---------------------------------------------------------------- Login */
.login {
  min-height: 100vh; min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 20px) 22px calc(var(--safe-b) + 20px);
  gap: 26px;
}
.login .wave { width: 64px; height: 64px; border-radius: 20px; background: linear-gradient(145deg, var(--acc), #5b3fe0); box-shadow: 0 16px 40px -14px rgba(124, 92, 255, .9); display: grid; place-items: center; }
.login .wave svg { width: 32px; height: 32px; stroke: #fff; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.login h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em; text-align: center; }
.login p { margin: -16px 0 0; color: var(--dim); font-size: 13.5px; text-align: center; }
.dots { display: flex; gap: 14px; height: 14px; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 1.6px solid #3a3a48; transition: all .18s ease; }
.dot.on { background: var(--acc); border-color: var(--acc); transform: scale(1.08); }
.pad { display: grid; grid-template-columns: repeat(3, 78px); gap: 14px; }
.pad button {
  height: 62px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line);
  font-size: 22px; font-weight: 600;
  display: grid; place-items: center;
  transition: background .12s ease;
  font-variant-numeric: tabular-nums;
}
.pad button:active { background: var(--card-2); }
.pad button.blank { background: none; border: 0; pointer-events: none; }
.pad button svg { width: 23px; height: 23px; stroke: var(--txt); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.login .err { color: var(--err); font-size: 13px; font-weight: 550; height: 16px; margin-top: -10px; }
.shake { animation: shake .32s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

/* ---------------------------------------------------------------- Sheet */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(3px);
  animation: fade .18s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  background: #13131a;
  border-radius: 26px 26px 0 0;
  border-top: 1px solid rgba(255, 255, 255, .07);
  padding: 10px var(--pad) calc(var(--safe-b) + 18px);
  animation: up .26s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.grabber { width: 38px; height: 4px; border-radius: 4px; background: #33333f; margin: 0 auto 16px; }
.sheet .picked { display: flex; gap: 13px; align-items: center; margin-bottom: 18px; }
.sheet .picked .thumb { width: 56px; height: 56px; aspect-ratio: auto; border-radius: 12px; flex: none; }
.sheet .picked .t { font-size: 14.5px; font-weight: 650; line-height: 1.3; }
.sheet .picked .s { font-size: 12px; color: var(--dim); margin-top: 3px; }
.sheet .picked .pbody { min-width: 0; }
.sheet .ask { font-size: 13px; color: var(--dim); margin: 0 0 14px; line-height: 1.5; }
.sheet .ask b { color: var(--txt); }
.sheet .btns { display: flex; flex-direction: column; gap: 9px; }

/* ---------------------------------------------------------------- Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 22px);
  transform: translate(-50%, 30px);
  z-index: 90;
  padding: 13px 20px;
  border-radius: 14px;
  background: #1c2a23;
  border: 1px solid rgba(52, 211, 153, .3);
  color: #d1fae5;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .24s cubic-bezier(.2, .9, .3, 1);
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #2b1a1a; border-color: rgba(248, 113, 113, .32); color: #fecaca; }

.skel { background: linear-gradient(100deg, #16161e 30%, #1f1f2a 50%, #16161e 70%); background-size: 220% 100%; animation: sheen 1.3s infinite; }
@keyframes sheen { from { background-position: 180% 0; } to { background-position: -40% 0; } }
.skel-card .thumb { border: 0; }
.skel-card .bar { height: 11px; border-radius: 6px; }
.skel-card .bar.w1 { width: 88%; }
.skel-card .bar.w2 { width: 52%; opacity: .6; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}
