:root {
  --bg: #F6F1E9;
  --surface: #FFFFFF;
  --ink: #1F1A14;
  --muted: #6E655A;
  --line: #E6DDD0;
  --accent: #A3412A;
  --accent-ink: #FFFFFF;
  --accent-soft: #F4E4DB;
  --range: rgba(163, 65, 42, .18);
  --danger: #B42318;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --h-ctl: 48px;
  --fs-sm: 14px; --fs-md: 16px; --fs-lg: 20px; --fs-xl: 30px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --dur: 180ms;
  color-scheme: light;
}
/* Standard ist hell; dunkel nur, wenn man es oben rechts einschaltet */
:root[data-theme="dark"] {
  --bg: #15120E; --surface: #1F1B16; --ink: #F3EDE4; --muted: #A69C8F; --line: #322B23;
  --accent: #E2805E; --accent-ink: #1A0F0A; --accent-soft: #3A251C; --range: rgba(226, 128, 94, .22);
  --danger: #F97066;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 var(--fs-md)/1.5 Inter, ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.wrap { max-width: 720px; margin: 0 auto; padding: var(--s-5) var(--s-4) var(--s-7); }

/* Kopf */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-6); }
.brand { display: inline-flex; align-items: center; gap: var(--s-2); text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: var(--fs-lg); letter-spacing: -.01em; }
.brand-ar { font-size: var(--fs-sm); color: var(--muted); font-family: "Noto Naskh Arabic", "Geeza Pro", serif; }
.top-ctl { display: inline-flex; align-items: center; gap: var(--s-2); }
.theme-btn { width: 38px; height: 38px; border-radius: 999px; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); }
.lang button { border: 0; background: none; color: var(--muted); font: 600 13px/1 inherit; font-family: inherit; padding: 7px 10px; border-radius: 999px; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* Typo */
h1 { font-size: var(--fs-xl); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 var(--s-2); }
.lead { color: var(--muted); margin: 0 0 var(--s-5); font-size: var(--fs-md); }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 var(--s-2); }

/* Karten + Felder */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); }
.card + .card, .card + .section, .section + .card { margin-top: var(--s-4); }
label.field { display: block; margin-bottom: var(--s-4); }
label.field > span { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--s-2); }
input[type=text], input[type=url], textarea {
  width: 100%; min-height: var(--h-ctl); padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); color: var(--ink);
  font: inherit; outline: none; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--range); }
.row { display: flex; gap: var(--s-2); }
.row > input { flex: 1; }

/* Knöpfe */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--h-ctl); padding: 0 var(--s-5); border-radius: var(--r-md); border: 1px solid transparent;
  font: 600 var(--fs-md)/1 inherit; font-family: inherit; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur);
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-sm { min-height: 36px; padding: 0 var(--s-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btns { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.btns > .btn { flex: 1 1 auto; }

.error { color: var(--danger); font-size: var(--fs-sm); font-weight: 500; margin: var(--s-2) 0 0; min-height: 1em; }
.hint { color: var(--muted); font-size: var(--fs-sm); margin: var(--s-2) 0 0; }

/* Player */
.player { position: relative; aspect-ratio: 16/9; border-radius: var(--r-md); overflow: hidden; background: #000; }
.player iframe, .player > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.source { display: flex; gap: var(--s-2); align-items: baseline; margin: var(--s-3) 0 0; color: var(--muted); font-size: var(--fs-sm); }
.source strong { color: var(--ink); font-weight: 600; }

/* Zeitleiste */
.timeline { margin: var(--s-5) 0 var(--s-4); user-select: none; touch-action: none; }
.track { position: relative; height: 44px; border-radius: var(--r-sm); background: var(--bg); border: 1px solid var(--line); cursor: pointer; }
.track .sel { position: absolute; top: 0; bottom: 0; background: var(--range); border-left: 2px solid var(--accent); border-right: 2px solid var(--accent); }
.track .head { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); margin-left: -1px; pointer-events: none; }
.handle { position: absolute; top: 50%; width: 22px; height: 52px; margin: -26px 0 0 -11px; border-radius: 8px; background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.25); cursor: ew-resize; display: grid; place-items: center; }
.handle::after { content: ""; width: 2px; height: 18px; border-radius: 2px; background: var(--accent-ink); opacity: .8; }
.handle:focus-visible { outline: 3px solid var(--range); outline-offset: 2px; }
.scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: var(--s-2); font-variant-numeric: tabular-nums; }

.ends { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.end { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-3); background: var(--bg); }
.end-label { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.end-time { width: 100%; border: 0; background: none; padding: var(--s-1) 0; min-height: 0; font: 700 26px/1.2 inherit; font-family: inherit; color: var(--ink); font-variant-numeric: tabular-nums; box-shadow: none !important; }
.end-ctl { display: flex; gap: var(--s-1); margin-top: var(--s-2); }
.end-ctl .btn { flex: 1; padding: 0 var(--s-2); }
.end-ctl .btn-set { flex: 2; }
.length { text-align: center; margin: var(--s-4) 0; font-size: var(--fs-sm); color: var(--muted); }
.length strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* Ergebnis */
.result { text-align: center; }
.result .ok { width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto var(--s-3); }
.result .ok svg { width: 26px; height: 26px; }
.linkbox { display: flex; align-items: center; gap: var(--s-2); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4); margin: var(--s-4) 0; }
.linkbox code { flex: 1; text-align: left; font: 600 var(--fs-md)/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Liste */
.section { margin-top: var(--s-6); }
.section h2 { font-size: var(--fs-lg); margin: 0 0 var(--s-3); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.item { display: flex; align-items: center; gap: var(--s-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-2); }
.item img { width: 96px; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--r-sm); flex: none; background: var(--bg); }
.item .main { flex: 1; min-width: 0; text-decoration: none; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .m { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--muted); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 18px; height: 18px; }
.empty { color: var(--muted); font-size: var(--fs-sm); border: 1px dashed var(--line); border-radius: var(--r-md); padding: var(--s-4); text-align: center; }

/* Clip-Seite */
.clip-title { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: var(--s-4) 0 var(--s-2); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; padding: 6px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-variant-numeric: tabular-nums; }
.chip svg { width: 15px; height: 15px; }
.chip.neutral { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.note { white-space: pre-wrap; margin: var(--s-4) 0 0; padding: var(--s-4); background: var(--bg); border-radius: var(--r-md); border: 1px solid var(--line); }
.progress { height: 6px; border-radius: 3px; background: var(--line); margin-top: var(--s-3); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.done { display: none; text-align: center; margin-top: var(--s-3); }
.done.show { display: block; }

.foot { margin-top: var(--s-7); text-align: center; color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

.reveal { animation: none; }
@starting-style { .reveal { opacity: 0; transform: translateY(8px); } }
.reveal { transition: opacity 260ms var(--ease), transform 260ms var(--ease); }

@media (max-width: 520px) {
  h1 { font-size: 26px; }
  .card { padding: var(--s-4); }
  .end-time { font-size: 22px; }
  .row { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Download-Knöpfe */
.dl-box { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--line); }
.dl { position: relative; overflow: hidden; }
.dl.dl-busy[disabled] { opacity: 1; cursor: progress; }
.dl.dl-busy::before { content: ""; position: absolute; inset: 0; width: var(--p, 0%); background: var(--range); transition: width .4s linear; }
.dl > * { position: relative; }

/* Upload */
.or { display: flex; align-items: center; gap: var(--s-3); color: var(--muted); font-size: var(--fs-sm); margin: var(--s-3) 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.upload-btn { position: relative; overflow: hidden; cursor: pointer; }
.upload-btn.dl-busy { pointer-events: none; }
.upload-btn.dl-busy::before { content: ""; position: absolute; inset: 0; width: var(--p, 0%); background: var(--range); transition: width .3s linear; }
.upload-btn > * { position: relative; }

/* Player für Dateien */
.player video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.player.player-audio { aspect-ratio: auto; background: var(--accent-soft); padding: var(--s-6) var(--s-4) var(--s-4); display: grid; gap: var(--s-4); justify-items: center; }
.player.player-audio audio { position: static; width: 100%; height: 44px; }
.audio-art { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.audio-art svg { width: 28px; height: 28px; }
.thumb-ph { width: 96px; aspect-ratio: 16/9; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.thumb-ph svg { width: 20px; height: 20px; }

/* YouTube: Befehl für den eigenen Mac */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); margin-bottom: var(--s-3); }
.seg-btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 40px; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); font: 600 var(--fs-sm)/1 inherit; font-family: inherit; cursor: pointer; }
.seg-btn svg { width: 16px; height: 16px; flex: none; }
@media (max-width: 420px) { .seg-btn { font-size: 13px; gap: 6px; } }
.seg-btn[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.cmd { background: #1F1A14; color: #F3EDE4; border-radius: var(--r-md); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-3); overflow-x: auto; }
.cmd code { font: 500 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; }
.steps { margin: var(--s-4) 0; padding-left: 20px; color: var(--muted); font-size: var(--fs-sm); display: grid; gap: var(--s-1); }
.once { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-3); }
.once summary { cursor: pointer; font-weight: 600; font-size: var(--fs-sm); }
.once[open] summary { margin-bottom: var(--s-3); }
.note-private { display: flex; gap: var(--s-2); align-items: flex-start; font-size: var(--fs-sm); color: var(--ink); background: var(--accent-soft); border-radius: var(--r-md); padding: var(--s-3); margin: 0; }
.note-private svg { width: 18px; height: 18px; flex: none; color: var(--accent); margin-top: 1px; }

/* Listen: Einträge dürfen nie breiter als der Bildschirm werden */
.list { grid-template-columns: minmax(0, 1fr); }
.list > li { min-width: 0; }
.item .t { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.item .btn-sm { flex: none; }
.lib-open { border: 0; background: none; padding: 0; text-align: start; font: inherit; color: inherit; cursor: pointer; }
.icon-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
