:root {
  color-scheme: dark;

  --bg: #090d0b;
  --bg-deep: #060907;
  --surface: rgba(21, 28, 24, 0.88);
  --surface-solid: #151c18;
  --surface-raised: #1a231e;
  --surface-soft: #202b24;
  --text: #f2f7f3;
  --text-soft: #c8d4cc;
  --muted: #8fa096;
  --faint: #64756b;
  --line: rgba(193, 221, 203, 0.13);
  --line-strong: rgba(193, 221, 203, 0.24);
  --accent: #83e6ad;
  --accent-bright: #a0f4c2;
  --accent-deep: #47b77a;
  --accent-ink: #07150d;
  --accent-glow: rgba(97, 222, 151, 0.22);
  --danger: #ff8d8d;
  --danger-soft: rgba(255, 111, 111, 0.12);
  --warning: #f3c777;
  --warning-soft: rgba(243, 199, 119, 0.11);
  --info: #91c9ff;
  --info-soft: rgba(115, 182, 255, 0.11);

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-xl: 34px;

  --shadow-soft: 0 18px 50px rgba(0, 0, 0, 0.28);
  --shadow-card: 0 12px 34px rgba(0, 0, 0, 0.24);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --font-display: "Avenir Next", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --font-body: "Avenir Next", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

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

html {
  background: var(--bg-deep);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% -10%, rgba(76, 191, 128, 0.16), transparent 34rem),
    radial-gradient(circle at 94% 7%, rgba(73, 125, 97, 0.12), transparent 31rem),
    linear-gradient(180deg, #0c120e 0%, var(--bg) 38%, var(--bg-deep) 100%);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.014) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
  content: "";
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled),
[role="button"]:not([aria-disabled="true"]) {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

img {
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3,
strong {
  font-family: var(--font-display);
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

::selection {
  background: rgba(131, 230, 173, 0.3);
  color: var(--text);
}

.app-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 max(18px, var(--safe-right)) calc(28px + var(--safe-bottom))
    max(18px, var(--safe-left));
}

/* -------------------------------------------------------------------------- */
/* Header                                                                     */
/* -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 calc(-1 * max(18px, var(--safe-right))) 0
    calc(-1 * max(18px, var(--safe-left)));
  padding: calc(10px + var(--safe-top)) max(18px, var(--safe-right)) 10px
    max(18px, var(--safe-left));
  border-bottom: 1px solid transparent;
  background: linear-gradient(180deg, rgba(9, 13, 11, 0.9), rgba(9, 13, 11, 0.66));
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 1px solid rgba(145, 241, 184, 0.3);
  border-radius: 13px;
  background:
    radial-gradient(circle at 32% 20%, rgba(176, 255, 208, 0.3), transparent 50%),
    linear-gradient(145deg, #164b2d, #0b2317);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 8px 24px rgba(33, 135, 79, 0.24);
  color: var(--accent-bright);
}

.brand-mark svg {
  width: 27px;
  height: 27px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.04;
}

.brand-copy strong {
  font-size: 1.08rem;
  letter-spacing: 0.01em;
}

.brand-copy small {
  margin-top: 5px;
  color: var(--faint);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid rgba(131, 230, 173, 0.2);
  border-radius: 999px;
  background: rgba(131, 230, 173, 0.08);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill svg {
  width: 14px;
  height: 14px;
}

.status-pill.offline {
  border-color: rgba(243, 199, 119, 0.2);
  background: var(--warning-soft);
  color: var(--warning);
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-soft);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.icon-button:active {
  transform: scale(0.95);
}

.icon-button.subtle {
  width: 38px;
  height: 38px;
  background: transparent;
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

/* -------------------------------------------------------------------------- */
/* Main layout                                                                */
/* -------------------------------------------------------------------------- */

.main-content {
  display: grid;
  gap: 22px;
  padding-top: clamp(30px, 6vw, 66px);
}

.hero {
  max-width: 740px;
  padding: 2px 2px 5px;
}

.eyebrow,
.section-kicker {
  color: var(--accent);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
}

.eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(131, 230, 173, 0.1);
  animation: pulse 2.8s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 5px rgba(131, 230, 173, 0.1);
  }
  50% {
    box-shadow: 0 0 0 9px rgba(131, 230, 173, 0.015);
  }
}

.hero h1 {
  max-width: 700px;
  font-size: clamp(2.5rem, 8.6vw, 5.1rem);
  font-weight: 700;
  letter-spacing: -0.06em;
  line-height: 0.96;
}

.hero h1 span {
  background: linear-gradient(100deg, var(--accent-bright), #83c9aa 58%, #8ea99a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-copy {
  max-width: 560px;
  margin-top: 19px;
  color: var(--muted);
  font-size: clamp(0.96rem, 2.4vw, 1.08rem);
  line-height: 1.68;
}

/* -------------------------------------------------------------------------- */
/* Ingest card                                                                */
/* -------------------------------------------------------------------------- */

.ingest-card,
.storage-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.045), transparent 42%),
    var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.ingest-card {
  overflow: hidden;
  padding: clamp(18px, 5vw, 30px);
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.card-heading h2,
.library-heading h2,
.storage-heading h2 {
  margin-top: 4px;
  font-size: clamp(1.25rem, 3.5vw, 1.6rem);
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.card-heading-icon {
  display: grid;
  width: 45px;
  height: 45px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(131, 230, 173, 0.15);
  border-radius: 15px;
  background: rgba(131, 230, 173, 0.07);
  color: var(--accent);
}

.card-heading-icon svg {
  width: 21px;
  height: 21px;
}

.url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

.input-wrap {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
}

.input-wrap > svg {
  position: absolute;
  left: 15px;
  width: 18px;
  height: 18px;
  color: var(--faint);
  pointer-events: none;
}

.input-wrap input {
  width: 100%;
  min-height: 52px;
  padding: 13px 14px 13px 43px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  background: rgba(4, 8, 6, 0.45);
  color: var(--text);
  font-size: 0.95rem;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.input-wrap input::placeholder {
  color: #5d6d63;
}

.input-wrap input:focus {
  border-color: rgba(131, 230, 173, 0.55);
  background: rgba(4, 8, 6, 0.68);
  box-shadow: 0 0 0 4px rgba(131, 230, 173, 0.09);
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 17px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.2;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.button:active:not(:disabled) {
  transform: scale(0.975);
}

.button-primary {
  border-color: rgba(179, 255, 211, 0.22);
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  box-shadow:
    0 8px 24px rgba(68, 184, 119, 0.19),
    inset 0 1px 0 rgba(255, 255, 255, 0.54);
  color: var(--accent-ink);
}

.button-primary:hover {
  background: linear-gradient(180deg, #b9ffd4, #91eeb8);
}

.button-secondary {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}

.button-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.button-danger {
  background: linear-gradient(180deg, #ff9b9b, #f57d7d);
  color: #260909;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.37);
}

.button-danger-ghost {
  border-color: rgba(255, 141, 141, 0.18);
  background: rgba(255, 111, 111, 0.055);
  color: var(--danger);
}

.button-danger-ghost:hover {
  background: rgba(255, 111, 111, 0.11);
}

.button-small {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
}

.button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.download-button {
  min-width: 148px;
}

.spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fetch-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

.fetch-status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(131, 230, 173, 0.08);
  content: "";
}

.inline-error {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 141, 141, 0.16);
  border-radius: 10px;
  background: var(--danger-soft);
  color: #ffc0c0;
  font-size: 0.84rem;
}

/* Metadata preview -------------------------------------------------------- */

.metadata-preview {
  display: grid;
  grid-template-columns: minmax(0, 155px) minmax(0, 1fr);
  gap: clamp(15px, 3vw, 24px);
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  animation: reveal 320ms ease both;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.preview-art {
  position: relative;
  align-self: start;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, #1c4e31, #0b2014 70%);
}

.preview-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-art img:not([src]),
.preview-art img.is-broken {
  display: none;
}

.preview-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 26% 15%, rgba(169, 255, 204, 0.21), transparent 52%),
    linear-gradient(145deg, #1a4a2e, #0a1c12);
  color: rgba(229, 255, 240, 0.72);
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 700;
  text-transform: uppercase;
}

.duration-chip {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.66);
  color: #ecf5ef;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.02em;
  backdrop-filter: blur(5px);
}

.preview-copy {
  min-width: 0;
}

.preview-topline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 2px 7px;
  border: 1px solid rgba(131, 230, 173, 0.16);
  border-radius: 6px;
  background: rgba(131, 230, 173, 0.08);
  color: var(--accent);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
}

.preview-copy h3 {
  display: -webkit-box;
  margin-top: 8px;
  overflow: hidden;
  font-size: clamp(1.02rem, 3.2vw, 1.35rem);
  letter-spacing: -0.025em;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.preview-channel {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  gap: 3px;
  margin-top: 15px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(4, 8, 6, 0.35);
}

.segmented button {
  display: inline-flex;
  min-height: 33px;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
  transition:
    background 150ms ease,
    color 150ms ease;
}

.segmented button svg {
  width: 15px;
  height: 15px;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface-soft);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 2px 6px rgba(0, 0, 0, 0.19);
  color: var(--text);
}

.preview-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.select-label {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 5px;
  color: var(--faint);
  font-size: 0.67rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.select-label select,
.field-label select {
  width: 100%;
  min-height: 44px;
  padding: 9px 34px 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background-color: rgba(4, 8, 6, 0.55);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
}

.select-label select:focus,
.field-label select:focus {
  border-color: rgba(131, 230, 173, 0.5);
  box-shadow: 0 0 0 4px rgba(131, 230, 173, 0.08);
}

.download-hint {
  margin-top: 11px;
  color: var(--muted);
  font-size: 0.8rem;
}

.download-hint.error {
  color: var(--danger);
}

.download-hint.success {
  color: var(--accent);
}

/* -------------------------------------------------------------------------- */
/* Banners                                                                    */
/* -------------------------------------------------------------------------- */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.banner-warning {
  border-color: rgba(243, 199, 119, 0.18);
  background:
    linear-gradient(130deg, rgba(243, 199, 119, 0.07), transparent 55%),
    var(--surface);
}

.banner-info {
  border-color: rgba(115, 182, 255, 0.17);
  background:
    linear-gradient(130deg, rgba(115, 182, 255, 0.075), transparent 55%),
    var(--surface);
}

.banner-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  background: var(--warning-soft);
  color: var(--warning);
}

.banner-info .banner-icon {
  background: var(--info-soft);
  color: var(--info);
}

.banner-icon svg {
  width: 19px;
  height: 19px;
}

.banner-copy {
  min-width: 0;
  flex: 1;
}

.banner-copy strong {
  display: block;
  font-size: 0.92rem;
}

.banner-copy p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

/* -------------------------------------------------------------------------- */
/* Library                                                                    */
/* -------------------------------------------------------------------------- */

.library {
  padding-top: 8px;
}

.library-heading,
.storage-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 19px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(4, 8, 6, 0.28);
}

.tab {
  min-height: 32px;
  padding: 5px 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 750;
  transition:
    background 150ms ease,
    color 150ms ease;
}

.tab.is-active {
  background: var(--surface-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.item-count {
  color: var(--faint);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  white-space: nowrap;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 13px;
  margin-top: 16px;
}

.media-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition:
    border-color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

.media-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.31);
  transform: translateY(-2px);
}

.media-card:active {
  transform: scale(0.99);
}

.media-card:focus-visible {
  outline-offset: 2px;
}

.card-art {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background:
    radial-gradient(circle at 25% 10%, rgba(129, 224, 169, 0.21), transparent 52%),
    linear-gradient(145deg, #1b4930, #0a1c12 75%);
}

.media-card.is-audio .card-art {
  background:
    radial-gradient(circle at 78% 18%, rgba(96, 160, 255, 0.2), transparent 45%),
    radial-gradient(circle at 18% 90%, rgba(131, 230, 173, 0.14), transparent 48%),
    linear-gradient(145deg, #24354a, #0f1b25 70%);
}

.card-thumb {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms ease;
}

.media-card:hover .card-thumb {
  transform: scale(1.025);
}

.card-thumb.is-broken,
.card-thumb:not([src]) {
  display: none;
}

.card-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(226, 255, 239, 0.68);
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 700;
  text-transform: uppercase;
}

.media-card.has-image .card-fallback {
  display: none;
}

.card-type-badge {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 7px;
  background: rgba(4, 9, 6, 0.61);
  color: #eafff2;
  backdrop-filter: blur(6px);
}

.card-type-badge svg {
  width: 14px;
  height: 14px;
}

.card-duration {
  position: absolute;
  z-index: 2;
  right: 8px;
  bottom: 8px;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.67);
  color: #f2f7f3;
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.card-actions {
  position: absolute;
  z-index: 3;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 150ms ease;
}

.media-card:hover .card-actions,
.media-card:focus-within .card-actions {
  opacity: 1;
}

.card-action {
  display: grid;
  width: 29px;
  height: 29px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(4, 9, 6, 0.7);
  color: #f4fbf6;
  backdrop-filter: blur(6px);
}

.card-action svg {
  width: 14px;
  height: 14px;
}

.card-delete:hover {
  color: var(--danger);
}

.card-play {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(5, 12, 8, 0.58);
  box-shadow: 0 8px 21px rgba(0, 0, 0, 0.24);
  color: #f4fff8;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.9);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    background 160ms ease;
  backdrop-filter: blur(8px);
}

.card-play svg {
  width: 19px;
  height: 19px;
  margin-left: 2px;
}

.media-card:hover .card-play,
.media-card:focus-within .card-play {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.card-progress {
  position: absolute;
  z-index: 4;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.46);
}

.card-progress-fill {
  width: 0;
  height: 100%;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  transition: width 220ms ease;
}

.media-card.is-failed {
  border-color: rgba(255, 141, 141, 0.18);
}

.media-card.is-downloading .card-play,
.media-card.is-queued .card-play {
  display: none;
}

.card-copy {
  padding: 10px 11px 12px;
}

.card-title {
  display: -webkit-box;
  min-height: 2.48em;
  overflow: hidden;
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: -0.012em;
  line-height: 1.24;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-channel {
  margin-top: 4px;
  overflow: hidden;
  color: var(--faint);
  font-size: 0.69rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
}

.card-status {
  overflow: hidden;
  max-width: 60%;
  color: var(--faint);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.is-downloading .card-status {
  color: var(--accent);
}

.is-failed .card-status {
  color: var(--danger);
}

.is-queued .card-status {
  color: var(--warning);
}

.empty-state {
  display: flex;
  min-height: 245px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.012);
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 15px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--faint);
}

.empty-icon svg {
  width: 23px;
  height: 23px;
}

.empty-state h3 {
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.empty-state p {
  max-width: 330px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

/* -------------------------------------------------------------------------- */
/* Storage card                                                               */
/* -------------------------------------------------------------------------- */

.storage-card {
  padding: 18px;
}

.storage-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.storage-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.storage-icon svg {
  width: 19px;
  height: 19px;
}

.storage-heading h2 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.87rem;
  font-weight: 750;
  letter-spacing: 0;
}

.storage-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.text-button {
  padding: 6px 2px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.text-button:hover {
  color: var(--accent-bright);
}

.storage-track {
  height: 7px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.065);
}

.storage-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  box-shadow: 0 0 18px rgba(131, 230, 173, 0.22);
  transition:
    width 500ms ease,
    background 300ms ease;
}

.storage-fill.is-high {
  background: linear-gradient(90deg, #d8a954, var(--warning));
}

.storage-fill.is-critical {
  background: linear-gradient(90deg, #e76d6d, var(--danger));
}

.storage-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  color: var(--faint);
  font-size: 0.69rem;
}

.persistence-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-align: right;
}

.persistence-status::before {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--warning);
  content: "";
}

.persistence-status.granted {
  color: var(--accent);
}

.persistence-status.granted::before {
  background: var(--accent);
}

.persistence-status.unsupported {
  color: var(--muted);
}

/* -------------------------------------------------------------------------- */
/* Footer                                                                     */
/* -------------------------------------------------------------------------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 7px 20px;
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.68rem;
}

/* -------------------------------------------------------------------------- */
/* Dialogs                                                                    */
/* -------------------------------------------------------------------------- */

.modal {
  width: min(500px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}

.modal::backdrop {
  background: rgba(2, 5, 3, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal[open] {
  animation: modal-in 190ms ease both;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-card {
  margin: 0;
  padding: 22px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.055), transparent 43%),
    #121914;
}

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

.modal-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(131, 230, 173, 0.16);
  border-radius: 13px;
  background: rgba(131, 230, 173, 0.08);
  color: var(--accent);
}

.modal-icon.warning {
  border-color: rgba(243, 199, 119, 0.17);
  background: var(--warning-soft);
  color: var(--warning);
}

.modal-icon.danger {
  border-color: rgba(255, 141, 141, 0.17);
  background: var(--danger-soft);
  color: var(--danger);
}

.modal-icon svg {
  width: 20px;
  height: 20px;
}

.dialog-close {
  margin: -3px -3px 0 0;
}

.modal h2 {
  margin-bottom: 9px;
  font-size: clamp(1.35rem, 5vw, 1.7rem);
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.modal h2 + p,
.modal-card > p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.65;
}

.callout {
  margin-top: 17px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.025);
}

.callout strong {
  display: block;
  font-size: 0.84rem;
}

.callout p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.check-list {
  display: grid;
  gap: 8px;
  margin: 17px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.5;
  list-style: none;
}

.check-list li {
  position: relative;
  padding-left: 18px;
}

.check-list li::before {
  position: absolute;
  top: 0.57em;
  left: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.modal-actions {
  display: grid;
  gap: 8px;
  margin-top: 21px;
}

.row-actions {
  grid-template-columns: minmax(0, 1fr) auto;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 17px;
  color: var(--text-soft);
  font-size: 0.77rem;
  font-weight: 750;
  letter-spacing: 0.015em;
}

.field-label input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: rgba(4, 8, 6, 0.55);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0;
}

.field-label input:focus {
  border-color: rgba(131, 230, 173, 0.5);
  box-shadow: 0 0 0 4px rgba(131, 230, 173, 0.08);
}

.field-hint {
  margin-top: 6px;
  color: var(--faint);
  font-size: 0.7rem;
  line-height: 1.5;
}

.field-hint code {
  color: var(--muted);
  font-size: 0.68rem;
}

.settings-list {
  display: grid;
  gap: 1px;
  margin-top: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}

.settings-row {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #141c17;
}

.settings-row > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.settings-row strong {
  font-size: 0.8rem;
}

.settings-row span {
  margin-top: 2px;
  overflow: hidden;
  color: var(--faint);
  font-size: 0.68rem;
  text-overflow: ellipsis;
}

.settings-row .status-pill {
  margin-top: 0;
  font-size: 0.6rem;
}

.settings-row .status-pill.standalone {
  border-color: rgba(131, 230, 173, 0.18);
  background: rgba(131, 230, 173, 0.08);
  color: var(--accent);
}

/* -------------------------------------------------------------------------- */
/* Player                                                                     */
/* -------------------------------------------------------------------------- */

.player-dialog {
  width: min(900px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}

.player-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.045), transparent 40%),
    #0f1511;
}

.player-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}

.player-heading-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.player-kicker {
  color: var(--faint);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.player-heading-copy strong {
  overflow: hidden;
  margin-top: 2px;
  font-size: 0.85rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-heading-spacer {
  width: 38px;
}

.player-stage {
  position: relative;
  display: flex;
  min-height: 160px;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(131, 230, 173, 0.08), transparent 55%),
    #040705;
}

.player-stage video {
  display: block;
  width: 100%;
  max-height: 60dvh;
  background: #000;
}

.player-stage audio {
  display: block;
  width: calc(100% - 26px);
  margin: 0 auto 14px;
  color-scheme: dark;
}

.audio-artwork {
  position: relative;
  width: 100%;
  min-height: 230px;
  max-height: 39dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 12%, rgba(116, 210, 255, 0.19), transparent 48%),
    radial-gradient(circle at 82% 85%, rgba(131, 230, 173, 0.17), transparent 47%),
    linear-gradient(145deg, #23344a, #0d1821 75%);
}

.audio-artwork img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  opacity: 0.82;
}

.audio-artwork img:not([src]),
.audio-artwork img.is-broken {
  display: none;
}

.audio-artwork::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 38%, rgba(4, 7, 5, 0.72));
  content: "";
}

.audio-artwork-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.audio-artwork-fallback > span:first-child {
  color: rgba(234, 255, 243, 0.54);
  font-family: var(--font-display);
  font-size: clamp(3rem, 12vw, 6rem);
  font-weight: 700;
  text-transform: uppercase;
}

.audio-bars {
  display: flex;
  height: 42px;
  align-items: flex-end;
  gap: 5px;
}

.audio-bars i {
  display: block;
  width: 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent-deep));
  animation: bars 1.1s ease-in-out infinite alternate;
}

.audio-bars i:nth-child(1) {
  height: 32%;
  animation-delay: -0.2s;
}

.audio-bars i:nth-child(2) {
  height: 75%;
  animation-delay: -0.55s;
}

.audio-bars i:nth-child(3) {
  height: 48%;
  animation-delay: -0.9s;
}

.audio-bars i:nth-child(4) {
  height: 88%;
  animation-delay: -0.35s;
}

@keyframes bars {
  to {
    height: 18%;
  }
}

.player-info {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 16px 0;
}

.player-info h2 {
  font-size: 1.05rem;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.player-info p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.player-meta {
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--faint);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.player-footnote {
  padding: 9px 16px 16px;
  color: var(--faint);
  font-size: 0.68rem;
}

/* -------------------------------------------------------------------------- */
/* Toasts                                                                     */
/* -------------------------------------------------------------------------- */

.toast-host {
  position: fixed;
  z-index: 100;
  right: max(16px, var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  left: max(16px, var(--safe-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  max-width: min(420px, 100%);
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(24, 33, 27, 0.96);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.42);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.4;
  animation: toast-in 220ms ease both;
  backdrop-filter: blur(12px);
}

.toast.is-error {
  border-color: rgba(255, 141, 141, 0.2);
  color: #ffc7c7;
}

.toast.is-success {
  border-color: rgba(131, 230, 173, 0.2);
}

.toast svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--accent);
}

.toast.is-error svg {
  color: var(--danger);
}

.toast.is-leaving {
  animation: toast-out 180ms ease both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(5px);
  }
}

/* -------------------------------------------------------------------------- */
/* Responsive                                                                 */
/* -------------------------------------------------------------------------- */

@media (max-width: 620px) {
  .app-shell {
    padding-right: max(14px, var(--safe-right));
    padding-left: max(14px, var(--safe-left));
  }

  .topbar {
    margin-right: calc(-1 * max(14px, var(--safe-right)));
    margin-left: calc(-1 * max(14px, var(--safe-left)));
    padding-right: max(14px, var(--safe-right));
    padding-left: max(14px, var(--safe-left));
  }

  .main-content {
    gap: 18px;
  }

  .hero {
    padding-top: 4px;
  }

  .hero h1 {
    font-size: clamp(2.5rem, 13vw, 4rem);
  }

  .url-row {
    grid-template-columns: 1fr;
  }

  .url-row .button {
    min-height: 47px;
  }

  .metadata-preview {
    grid-template-columns: 1fr;
  }

  .preview-art {
    max-width: 270px;
  }

  .preview-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .download-button {
    width: 100%;
    min-height: 47px;
  }

  .media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .card-actions {
    opacity: 1;
  }

  .card-play {
    display: none;
  }

  .storage-card {
    padding: 16px;
  }

  .player-dialog {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - var(--safe-top));
    margin: auto 0 0;
    border: 0;
    border-bottom: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .player-dialog[open] {
    animation: player-up 230ms cubic-bezier(0.22, 0.8, 0.25, 1) both;
  }

  @keyframes player-up {
    from {
      opacity: 0;
      transform: translateY(22px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  .player-card {
    padding-bottom: var(--safe-bottom);
  }

  .audio-artwork {
    min-height: 205px;
  }

  .row-actions {
    grid-template-columns: 1fr;
  }

  .row-actions .button-danger-ghost {
    order: 2;
  }

  .modal-card {
    padding: 19px;
  }
}

@media (max-width: 380px) {
  .brand-copy small {
    display: none;
  }

  .media-grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 2.35rem;
  }

  .status-pill {
    padding-right: 7px;
    padding-left: 7px;
    font-size: 0.62rem;
  }
}

@media (min-width: 760px) {
  .main-content {
    gap: 28px;
  }

  .metadata-preview {
    grid-template-columns: minmax(190px, 230px) minmax(0, 1fr);
  }

  .media-grid {
    gap: 16px;
  }

  .storage-card {
    padding: 21px;
  }

  .modal-actions:not(.row-actions) {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .modal-actions:not(.row-actions) > :first-child {
    order: 2;
  }

  .modal-actions:not(.row-actions) > :last-child {
    order: 1;
  }

  .player-info {
    padding: 18px 20px 0;
  }

  .player-footnote {
    padding: 10px 20px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
