/* Base layout: white, minimal, iOS-terminal inspired */
:root {
  --bg: #ffffff;
  --bg-alt: #f5f5f7;
  --border: #e5e5ea;
  --text: #111111;
  --muted: #8e8e93;
  --accent: #007aff;
  --primary: #007aff;
  --danger: #ff3b30;
  --radius-xl: 24px;
  --radius-md: 12px;
  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    sans-serif;
  --glass: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
}

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

html {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--sans);
  background: #f2f2f7;
  /* iOS System Gray 6 */
  color: var(--text);
  display: flex;
  justify-content: center;
  /* Remove align-items: center to prevent top cropping on overflow */
  align-items: flex-start;
  background-image:
    radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
    radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-attachment: fixed;
  /* Keep background fixed while scrolling */
}

/* Centered terminal shell */
.shell {
  width: min(1400px, 98%);
  padding: 40px 20px;
  margin: auto;
  /* Centers vertically if content is short, lets it grow if long */
}

@media (max-width: 768px) {
  .shell {
    padding: 20px 10px;
    /* Add more vertical padding on mobile */
    width: 100%;
  }
}

.terminal {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 18px;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Top bar like iOS/macOS terminal */
.terminal-header {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  min-height: 44px;
  overflow: hidden;
}

.traffic-lights {
  display: flex;
  gap: 8px;
  margin-right: 16px;
  flex-shrink: 0;
}

.traffic-lights span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.traffic-lights .close {
  background: #ff5f57;
}

.traffic-lights .minimize {
  background: #febc2e;
}

.traffic-lights .zoom {
  background: #28c840;
}

.terminal-title {
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.terminal-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  display: block;
}

.terminal-title .amstream-link {
  font-size: inherit;
}

/* Terminal body */
.terminal-body {
  padding: 30px;
  background: transparent;
  min-height: 700px;
}

@media (max-width: 768px) {
  .terminal-header {
    padding: 10px 12px;
  }

  .traffic-lights {
    gap: 6px;
    margin-right: 12px;
  }

  .traffic-lights span {
    width: 10px;
    height: 10px;
  }

  .terminal-body {
    padding: 15px;
    min-height: auto;
  }

  .terminal-title {
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .terminal-header {
    padding: 8px 10px;
    flex-wrap: wrap;
    min-height: auto;
    align-items: flex-start;
  }

  .traffic-lights {
    gap: 5px;
    margin-right: 8px;
    flex-shrink: 0;
  }

  .traffic-lights span {
    width: 8px;
    height: 8px;
  }

  .terminal-title {
    font-size: 9px;
    line-height: 1.4;
    max-width: 100%;
    flex: 1 1 auto;
    min-width: 0;
    display: block;
  }

  .terminal-title-text {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    line-height: 1.5;
    display: block;
    max-height: none;
  }

  .terminal-title .amstream-link {
    font-size: inherit;
    white-space: normal;
    display: inline;
  }
}

/* Prompt + content layout */
.prompt-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  overflow: hidden;
  width: 100%;
}

.prompt-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
  min-width: 0;
}

@media (max-width: 640px) {
  .prompt-line {
    font-size: 11px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .prompt-path {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .typewriter-stats {
    font-size: 11px;
    gap: 6px;
    overflow: hidden;
    width: 100%;
  }

  .typewriter-text {
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    flex: 1;
    min-width: 0;
  }
}

.typewriter-stats {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 24px;
  min-height: 20px;
  overflow: hidden;
  width: 100%;
}

.typewriter-text {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  word-wrap: break-word;
  flex: 1;
  min-width: 0;
}

.typewriter-text::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 14px;
  background: #111827;
  border-radius: 2px;
  animation: blink 1.1s steps(1, end) infinite;
  margin-left: 4px;
  vertical-align: middle;
}

.prompt-symbol {
  color: var(--accent);
}

.prompt-path {
  color: #111827;
}

.prompt-caret {
  width: 8px;
  height: 14px;
  background: #111827;
  border-radius: 2px;
  animation: blink 1.1s steps(1, end) infinite;
}

@keyframes blink {

  0%,
  50% {
    opacity: 1;
  }

  50.01%,
  100% {
    opacity: 0;
  }
}

/* Main card inside terminal */
.card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

/* Hero Card Specifics */
.hero-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.6) 100%);
  border: 1px solid rgba(255, 255, 255, 0.8);
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(0, 122, 255, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

/* Auth layout */
.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  padding: 40px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {
  .auth-layout {
    grid-template-columns: 1fr;
    padding: 24px;
    gap: 24px;
  }
}

/* Left side: heading + description */
.auth-heading {
  margin-bottom: 18px;
}

.auth-heading h1 {
  margin: 0 0 12px;
  font-size: 32px;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #111 0%, #444 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-heading p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #e5f2ff;
  color: #0b63ce;
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 10px;
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #0b63ce;
}

/* Right side: form */
.auth-form {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  padding: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.auth-form h2 {
  margin: 0 0 14px;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
  color: #4b5563;
}

.form-input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 12px 16px;
  font-size: 14px;
  font-family: var(--sans);
  background: #f9fafb;
  outline: none;
  transition: all 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

@media (max-width: 640px) {
  .form-input {
    padding: 12px;
    font-size: 16px;
    min-height: 44px;
  }
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
  background: #ffffff;
  transform: translateY(-1px);
}

.form-input::placeholder {
  color: #d1d5db;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  font-family: var(--sans);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 44px;
  touch-action: manipulation;
  letter-spacing: -0.01em;
}

@media (max-width: 640px) {
  .btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 14px;
  }
}

.btn-primary {
  background: linear-gradient(135deg, #007aff 0%, #0062cc 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 122, 255, 0.35);
}

.btn-gradient {
  background: linear-gradient(135deg, #007aff, #00c6ff);
  color: white;
  border: none;
  box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

.btn-gradient:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
  background: linear-gradient(135deg, #0062cc, #00b4e6);
}

.animate-pulse {
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.7);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 0 10px rgba(0, 122, 255, 0);
    transform: scale(1.05);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(0, 122, 255, 0);
    transform: scale(1);
  }
}

.btn-secondary {
  background: #e5e5ea;
  color: #1c1c1e;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
  background: #d1d1d6;
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #ff3b30 0%, #d32f2f 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.25);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #d32f2f 0%, #b91c1c 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 59, 48, 0.35);
}

.btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: transparent;
  color: #111827;
  padding-inline: 10px;
}

.btn-ghost:hover {
  background: rgba(15, 23, 42, 0.04);
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Small text row */
.auth-footer {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* Index page tweaks */
.index-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.index-title {
  font-size: 42px;
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #111 0%, #555 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.index-sub {
  font-size: 18px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 600px;
}

.index-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

/* Dashboard Styles */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.dashboard-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.mobile-logout-form {
  display: none;
}

.btn-logout-mobile {
  background: rgba(255, 59, 48, 0.1);
  /* Light red background */
  color: #ff3b30;
  /* Red text */
  border: 1px solid rgba(255, 59, 48, 0.2);
  padding: 5px 10px;
  border-radius: 6px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  font-size: 0.7rem;
  min-height: 28px;
  white-space: nowrap;
}

.btn-logout-mobile:active {
  background: rgba(255, 59, 48, 0.2);
  transform: scale(0.96);
}

.logout-icon {
  font-size: 12px;
  line-height: 1;
}

.logout-text {
  font-size: 0.65rem;
  font-weight: 500;
}

@media (max-width: 480px) {
  .btn-logout-mobile {
    padding: 4px 8px;
    font-size: 0.65rem;
    min-height: 26px;
    gap: 3px;
  }

  .logout-icon {
    font-size: 11px;
  }

  .logout-text {
    font-size: 0.6rem;
  }
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

@media (max-width: 768px) {
  .dashboard-header {
    flex-direction: column;
    gap: 16px;
    position: relative;
  }

  .header-content {
    width: 100%;
  }

  .header-title-row {
    justify-content: space-between;
    width: 100%;
    align-items: center;
    gap: 8px;
  }

  .mobile-logout-form {
    display: block;
    margin: 0;
    flex-shrink: 0;
    margin-left: auto;
  }

  .btn-logout-mobile {
    padding: 5px 10px;
    font-size: 0.7rem;
    min-height: 28px;
  }

  .desktop-logout-form {
    display: none;
  }

  .dashboard-actions {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .dashboard-actions::-webkit-scrollbar {
    display: none;
  }

  .dashboard-actions>* {
    flex: 0 0 auto;
    min-width: fit-content;
    white-space: nowrap;
  }

  .dashboard-actions .btn {
    padding: 8px 12px;
    font-size: 12px;
    min-height: 36px;
  }

  .dashboard-actions form {
    flex: 0 0 auto;
    margin: 0;
  }

  .dashboard-actions button {
    width: auto;
    min-width: fit-content;
  }

  .dashboard-title {
    font-size: 20px;
    margin: 0;
  }

  .dashboard-subtitle {
    font-size: 12px;
    margin-top: 4px;
  }
}

@media (max-width: 480px) {
  .dashboard-actions {
    gap: 6px;
  }

  .dashboard-actions .btn {
    padding: 6px 10px;
    font-size: 11px;
    min-height: 34px;
  }

  .dashboard-actions .btn-gradient {
    order: -1;
    /* Upgrade button first on mobile */
  }
}

.dashboard-title {
  font-size: 24px;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.dashboard-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Upload Card */
.upload-card {
  margin-bottom: 32px;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  padding: 0;
  overflow: hidden;
}

@media (max-width: 640px) {
  .upload-card {
    margin-bottom: 20px;
  }
}

.upload-form {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.upload-area {
  position: relative;
  width: 100%;
  min-height: 140px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.5);
  padding: 1rem;
}

@media (max-width: 640px) {
  .upload-area {
    min-height: 120px;
    border-radius: 12px;
  }

  .upload-icon {
    font-size: 28px;
  }

  .upload-title {
    font-size: 15px;
  }

  .upload-desc {
    font-size: 12px;
  }
}

.upload-area:hover,
.upload-area.highlight {
  border-color: var(--accent);
  background: rgba(239, 246, 255, 0.6);
}

.upload-area.has-file {
  border-style: solid;
  border-color: var(--accent);
  background: #f0f9ff;
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
}

.upload-content {
  text-align: center;
  pointer-events: none;
}

.upload-icon {
  font-size: 32px;
  margin-bottom: 8px;
  display: block;
  color: var(--accent);
}

.upload-title {
  font-size: 16px;
  margin: 0 0 4px;
  color: var(--text);
}

.upload-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.file-name {
  display: block;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
  min-height: 400px;
}

.tab-content.active {
  display: block;
}

/* Ensure both uploads and results tabs have same size */
#uploads-tab,
#results-tab {
  min-height: 400px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Delete Button */
.btn-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 5;
  touch-action: manipulation;
}

@media (max-width: 640px) {
  .btn-delete {
    width: 36px;
    height: 36px;
    font-size: 20px;
    opacity: 0.8;
    top: 6px;
    right: 6px;
  }

  .video-card:active .btn-delete {
    opacity: 1;
  }
}

.btn-delete:hover {
  background: var(--danger);
  transform: scale(1.1);
}

.video-card:hover .btn-delete {
  opacity: 1;
}

/* Admin Table Button Styles */
table .btn-delete {
  position: static;
  opacity: 1;
  width: auto;
  height: auto;
  background: none;
  color: var(--danger);
  font-size: 1.5rem;
  padding: 0;
  margin: 0;
}

table .btn-delete:hover {
  transform: scale(1.2);
  background: none;
}

/* Admin Edit Button */
.btn-edit {
  padding: 6px 12px;
  font-size: 0.85rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.btn-edit:hover {
  background: #0062cc;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 122, 255, 0.3);
}

/* Admin Table Checkboxes */
table input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--primary);
}

#selectAll {
  transform: scale(1.1);
}

/* Bulk Actions Container */
.bulk-actions-container {
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.1) 0%, rgba(0, 200, 255, 0.05) 100%);
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 12px 16px;
  animation: slideInBulk 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.15);
  margin-top: 8px;
}

.bulk-actions-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bulk-select-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.bulk-select-wrapper:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

.bulk-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.bulk-select {
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  outline: none;
  padding: 4px 8px;
  min-width: 140px;
  font-family: var(--sans);
}

.bulk-select:focus {
  color: var(--primary);
}

.btn-bulk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--sans);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.btn-bulk::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-bulk:hover::before {
  width: 300px;
  height: 300px;
}

.btn-bulk:active {
  transform: scale(0.95);
}

.btn-bulk-primary {
  background: linear-gradient(135deg, #007aff 0%, #0051d5 100%);
  color: white;
}

.btn-bulk-primary:hover {
  background: linear-gradient(135deg, #0062cc 0%, #0040a8 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.btn-bulk-danger {
  background: linear-gradient(135deg, #ff3b30 0%, #d32f2f 100%);
  color: white;
}

.btn-bulk-danger:hover {
  background: linear-gradient(135deg, #e6392a 0%, #b71c1c 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.4);
}

.btn-icon {
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@keyframes slideInBulk {
  from {
    opacity: 0;
    transform: translateY(-15px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Notification Styles */
@keyframes slideInNotification {
  from {
    opacity: 0;
    transform: translateX(400px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutNotification {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(400px);
  }
}

.bulk-notification {
  font-family: var(--sans);
  font-size: 0.9rem;
}

/* Responsive for bulk actions */
@media (max-width: 768px) {
  .bulk-actions-group {
    flex-direction: column;
    width: 100%;
  }

  .bulk-select-wrapper {
    width: 100%;
  }

  .bulk-select {
    flex: 1;
    min-width: auto;
  }

  .btn-bulk {
    width: 100%;
    justify-content: center;
  }

  .bulk-notification {
    right: 10px !important;
    left: 10px !important;
    max-width: calc(100% - 20px) !important;
  }
}

/* Video Grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

@media (max-width: 640px) {
  .video-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .video-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.video-card {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: none;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.video-preview {
  background: #000;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.video-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-playsinline: true;
  playsinline: true;
}

@media (max-width: 640px) {
  .video-preview {
    aspect-ratio: 16/9;
    max-height: 50vh;
  }
}

.video-info {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

@media (max-width: 640px) {
  .video-info {
    padding: 12px;
  }

  .video-name {
    font-size: 13px;
  }

  .video-meta {
    font-size: 10px;
  }
}

.video-name {
  font-size: 14px;
  margin: 0 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--muted);
}

.status-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  text-transform: uppercase;
  font-size: 10px;
}

.status-badge.pending {
  background: #f3f4f6;
  color: #4b5563;
}

.status-badge.processing {
  background: #fff7ed;
  color: #c2410c;
}

.status-badge.completed {
  background: #ecfdf5;
  color: #047857;
}

.status-badge.error {
  background: #fef2f2;
  color: #b91c1c;
}

.loop-form {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .loop-form {
    padding-top: 10px;
  }
}

.loop-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 12px;
}

@media (max-width: 640px) {
  .loop-controls {
    gap: 10px;
    font-size: 11px;
  }
}

.loop-compact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
  /* Allow wrapping for button */
}

.compact-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  padding: 0;
  border: none;
}

/* Ensure Loop group doesn't stretch */
.compact-group:first-child {
  flex: 0 0 auto;
}

.fade-group {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.compact-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  margin-right: 2px;
}

.compact-input {
  width: 48px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  color: var(--text);
  font-family: var(--mono);
  outline: none;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.compact-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.compact-input:hover {
  border-color: #d1d5db;
}

.compact-slider {
  flex: 1;
  width: auto;
  min-width: 60px;
  height: 4px;
  margin: 0 12px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: #e5e5ea;
  border-radius: 2px;
}

.compact-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s;
}

.compact-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.compact-input::-webkit-outer-spin-button,
.compact-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.compact-btn {
  width: 100%;
  /* Full width on new line */
  margin-top: 8px;
  padding: 8px 16px;
  font-size: 13px;
  height: 36px;
}

@media (max-width: 640px) {
  .loop-compact-row {
    flex-wrap: wrap;
    gap: 8px;
    background: transparent;
    padding: 0;
    border: none;
    border-radius: 0;
  }

  .compact-group {
    padding: 8px;
    background: var(--bg-alt);
    border: 1px solid transparent;
    border-radius: 8px;
    flex: 1;
    /* Equal width for both groups */
    min-width: 0;
    justify-content: center;
    display: flex;
    flex-direction: column;
    /* Stack label/input vertically inside the group for symmetry */
    align-items: center;
    gap: 4px;
    height: 100%;
  }

  .compact-group:first-child,
  .fade-group {
    order: 1;
    border: 1px solid transparent;
  }

  .compact-label {
    font-size: 11px;
    margin: 0;
    width: 100%;
    text-align: center;
  }

  .compact-input {
    width: 100%;
    /* Full width inside the group */
    max-width: 80px;
    /* Limit max width but wider than before */
    font-size: 14px;
    padding: 6px;
    height: 36px;
    border: 1px solid var(--border);
    background: #fff;
  }

  /* Slider behavior on mobile */
  .fade-group .compact-slider {
    display: block;
    width: 100%;
    margin: 4px 0 0 0;
    height: 16px;
    flex-basis: auto;
  }

  /* Make the first group (Loop) match the height/structure of Fade group */
  .compact-group:first-child {
    justify-content: space-between;
    /* Distribute space if needed */
  }

  /* Add invisible spacer or padding to Loop group to match Fade group's slider height if needed for perfect alignment,
     OR just let flexbox handle equal height (stretch).
  */

  .compact-btn {
    width: 100%;
    margin-top: 4px;
    height: 40px;
    font-size: 14px;
    order: 3;
    flex: 1 1 100%;
  }
}

.range-slider {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: #e5e5ea;
  outline: none;
  -webkit-appearance: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.progress-container {
  width: 100%;
  height: 6px;
  background: #f3f4f6;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
  display: none;
  /* Hidden by default */
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 99px;
}

.progress-text {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
  display: none;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
  margin-left: auto;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 640px) {
  .empty-state {
    padding: 30px 20px;
    font-size: 13px;
  }
}

.processing-text {
  font-size: 12px;
  color: var(--accent);
  font-style: italic;
  margin: 0;
}

.plan-info-text {
  padding: 8px 0;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 8px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.plan-name {
  color: var(--primary);
  font-weight: bold;
}

.max-loops {
  color: var(--success);
  font-weight: bold;
}

@media (max-width: 640px) {
  .plan-info-text {
    font-size: 10px;
    line-height: 1.4;
    padding: 6px 0;
  }
}

/* Additional Refinements */

/* Hero Card on Index */
.hero-card {
  text-align: center;
  padding: 60px 40px;
}

.hero-content {
  max-width: 480px;
  margin: 0 auto 32px;
}

.user-status {
  background: rgba(255, 255, 255, 0.5);
  padding: 20px;
  border-radius: 12px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Auth Page Refinements */
.auth-info {
  padding-right: 20px;
}

.auth-form-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.btn-block {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}

@media (max-width: 640px) {
  .btn-block {
    margin-top: 12px;
    padding: 12px 20px;
    min-height: 48px;
    font-size: 15px;
  }
}

/* Alerts */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-danger {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* Mobile-specific improvements */
@media (max-width: 640px) {
  body {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }

  /* Better touch targets */
  button,
  a,
  input,
  select,
  textarea {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }

  /* Prevent zoom on input focus (iOS) */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  @supports (-webkit-touch-callout: none) {

    input,
    select,
    textarea {
      font-size: 16px !important;
    }
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .hero-card {
    padding: 40px 20px;
  }

  .auth-info {
    padding-right: 0;
    margin-bottom: 24px;
    text-align: center;
  }

  .auth-heading h1 {
    font-size: 28px;
  }

  /* Table responsiveness */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-responsive table {
    width: 100%;
    min-width: 600px;
    /* Ensure table doesn't squish too much */
  }
}

@media (max-width: 640px) {
  .hero-card {
    padding: 30px 16px;
  }

  .index-title {
    font-size: 24px;
  }

  .index-sub {
    font-size: 12px;
  }

  .auth-heading h1 {
    font-size: 22px;
  }

  .traffic-lights {
    gap: 6px;
  }

  .traffic-lights span {
    width: 10px;
    height: 10px;
  }
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 0;
  border: 1px solid #888;
  width: 90%;
  max-width: 400px;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  animation: modalSlideIn 0.3s ease;
  overflow: hidden;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 16px 20px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.modal-close {
  color: #9ca3af;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #111827;
}

.modal-body {
  padding: 20px;
  text-align: center;
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}

.modal-message {
  margin: 0 0 20px;
  color: #4b5563;
  font-size: 14px;
  line-height: 1.5;
}

.modal-footer {
  padding: 16px 20px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 640px) {
  .modal-content {
    width: 95%;
    max-width: 95%;
    margin: 10px;
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
  }

  .modal-close {
    font-size: 28px;
    padding: 4px 8px;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.bg-uploading {
  background-color: #60a5fa !important;
}

/* AMSTREAM Link Animation */
.amstream-link {
  color: #3b82f6;
  text-decoration: none;
  font-weight: bold;
  transition: all 0.3s ease;
  animation: pulse-glow 2s ease-in-out infinite;
}

.amstream-link:hover {
  color: #60a5fa;
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
  transform: scale(1.05);
}

@keyframes pulse-glow {

  0%,
  100% {
    text-shadow: 0 0 5px rgba(59, 130, 246, 0.3);
  }

  50% {
    text-shadow: 0 0 15px rgba(59, 130, 246, 0.6), 0 0 20px rgba(59, 130, 246, 0.4);
  }
}

/* Admin Panel Styles */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.admin-tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.admin-tab:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.02);
}

.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.data-table {
  width: 100%;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: rgba(0, 0, 0, 0.02);
  padding: 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover {
  background: rgba(0, 122, 255, 0.03);
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.badge-processing {
  background: rgba(255, 149, 0, 0.1);
  color: #ff9500;
}

.badge-completed {
  background: rgba(52, 199, 89, 0.1);
  color: #34c759;
}

.badge-error {
  background: rgba(255, 59, 48, 0.1);
  color: #ff3b30;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.9);
  outline: none;
}

.filter-select:focus {
  border-color: var(--accent);
}

.refresh-info {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #34c759;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}