/* ============================================================
   Videoarchiv — DITIB Nürnberg design system
   (shared with the Lecture Quiz app: maroon #911915, crimson
   #A10F2B, dark #222222, warm white, gold as quiet accent)
   ============================================================ */
:root {
  --bg: #F6F4F1;
  --card: #FFFFFF;
  --line: #E4DED8;
  --ink: #222222;
  --muted: #6D6560;
  --petrol: #911915;
  --petrol-2: #A10F2B;
  --red-2: #6E100D;
  --gold-deep: #8F721A;
  --shadow-sm: 0 1px 2px rgba(21, 36, 44, 0.06), 0 2px 10px rgba(21, 36, 44, 0.05);
  --shadow-md: 0 2px 6px rgba(21, 36, 44, 0.07), 0 10px 28px rgba(21, 36, 44, 0.09);
  --shadow-lg: 0 8px 24px rgba(21, 36, 44, 0.14), 0 24px 64px rgba(21, 36, 44, 0.14);
  --radius: 16px;
  --font-ui: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-arabic: "Amiri", "Times New Roman", serif;
  --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);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background-color: var(--bg);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><g fill='none' stroke='%23911915' stroke-opacity='0.04' stroke-width='1.5'><rect x='54' y='54' width='52' height='52'/><rect x='54' y='54' width='52' height='52' transform='rotate(45 80 80)'/><circle cx='80' cy='80' r='10'/></g></svg>");
  color: var(--ink);
  font: 16px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
a, button, label { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: var(--petrol-2); text-decoration: none; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: 30px; letter-spacing: -0.01em; margin: 6px 0 8px; color: var(--petrol); line-height: 1.2; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------- buttons & inputs ---------------- */
button {
  background: linear-gradient(135deg, #A10F2B, #7E1410);
  color: #fff; border: 0; border-radius: 12px;
  padding: 11px 20px; font-size: 15px; font-weight: 800; letter-spacing: 0.2px;
  font-family: inherit;
  cursor: pointer; transition: transform .06s ease, filter .15s ease, box-shadow .15s ease;
  min-height: 44px;
  box-shadow: 0 2px 8px rgba(110, 16, 13, 0.25);
}
button:hover { filter: brightness(1.07); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.55; cursor: progress; filter: none; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(161, 15, 43, 0.35); outline-offset: 2px; }
button.big { padding: 14px 28px; font-size: 16px; border-radius: 14px; min-height: 52px; }

input[type="password"], input[type="text"], input[type="url"], input[type="number"], input[type="date"] {
  width: 100%;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 52px 14px 15px; font-size: 17px; font-family: inherit;
  outline: none; min-width: 0; min-height: 52px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--petrol-2); box-shadow: 0 0 0 3px rgba(161, 15, 43, 0.14); }

/* ---------------- lock screen ---------------- */
.lock {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: calc(24px + var(--safe-t)) calc(20px + var(--safe-r)) calc(24px + var(--safe-b)) calc(20px + var(--safe-l));
}
.lock-card {
  width: 100%; max-width: 400px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 30px 24px 26px;
  box-shadow: var(--shadow-lg);
  text-align: center; position: relative;
  display: flex; flex-direction: column; gap: 14px;
}
.lock-card::before {
  content: ""; position: absolute; top: -1px; left: 28px; right: 28px; height: 3px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, var(--petrol), rgba(145, 25, 21, 0.08));
}
.lock-card h1 { margin: 0; }
.lock-card p { margin: 0 0 6px; font-size: 14.5px; }
.logo {
  width: 72px; height: 72px; margin: 0 auto 2px;
  display: grid; place-items: center; border-radius: 20px;
  background: linear-gradient(160deg, #A10F2B 0%, #6E100D 100%);
  box-shadow: 0 6px 18px rgba(110, 16, 13, 0.35);
}
.bismillah { font-family: var(--font-arabic); font-size: 20px; color: var(--gold-deep); letter-spacing: 0.5px; }

.field { position: relative; display: block; }
.icon-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; min-height: 44px; padding: 0;
  display: grid; place-items: center;
  background: transparent; color: var(--muted); box-shadow: none; border-radius: 10px;
}
.icon-btn:active { transform: translateY(-50%) scale(0.94); }
.icon-btn[aria-pressed="true"] { color: var(--petrol); }

.check {
  display: flex; align-items: center; gap: 10px; justify-content: flex-start;
  text-align: left; font-size: 14.5px; color: var(--muted); cursor: pointer;
  min-height: 44px;
}
.check input { width: 20px; height: 20px; accent-color: var(--petrol); margin: 0; flex: none; }

.error { margin: 0; color: var(--petrol-2); font-weight: 700; font-size: 14.5px; }
.shake { animation: shake .38s ease; }
@keyframes shake {
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

/* ---------------- top bar ---------------- */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) 10px calc(16px + var(--safe-l));
  background: linear-gradient(180deg, #7E1410 0%, #5C0D0A 100%);
  border-bottom: 2px solid #A10F2B;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 4px 18px rgba(92, 13, 10, 0.25);
}
.brand { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 800; font-size: 17px; letter-spacing: 0.2px; }
#edit-btn { margin-left: auto; }
.topbar-btn {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 7px 13px; font-size: 13.5px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff; box-shadow: none;
}
.topbar-btn[aria-pressed="true"] { background: #fff; color: var(--petrol); border-color: #fff; }
@media (max-width: 420px) {
  .topbar-btn { width: 40px; height: 40px; min-height: 40px; padding: 0; justify-content: center; }
  .topbar-btn span { display: none; }
}

/* ---------------- archive ---------------- */
#view {
  max-width: 1180px; margin: 0 auto;
  padding: 22px calc(16px + var(--safe-r)) calc(48px + var(--safe-b)) calc(16px + var(--safe-l));
}

/* sort control bar */
#toolbar {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px calc(16px + var(--safe-r)) 0 calc(16px + var(--safe-l));
}
.sort-ctl {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 800; color: var(--muted);
}
.sort-ctl svg { color: var(--muted); }
#sort {
  width: auto; min-height: 40px; padding: 8px 34px 8px 12px; font-size: 14px; font-weight: 700;
  border-radius: 999px; background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'><path fill='%236D6560' d='M6 9l6 6 6-6z'/></svg>") no-repeat right 12px center;
  -webkit-appearance: none; appearance: none;
}
#sort:focus { border-color: var(--petrol-2); box-shadow: 0 0 0 3px rgba(161, 15, 43, 0.14); }

.season-head {
  display: flex; align-items: center; gap: 12px;
  margin: 6px 2px 18px;
}
.season-head:first-child { margin-top: 0; }
.season-head h2 {
  font-family: var(--font-display); font-size: 25px; font-weight: 700;
  color: var(--petrol-2); margin: 0; letter-spacing: 0.2px;
}
.season-head::after {
  content: ""; flex: 1; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(145, 25, 21, 0.35), rgba(145, 25, 21, 0));
}
.series { margin-bottom: 30px; }
.series-head { display: flex; align-items: baseline; gap: 10px; margin: 0 2px 14px; }
.series-head h2 { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--petrol); margin: 0; line-height: 1.25; }
.series-head .count {
  font-size: 12px; font-weight: 800; color: var(--gold-deep);
  background: #FBF4DC; border: 1px solid #DCC98B; border-radius: 999px; padding: 2px 9px;
  white-space: nowrap;
}
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.video {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.player { position: relative; aspect-ratio: 16 / 9; background: #1a0605; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.noembed {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 18px; text-align: center;
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(161, 15, 43, 0.28), rgba(26, 6, 5, 0.9) 70%),
    #1a0605;
}
.noembed p { margin: 0; color: #E9DAD8; font-size: 13.5px; line-height: 1.45; max-width: 34ch; }
.noembed a {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  font-size: 14px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #A10F2B, #7E1410);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.thumb {
  position: absolute; inset: 0; width: 100%; height: 100%;
  padding: 0; border-radius: 0; background: #1a0605; box-shadow: none; min-height: 0;
  overflow: hidden;
}
.thumb:active { transform: none; filter: brightness(0.92); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 45%, rgba(40, 6, 5, 0.55) 100%);
}
.play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1;
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center; padding-left: 3px;
  background: linear-gradient(135deg, rgba(161, 15, 43, 0.95), rgba(110, 16, 13, 0.95));
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  transition: transform .15s ease;
}
.thumb:hover .play { transform: translate(-50%, -50%) scale(1.06); }
.part {
  position: absolute; left: 12px; bottom: 10px; z-index: 1;
  color: #fff; font-weight: 800; font-size: 13px; letter-spacing: 0.3px;
  background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px; padding: 3px 10px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

.meta { display: flex; align-items: center; gap: 12px; padding: 13px 14px 14px 16px; }
.meta .text { flex: 1; min-width: 0; }
.meta h3 { margin: 0; font-size: 15.5px; font-weight: 800; line-height: 1.3; color: var(--ink); }
.meta time { font-size: 13.5px; color: var(--muted); }
.yt {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 14px; border-radius: 12px;
  font-size: 13.5px; font-weight: 800; color: var(--petrol);
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.yt:hover { background: #F7ECEA; text-decoration: none; }
.yt:active { transform: scale(0.97); }

.footer-note { text-align: center; font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ---------------- busy overlay ---------------- */
.busy {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(246, 244, 241, 0.6);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid rgba(145, 25, 21, 0.15); border-top-color: var(--petrol);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- edit mode ---------------- */
.edit-video {
  display: none; flex: none;
  width: 44px; height: 44px; min-height: 44px; padding: 0; place-items: center;
  background: #fff; color: var(--petrol); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.editing .edit-video { display: grid; }
.editing .yt { display: none; }
.editing .video { outline: 2px dashed rgba(145, 25, 21, 0.25); outline-offset: 3px; }
.editing #view { padding-bottom: calc(110px + var(--safe-b)); }

.fab {
  position: fixed; z-index: 60;
  right: calc(18px + var(--safe-r)); bottom: calc(18px + var(--safe-b));
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 0 22px 0 18px; border-radius: 999px; font-size: 15.5px;
  box-shadow: 0 8px 24px rgba(110, 16, 13, 0.4);
}

.empty { text-align: center; padding: 48px 12px; }

/* ---------------- sheets (dialogs) ---------------- */
.sheet {
  border: 0; padding: 0; color: var(--ink); background: var(--card);
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  border-radius: 22px; box-shadow: var(--shadow-lg);
}
.sheet::backdrop { background: rgba(34, 14, 12, 0.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.sheet form { display: flex; flex-direction: column; gap: 14px; padding: 20px 20px 22px; }
.sheet p { margin: 0; font-size: 14.5px; }
@media (max-width: 639px) {
  .sheet {
    width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92dvh;
    border-radius: 22px 22px 0 0;
  }
  .sheet form { padding-bottom: calc(22px + var(--safe-b)); }
  .sheet[open] { animation: sheetUp .22s ease-out; }
}
@keyframes sheetUp { from { transform: translateY(60px); } }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.sheet-head h2 { flex: 1; margin: 0; font-family: var(--font-display); font-size: 22px; color: var(--petrol); }
.icon-btn.close { position: static; transform: none; margin-right: -8px; }
.icon-btn.close:active { transform: scale(0.94); }

.lbl { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 800; color: var(--muted); text-align: left; }
.lbl input { padding-right: 15px; }
.lbl .opt { font-weight: 600; opacity: 0.75; }
.row-2 { display: grid; grid-template-columns: 1fr 1.6fr; gap: 12px; }
.row-2 input[type="date"] { -webkit-appearance: none; appearance: none; }

.preview {
  display: flex; gap: 12px; align-items: center;
  padding: 8px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line);
}
.preview img { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; flex: none; background: #1a0605; }
.preview span { font-size: 13.5px; line-height: 1.35; }

.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.sheet-actions .big { flex: 1; }
.danger-outline { background: #fff; color: var(--petrol-2); border: 1px solid #E8C4C9; box-shadow: none; }
.danger-outline:hover { background: #FBEDEF; }

.toast {
  position: fixed; z-index: 120; left: 50%; transform: translateX(-50%);
  bottom: calc(90px + var(--safe-b));
  background: #2A1210; color: #fff; font-weight: 700; font-size: 14.5px;
  padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 32px); text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
