:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e6e8f0;
  --border-strong: #d4d8e4;
  --dash: #c7cbe0;

  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-ring: rgba(37, 99, 235, .22);
  --grad: #2563eb;
  --grad-hover: #1d4ed8;

  --success: #10b981;
  --success-2: #059669;
  --success-soft: #dcfce7;
  --success-text: #047857;
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --danger-text: #b91c1c;
  --info-soft: #dbeafe;
  --info-text: #1d4ed8;

  --chip: #f1f3f9;
  --code-bg: #f8f9fc;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow: 0 4px 12px -2px rgba(15, 23, 42, .06), 0 2px 4px -2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 22px 44px -14px rgba(15, 23, 42, .16), 0 8px 16px -8px rgba(15, 23, 42, .08);
  --shadow-primary: 0 8px 20px -6px rgba(37, 99, 235, .5);
  --ease: cubic-bezier(.22, 1, .36, 1);

  --font: "Plus Jakarta Sans", Inter, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] { display: none !important; }

::selection { background: var(--primary-soft); color: var(--primary-hover); }

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

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 40px 16px 72px;
}

/* ------------------------------------------------------------ header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -.02em;
}
.brand-name span { color: var(--primary); }
.brand-logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--grad);
  color: #fff;
  box-shadow: var(--shadow-primary);
  transition: transform .35s var(--ease);
}
.brand-logo svg { width: 20px; height: 20px; }
.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.08); }
.brand-tag {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

/* ------------------------------------------------------------ page heading */
.page-heading { min-width: 0; }
.page-title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.15;
}
.page-sub { margin: 6px 0 0; color: var(--muted); font-size: 16px; }
.text-gradient {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ------------------------------------------------------------ buttons & inputs */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background-color .2s, color .2s, border-color .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.97); transition-duration: .08s; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-lg { padding: 13px 24px; font-size: 16px; border-radius: 12px; }
.btn-upper { text-transform: uppercase; letter-spacing: .06em; font-size: 14px; font-weight: 700; }

/* shine sweep on hover for solid buttons */
.btn-primary::after,
.btn-success::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform .7s var(--ease);
}
.btn-primary:hover:not(:disabled)::after,
.btn-success:hover:not(:disabled)::after { transform: translateX(120%); }

.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--shadow-primary); }
.btn-primary:hover:not(:disabled) { background: var(--grad-hover); box-shadow: 0 14px 28px -8px rgba(37, 99, 235, .6); }

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, var(--success-2) 100%);
  color: #fff;
  box-shadow: 0 8px 20px -6px rgba(16, 185, 129, .5);
}
.btn-success:hover:not(:disabled) { box-shadow: 0 14px 28px -8px rgba(16, 185, 129, .6); }

.btn-outline-danger { background: var(--surface); color: var(--danger); border-color: #fecaca; }
.btn-outline-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 10px 22px -8px rgba(239, 68, 68, .55);
}

.btn-light {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.btn-light:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

.btn svg { width: 1.15em; height: 1.15em; flex: none; transition: transform .3s var(--ease); }
.btn:hover:not(:disabled) svg { transform: scale(1.12); }

.input {
  height: 50px;
  padding: 0 18px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.input::placeholder { color: #94a3b8; }

.search-wrap { position: relative; flex: 1; min-width: 0; }
.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  width: 20px;
  height: 20px;
  color: #94a3b8;
  transform: translateY(-50%);
  pointer-events: none;
  transition: color .2s;
}
.search-wrap:focus-within .search-icon { color: var(--primary); }
.search { width: 100%; padding-left: 46px; }

.select {
  width: 190px;
  padding-right: 42px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
}

/* ------------------------------------------------------------ top bar */
.top-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.top-bar--end { justify-content: flex-end; }
.top-bar--between { justify-content: space-between; align-items: flex-end; }

/* ------------------------------------------------------------ dropzone */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 24px 56px;
  background: var(--primary-soft);
  border: 2px dashed var(--dash);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: border-color .3s, background-color .3s, box-shadow .3s var(--ease), transform .3s var(--ease);
}
.dropzone[data-state="idle"]:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}
.dropzone.is-dragover {
  border-color: var(--primary);
  border-style: solid;
  background: var(--primary-soft);
  box-shadow: 0 0 0 6px var(--primary-ring), var(--shadow-lg);
  transform: scale(1.01);
}

.dropzone-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin-bottom: 24px;
  border-radius: 28px;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 18px 36px -12px rgba(37, 99, 235, .6);
  animation: float 3.2s ease-in-out infinite;
}
.dropzone-icon::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 36px;
  border: 2px solid rgba(37, 99, 235, .25);
  animation: ring 2.4s ease-out infinite;
}
.dropzone-icon svg { width: 44px; height: 44px; }
.dropzone.is-dragover .dropzone-icon { animation: none; transform: translateY(-6px) scale(1.08); }

.dropzone-title { margin: 0 0 8px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.dropzone-sub { margin: 0 0 28px; font-size: 17px; color: var(--muted); }

.qualities {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  width: min(560px, 100%);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 10px 14px;
  background: var(--chip);
  border: 1.5px solid transparent;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: background-color .2s, border-color .2s, color .2s, transform .25s var(--ease), box-shadow .25s;
}
.chip:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.chip:has(input:checked) {
  background: var(--primary-soft);
  border-color: rgba(37, 99, 235, .35);
  color: var(--primary-hover);
}
.chip input {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.chip input::after {
  content: "";
  width: 5px;
  height: 10px;
  margin-top: -2px;
  border: solid #fff;
  border-width: 0 2.4px 2.4px 0;
  transform: rotate(45deg) scale(0);
  transition: transform .2s var(--ease);
}
.chip input:checked { background: var(--grad); border-color: var(--primary); }
.chip input:checked::after { transform: rotate(45deg) scale(1); }
.chip input:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; }

/* ------------------------------------------------------------ dropzone states */
/* data-state on #dropzone: idle | selected | uploading | success | error */
.dz-panel { display: none; flex-direction: column; align-items: center; width: 100%; }
.dropzone[data-state="idle"] .dz-idle,
.dropzone:not([data-state="idle"]) .dz-file { display: flex; animation: fade-up .45s var(--ease) both; }

.file-icon {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin-bottom: 20px;
  border-radius: 24px;
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .15);
}
.file-icon svg { width: 42px; height: 42px; }
.dropzone[data-state="success"] .file-icon { background: var(--success-soft); color: var(--success-2); }
.dropzone[data-state="error"] .file-icon { background: var(--danger-soft); color: var(--danger); }
.dropzone[data-state="uploading"] .file-icon { animation: float 2s ease-in-out infinite; }

.file-name {
  margin: 0 0 28px;
  max-width: 100%;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

.dz-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.dz-progress { display: none; width: min(520px, 100%); margin-bottom: 24px; text-align: left; }
.dz-progress .status-label { font-size: 15px; font-weight: 600; }
.dz-progress #progress-pct { color: var(--primary); }
.dz-progress .progress { height: 10px; }
.result-msg {
  display: none;
  margin: 0;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  animation: fade-up .4s var(--ease) both;
}
.result-msg a { color: inherit; }

.dropzone[data-state="uploading"] .dz-progress { display: block; }
.dropzone[data-state="uploading"] #upload-btn { display: none; }
.dropzone[data-state="success"] .dz-actions,
.dropzone[data-state="error"] .dz-actions { display: none; }
.dropzone[data-state="success"] { border-color: rgba(16, 185, 129, .5); }
.dropzone[data-state="error"] { border-color: rgba(239, 68, 68, .5); }
.dropzone[data-state="success"] .result-msg { display: block; background: var(--success-soft); color: var(--success-text); }
.new-upload-btn { display: none; margin-top: 20px; }
.dropzone[data-state="success"] .new-upload-btn { display: inline-flex; }
.recent-list:not(:empty) { margin-top: 28px; }
.dropzone[data-state="error"] .result-msg { display: block; background: var(--danger-soft); color: var(--danger-text); }
.dropzone[data-state="uploading"] .qualities,
.dropzone[data-state="success"] .qualities,
.dropzone[data-state="error"] .qualities { opacity: .5; pointer-events: none; }

.progress {
  height: 8px;
  background: #eef0f6;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  position: relative;
  height: 100%;
  width: 0;
  background: var(--grad);
  border-radius: inherit;
  transition: width .4s var(--ease);
  overflow: hidden;
}
.progress-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(45deg, rgba(255, 255, 255, .22) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .22) 50%, rgba(255, 255, 255, .22) 75%, transparent 75%);
  background-size: 18px 18px;
  animation: stripes .8s linear infinite;
}

/* ------------------------------------------------------------ video cards */
.video-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }

.video-card {
  position: relative;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .3s;
}
.video-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22px;
  bottom: 22px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--grad);
  opacity: 0;
  transition: opacity .3s;
}
.video-card:hover {
  transform: translateY(-4px);
  border-color: rgba(37, 99, 235, .25);
  box-shadow: var(--shadow-lg);
}
.video-card:hover::before { opacity: 1; }

.video-main {
  display: flex;
  gap: 22px;
  align-items: flex-start;
}

.thumb {
  position: relative;
  flex: none;
  width: 240px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .05);
}
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .6s var(--ease);
}
.thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(15, 23, 42, .35));
  opacity: 0;
  transition: opacity .35s;
  pointer-events: none;
}
.video-card:hover .thumb img { transform: scale(1.07); }
.video-card:hover .thumb::after { opacity: 1; }
.thumb[data-action] { cursor: pointer; }
.thumb[data-action]:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; }
.thumb-play {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
  color: #fff;
  border-radius: 50%;
  opacity: 0;
  transform: scale(.85);
  transition: opacity .25s, transform .25s var(--ease);
  pointer-events: none;
}
.thumb-play svg { width: 22px; height: 22px; margin-left: 3px; }
.thumb[data-action]:hover .thumb-play,
.thumb[data-action]:focus-visible .thumb-play { opacity: 1; transform: scale(1); }
.thumb-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  color: #a5b4fc;
}
.thumb-placeholder svg { width: 44px; height: 44px; }
.thumb-action {
  position: absolute;
  z-index: 1;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(6px);
  color: var(--primary);
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: .9;
  transition: transform .25s var(--ease), background .2s, color .2s, opacity .2s;
}
.thumb-action:hover { background: var(--primary); color: #fff; opacity: 1; transform: scale(1.1); }
.thumb-action svg { width: 20px; height: 20px; }

.video-info { flex: 1; min-width: 0; padding-top: 2px; }
.video-title {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
  transition: color .2s;
}
.video-card:hover .video-title { color: var(--primary-hover); }
.video-meta { margin: 0 0 12px; color: var(--muted); font-size: 14px; font-weight: 500; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge-FINISHED { background: var(--success-soft); color: var(--success-text); }
.badge-PROCESSING { background: var(--info-soft); color: var(--info-text); }
.badge-PROCESSING::before { animation: pulse-dot 1.4s ease-in-out infinite; }
.badge-QUEUED { background: #f1f5f9; color: #475569; }
.badge-FAILED { background: var(--danger-soft); color: var(--danger-text); }

.video-actions { display: flex; gap: 10px; flex: none; }

.url-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 10px 10px 10px 14px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .2s, background-color .2s;
}
.url-box:hover { border-color: rgba(37, 99, 235, .3); background: #fbfbff; }
.url-text {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 13.5px;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* One row per quality: name, tick, link and Copy once done; progress while working. */
.quality-row + .quality-row { margin-top: 8px; }
.quality-name {
  flex: none;
  min-width: 56px;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.quality-row.is-pending .quality-name { background: #f1f5f9; color: var(--muted); }
.quality-progress { flex: 1; min-width: 0; }
.quality-progress .status-label { margin-bottom: 4px; font-size: 13px; }

.tick { flex: none; width: 22px; height: 22px; }
.tick circle { fill: var(--success); }
.tick-blue circle { fill: var(--primary); }
.quality-ready { flex: 1; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.link-row + .quality-row { margin-top: 8px; }
.link-row .quality-name { background: #ecfdf5; color: var(--success-2); }
.link-wait {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 1px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: link-spin .8s linear infinite;
}
@keyframes link-spin { to { transform: rotate(360deg); } }
.tick path { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.tick-anim circle { animation: tick-pop .4s ease-out both; transform-origin: center; }
.tick-anim path { stroke-dasharray: 16; stroke-dashoffset: 16; animation: tick-draw .35s .3s ease-out forwards; }
.quality-row:has(.tick-anim), .link-row:has(.tick-anim) { animation: row-flash 1.2s ease-out; }

.status-box {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.status-label { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-weight: 500; }
.status-box.is-error { background: #fff5f5; border-color: #fecaca; color: var(--danger-text); white-space: pre-wrap; font-size: 14px; }

.empty {
  padding: 72px 24px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  font-size: 17px;
  font-weight: 500;
}

/* ------------------------------------------------------------ pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  padding: 14px 16px 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.page-info { margin: 0; color: var(--muted); font-size: 14px; }
.page-info strong { color: var(--text); font-weight: 700; }
.page-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .25s var(--ease), background-color .2s, color .2s, border-color .2s, box-shadow .25s;
}
.page-btn svg { width: 16px; height: 16px; }
.page-btn:hover:not(:disabled):not(.is-active) {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-hover);
}
.page-btn:active:not(:disabled) { transform: scale(.95); }
.page-btn.is-active {
  border-color: transparent;
  background: var(--grad);
  color: #fff;
  box-shadow: var(--shadow-primary);
  cursor: default;
}
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-gap { min-width: 24px; text-align: center; color: var(--muted); font-weight: 700; }

/* ------------------------------------------------------------ modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, .6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in .25s ease both;
}
.modal-box {
  width: min(1100px, 100%);
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, .6);
  animation: zoom-in .35s var(--ease) both;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px 12px 20px;
  background: #0f172a;
  color: #fff;
}
.modal-title { margin: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, transform .3s var(--ease);
}
.modal-close:hover { background: var(--danger); transform: rotate(90deg); }
#player { display: block; width: 100%; max-height: 80vh; background: #000; }

/* ------------------------------------------------------------ toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  background: #0f172a;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  border-radius: 12px;
  box-shadow: 0 16px 36px -10px rgba(15, 23, 42, .45);
  animation: toast-in .4s var(--ease) both;
}
.toast.is-error { background: var(--danger); }

/* ------------------------------------------------------------ account bar */
.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -16px 0 28px;
  padding: 10px 12px 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.account-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.account-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-actions { display: flex; gap: 8px; flex: none; }
.account-actions .btn-light { padding: 8px 14px; font-size: 14px; }

.role-pill,
.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: #f1f5f9;
  color: #475569;
}
.role-pill.is-admin { background: var(--info-soft); color: var(--info-text); }
.status-pill.is-active { background: var(--success-soft); color: var(--success-text); }
.status-pill.is-inactive,
.status-pill.is-expired { background: var(--danger-soft); color: var(--danger-text); }
.status-pill.is-grace { background: #fef3c7; color: #b45309; }
.status-pill.is-suspended { background: #fde68a; color: #92400e; }
.status-pill.is-cancelled { background: #f1f5f9; color: #64748b; }
.status-pill.is-pending { background: var(--info-soft); color: var(--info-text); }
.btn-activate { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn-activate:hover { color: #fff; background: var(--primary-hover); border-color: var(--primary-hover); }
.key-input { font-family: var(--mono); font-size: 15px; }
.status-pill { white-space: nowrap; }
.you-tag { margin-left: 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; }

/* ------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field-label { font-size: 14px; font-weight: 600; }
.field-label em { color: var(--muted); font-style: normal; font-weight: 500; }
.field .input { width: 100%; }
.field .select { width: 100%; }
.field-full { grid-column: 1 / -1; }
.textarea { height: auto; padding: 12px 16px; line-height: 1.5; resize: vertical; }
.form-note { margin: 0; color: var(--muted); font-size: 14.5px; }
.form-note strong { color: var(--text); }
.input:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.form-error {
  margin: 0;
  padding: 10px 14px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 10px;
  color: var(--danger-text);
  font-size: 14px;
  font-weight: 500;
}

/* ------------------------------------------------------------ login */
.login-view { display: grid; place-items: center; min-height: calc(100vh - 140px); }
.login-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(420px, 100%);
  padding: 36px 32px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 4px;
  border-radius: 16px;
  background: var(--grad);
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.login-logo svg { width: 28px; height: 28px; }
.login-title { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.login-sub { margin: -8px 0 4px; color: var(--muted); font-size: 15px; }
.login-btn { width: 100%; margin-top: 4px; }

/* ------------------------------------------------------------ users page */
.top-bar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.data-table th {
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fbfbff; }
.cell-actions { text-align: right; }
.cell-sub { margin-top: 2px; color: var(--muted); font-size: 13px; }
.cell-usage { color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.data-table code { font-family: var(--mono); font-size: 13px; color: #334155; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.domain-list, .limit-list { display: flex; flex-direction: column; gap: 2px; }
.domain-list span { font-weight: 600; }
.limit-list span { color: var(--muted); font-size: 13.5px; }

/* ------------------------------------------------------------ upload: no active subscription */
.sub-note {
  width: min(560px, 100%);
  margin: 24px 0 0;
  padding: 10px 14px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 10px;
  color: var(--danger-text);
  font-size: 14px;
  font-weight: 600;
}
.chip:has(input:disabled) { opacity: .45; cursor: not-allowed; }

.info-box { width: min(760px, 100%); }
.key-box { margin-top: 14px; }
.key-box .url-text { white-space: normal; word-break: break-all; }
.table-empty { padding: 40px 16px !important; text-align: center; color: var(--muted); }

.form-box {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(620px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 22px 24px 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, .45);
  animation: zoom-in .35s var(--ease) both;
}
.form-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.form-title { margin: 0; font-size: 20px; font-weight: 800; }
.form-head .modal-close { background: var(--surface-2); color: var(--text); }
.form-head .modal-close:hover { color: #fff; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.form-actions .btn-light { padding: 13px 24px; font-size: 16px; border-radius: 12px; }

/* ------------------------------------------------------------ animations */
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes ring { 0% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }
@keyframes stripes { to { background-position: 18px 0; } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes zoom-in { from { opacity: 0; transform: scale(.94) translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes tick-pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes tick-draw { to { stroke-dashoffset: 0; } }
@keyframes row-flash { 0% { background: var(--success-soft); border-color: var(--success); } 100% { background: var(--code-bg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .tick-anim path { stroke-dashoffset: 0; }
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  .video-main { flex-wrap: wrap; }
  .video-actions { width: 100%; }
  .video-actions .btn { flex: 1; }
}

@media (max-width: 640px) {
  .container { padding-top: 24px; }
  .brand-tag { display: none; }
  .page-title { font-size: 26px; }
  .page-sub { font-size: 15px; }
  .top-bar { flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
  .top-bar--between { align-items: stretch; }
  .top-bar .btn,
  .search-wrap,
  .select { flex: 1 1 100%; width: 100%; }
  .dropzone { padding: 44px 16px 40px; }
  .dropzone-icon { width: 76px; height: 76px; border-radius: 24px; }
  .dropzone-icon svg { width: 36px; height: 36px; }
  .dropzone-title { font-size: 21px; }
  .dropzone-sub { font-size: 15px; margin-bottom: 24px; }
  .file-name { font-size: 18px; }
  .chip { font-size: 15px; padding: 8px 16px 8px 12px; }
  .video-card { padding: 14px; }
  .video-card:hover { transform: none; }
  .thumb { width: 100%; }
  .video-title { font-size: 17px; }
  .video-meta { font-size: 13px; }
  .video-actions { gap: 8px; }
  .video-actions .btn { padding: 10px; font-size: 14px; }
  .url-text { font-size: 12.5px; }
  .pagination { justify-content: center; padding: 14px; text-align: center; }
  .page-btn { min-width: 36px; height: 36px; padding: 0 10px; }
  .page-nav span { display: none; }
  .account-bar { margin-top: -8px; margin-bottom: 20px; }
  .role-pill { font-size: 12px; }
  .top-bar-actions { width: 100%; }
  .top-bar-actions .btn { flex: 1; }
  .login-card { padding: 28px 20px 24px; }
  .form-box { padding: 18px 16px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions .btn { flex: 1; }

  /* The users table becomes one card per user. */
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; }
  .data-table tr {
    margin-bottom: 12px;
    padding: 8px 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }
  .data-table td { display: flex; justify-content: space-between; gap: 12px; padding: 6px 12px; border: 0; text-align: right; }
  .data-table td::before { content: attr(data-label); color: var(--muted); font-weight: 600; text-align: left; }
  .data-table td.cell-actions::before, .data-table td.table-empty::before { content: none; }
  .data-table td.cell-actions .btn { width: 100%; }
  .data-table tbody tr:hover td { background: transparent; }
}
