:root {
  --primary-blue: #009ffc;
  --primary-blue-dark: #0284c7;
  --primary-gradient: linear-gradient(135deg, #009ffc 0%, #0284c7 100%);
  --btn-green: #22c55e;
  --btn-green-dark: #16a34a;
  --danger-red: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --bg-page: #f4f7fb;
  --bg-white: #ffffff;
  --text-dark: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --border-color: #e2e8f0;
  --shadow-card: 0 12px 32px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 4px 16px rgba(15, 23, 42, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Sukhumvit Set", "Helvetica Neue", Arial, sans-serif;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100vh;
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--text-dark);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

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

/* Header */
.site-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary-gradient);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 159, 252, 0.28);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-text small {
  font-size: 12px;
  color: var(--text-subtle);
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-install-pwa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--primary-gradient);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 159, 252, 0.25);
}

.btn-install-pwa[hidden] {
  display: none;
}

.engine-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: #f1f5f9;
  color: var(--text-muted);
}

.engine-status.ready {
  background: #ecfdf5;
  color: #15803d;
}

.engine-status.warning {
  background: #fffbeb;
  color: #b45309;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.engine-status.ready .status-dot {
  background: #22c55e;
}

.engine-status.warning .status-dot {
  background: #f59e0b;
}

/* Hero Section */
.hero-section {
  background: var(--primary-gradient);
  color: #ffffff;
  width: 100%;
  padding: 48px 20px 56px;
  text-align: center;
}

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

.hero-title {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 10px;
}

.hero-subtitle {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 22px;
}

.platform-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  backdrop-filter: blur(4px);
}

.platform-badge.highlight {
  background: rgba(255, 255, 255, 0.26);
  border-color: rgba(255, 255, 255, 0.45);
}

/* Form */
.download-form {
  display: flex;
  gap: 10px;
  align-items: stretch;
  max-width: 820px;
  margin: 0 auto;
}

.input-box-wrapper {
  flex: 1;
  min-height: 54px;
  background: var(--bg-white);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 20px;
  box-shadow: 0 8px 24px rgba(2, 60, 102, 0.18);
  border: 2px solid transparent;
  transition: border-color 0.15s ease;
}

.input-box-wrapper:focus-within {
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
}

.link-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-dark);
  font-family: inherit;
}

.link-input::placeholder {
  color: #94a3b8;
}

.btn-clear {
  background: #f1f5f9;
  color: var(--text-muted);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.btn-clear[hidden] {
  display: none;
}

.btn-clear:hover {
  background: #e2e8f0;
  color: var(--text-dark);
}

.btn-paste {
  height: 38px;
  padding: 0 14px;
  background: #e0f2fe;
  color: #0369a1;
  border: none;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.btn-paste:hover {
  background: #bae6fd;
}

.btn-download-main {
  min-width: 158px;
  height: 54px;
  padding: 0 22px;
  background: var(--btn-green);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.32);
  flex-shrink: 0;
  transition: transform 0.12s ease, background 0.15s ease;
}

.btn-download-main:hover:not(:disabled) {
  background: var(--btn-green-dark);
  transform: translateY(-1px);
}

.btn-download-main:disabled {
  opacity: 0.7;
  cursor: wait;
}

/* Options Toolbar (Quick Mode + Cookies) */
.options-toolbar {
  max-width: 820px;
  margin: 14px auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.quick-control,
.cookies-control {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-md);
  padding: 7px 13px;
  font-size: 13px;
}

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  color: #ffffff;
  font-weight: 600;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.35);
  transition: background 0.18s ease;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.18s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.toggle-switch input:checked + .toggle-slider {
  background: #22c55e;
  border-color: #4ade80;
}

.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.toggle-label {
  font-size: 13px;
  white-space: nowrap;
}

.btn-download-main.quick-active {
  background: #f59e0b;
  box-shadow: 0 8px 20px rgba(217, 119, 6, 0.35);
}

.btn-download-main.quick-active:hover:not(:disabled) {
  background: #d97706;
}

.cookies-label {
  font-weight: 600;
  color: #ffffff;
}

.cookies-select {
  background: #ffffff;
  color: var(--text-dark);
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.cookies-hint {
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
}

/* Error & Loading */
.error-banner {
  max-width: 820px;
  margin: 18px auto 0;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #991b1b;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  box-shadow: var(--shadow-soft);
}

.loading-panel {
  max-width: 820px;
  margin: 20px auto 0;
  padding: 20px 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-white);
  color: var(--text-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-card);
}

.loading-panel[hidden] {
  display: none;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary-blue);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

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

/* Results Card */
.download-results-container {
  max-width: 820px;
  margin: 22px auto 0;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  color: var(--text-dark);
  text-align: left;
}

.download-results-container[hidden] {
  display: none;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-full);
}

.result-close {
  background: #f1f5f9;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.result-close:hover {
  background: #e2e8f0;
  color: var(--text-dark);
}

.result-video-info {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-color);
}

.result-thumb-wrapper {
  position: relative;
  width: 192px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 36px;
}

.result-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.result-duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(15, 23, 42, 0.85);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}

.result-meta {
  flex: 1;
  min-width: 0;
}

.result-video-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 6px;
  word-break: break-word;
}

.result-video-author {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.result-video-note {
  font-size: 12px;
  color: var(--text-subtle);
}

/* Format Tabs (YouTube MP4 / MP3) */
.format-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.format-tab-btn {
  flex: 1;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.format-tab-btn:hover {
  border-color: var(--primary-blue);
  color: var(--text-dark);
}

.format-tab-btn.active {
  background: #f0f9ff;
  border-color: var(--primary-blue);
  color: #0369a1;
}

/* Quality Rows */
.quality-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quality-group[hidden] {
  display: none;
}

.quality-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #f8fafc;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.quality-row:hover {
  border-color: #bae6fd;
  background: #f0f9ff;
}

.quality-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quality-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.quality-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: #e0f2fe;
  color: #0369a1;
}

.quality-pill.mp3 {
  background: #fae8ff;
  color: #86198f;
}

.quality-size {
  font-size: 13px;
  color: var(--text-subtle);
}

.btn-download-choice {
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--btn-green);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, transform 0.12s ease;
}

.btn-download-choice:hover:not(:disabled) {
  background: var(--btn-green-dark);
  transform: translateY(-1px);
}

.btn-download-choice:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Active Download Progress Panel */
.progress-panel {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid #cbd5e1;
}

.progress-panel[hidden] {
  display: none;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.progress-message {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
}

.progress-meta {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.btn-cancel-job {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--danger-border);
  background: #ffffff;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-cancel-job:hover {
  background: var(--danger-bg);
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: var(--radius-full);
  background: #e2e8f0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #009ffc, #22c55e);
  transition: width 0.25s ease;
}

.download-toast {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.download-toast[hidden] {
  display: none;
}

.download-toast.error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: #991b1b;
}

.btn-redownload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  background: #16a34a;
  color: #ffffff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.btn-redownload:hover {
  background: #15803d;
}

/* Content Section (History & Guide) */
.content-section {
  padding: 36px 20px 56px;
}

.content-container {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.active-card,
.history-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.active-card {
  border-color: #7dd3fc;
  background: linear-gradient(180deg, #f0f9ff 0%, #ffffff 100%);
}

.active-card[hidden],
.history-card[hidden] {
  display: none;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.section-title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
}

.section-header-row h2 {
  font-size: 18px;
  font-weight: 700;
}

.count-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: #e0f2fe;
  color: #0369a1;
}

.history-summary {
  font-size: 13px;
  color: var(--text-subtle);
  font-weight: 500;
}

.active-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.active-job-item {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid #bae6fd;
}

.active-job-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.active-job-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
  word-break: break-word;
}

.active-job-sub {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 2px;
}

.btn-text-subtle {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-text-subtle:hover {
  color: var(--danger-red);
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 100%;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-color);
  font-size: 14px;
  max-width: 100%;
  overflow: hidden;
}

.history-item-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.history-item-title {
  font-weight: 700;
  color: var(--text-dark);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.history-item-sub {
  font-size: 12px;
  color: var(--text-subtle);
  overflow-wrap: anywhere;
}

.history-item-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
  max-width: 100%;
}

.btn-history-save {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: var(--btn-green);
  color: #ffffff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.btn-history-save:hover {
  background: var(--btn-green-dark);
}

.btn-history-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--danger-border);
  background: #ffffff;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.btn-history-delete:hover {
  background: var(--danger-bg);
}

/* Guide Grid */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.guide-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-color);
}

.guide-icon {
  font-size: 26px;
  margin-bottom: 10px;
}

.guide-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.guide-card p {
  font-size: 14px;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  background: var(--bg-white);
  border-top: 1px solid var(--border-color);
  padding: 18px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-subtle);
}

/* Focus rings */
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid #0284c7;
  outline-offset: 2px;
}

/* ==========================================================================
   Phase 1 Additions: Mode Tabs, Batch, Queue States, Library Tools & Modals
   ========================================================================== */

body.modal-open {
  overflow: hidden;
}

.input-mode-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 14px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.mode-tab-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-tab-btn.active {
  background: #ffffff;
  color: var(--primary-blue-dark);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.16);
}

.mode-tab-btn:hover:not(.active) {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

/* Batch Form */
.batch-form {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.batch-form[hidden] {
  display: none;
}

.batch-textarea-wrap {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-card);
}

.batch-textarea {
  width: 100%;
  min-height: 110px;
  max-height: 260px;
  resize: vertical;
  border: none;
  outline: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-dark);
}

.batch-textarea::placeholder {
  font-family: var(--font-family);
  color: #94a3b8;
}

.batch-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.batch-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.batch-count-pill {
  background: rgba(15, 23, 42, 0.22);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-full);
}

.btn-batch-util {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
}

.btn-batch-util:hover {
  background: rgba(255, 255, 255, 0.24);
}

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

.preset-select {
  height: 44px;
  background: #ffffff;
  color: var(--text-dark);
  border: none;
  border-radius: var(--radius-full);
  padding: 0 14px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.btn-batch-go {
  height: 44px;
  padding: 0 22px;
  font-size: 15px;
}

.quick-toast {
  max-width: 820px;
  margin: 14px auto 0;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: #ecfdf5;
  border: 1px solid #86efac;
  color: #065f46;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  box-shadow: var(--shadow-soft);
}

/* Queue States (Queued / Failed / Retry) */
.active-job-info {
  min-width: 0;
  flex: 1;
}

.active-job-item.queued {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.active-job-item.failed {
  background: #fef2f2;
  border-color: #fecaca;
}

.queue-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
  margin-right: 6px;
}

.queue-status-pill.queued {
  background: #e0f2fe;
  color: #0369a1;
}

.queue-status-pill.failed {
  background: #fee2e2;
  color: #b91c1c;
}

.active-job-sub.error-text {
  color: #991b1b;
}

.active-job-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-retry-job {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid #bae6fd;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-retry-job:hover {
  background: #bae6fd;
}

.btn-dismiss-job {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-subtle);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-dismiss-job:hover {
  color: var(--danger-red);
  border-color: var(--danger-border);
}

/* Library Toolbar: Search, Filter Chips, Sort, Bulk Actions */
.history-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.btn-text-subtle.active {
  color: var(--primary-blue-dark);
  font-weight: 700;
}

.btn-text-subtle.danger:hover {
  color: var(--danger-red);
}

.library-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.library-search-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  pointer-events: none;
}

.library-search-input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-dark);
  font-family: inherit;
  font-size: 13.5px;
}

.library-search-input:focus {
  background: #ffffff;
  border-color: var(--primary-blue);
  outline: none;
}

.library-sort-select {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-dark);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.14s ease;
}

.filter-chip:hover {
  border-color: var(--primary-blue);
  color: var(--primary-blue-dark);
}

.filter-chip.active {
  background: var(--primary-blue);
  border-color: var(--primary-blue);
  color: #ffffff;
}

.bulk-action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.bulk-action-bar[hidden] {
  display: none;
}

.bulk-count {
  font-size: 13.5px;
  font-weight: 700;
  color: #1e40af;
}

.bulk-action-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-bulk-util {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid #bfdbfe;
  background: #ffffff;
  color: #1e40af;
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-bulk-delete {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--danger-red);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-bulk-delete:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.history-empty-filter {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-subtle);
  font-size: 14px;
  background: #f8fafc;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
}

/* History Thumbnails & Action Buttons */
.history-item.selected {
  background: #eff6ff;
  border-color: #93c5fd;
}

.history-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.history-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-blue);
  cursor: pointer;
}

.history-thumb-btn {
  position: relative;
  width: 84px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #0f172a;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.history-thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #ffffff;
}

.history-thumb-fallback.audio {
  background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
}

.history-play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.34);
  color: #ffffff;
  font-size: 16px;
  opacity: 0.9;
  transition: background 0.15s ease;
}

.history-thumb-btn:hover .history-play-badge {
  background: rgba(0, 159, 252, 0.58);
}

.btn-history-play {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 13px;
  border-radius: var(--radius-full);
  border: 1px solid #bae6fd;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.btn-history-play:hover {
  background: #bae6fd;
}

.btn-history-rename {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-dark);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.btn-history-rename:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* Modals (In-App Player & Rename) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-dialog {
  width: 100%;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 92vh;
}

.player-dialog {
  max-width: 820px;
}

.rename-dialog {
  max-width: 480px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title-wrap {
  min-width: 0;
  flex: 1;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  word-break: break-word;
}

.modal-meta {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-subtle);
}

.modal-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-dark);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: #e2e8f0;
}

.player-stage {
  background: #020617;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  max-height: 66vh;
}

.modal-video {
  width: 100%;
  max-height: 66vh;
  display: block;
  background: #000000;
}

.modal-audio-wrap {
  width: 100%;
  padding: 36px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
}

.modal-audio-wrap[hidden] {
  display: none;
}

.audio-cover-icon {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  background: linear-gradient(135deg, #7c3aed 0%, #009ffc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.modal-audio {
  width: 100%;
  max-width: 480px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
}

.btn-modal-secondary {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-dark);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.btn-modal-secondary:hover {
  background: #f1f5f9;
}

.btn-modal-primary {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--primary-blue);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-modal-primary:hover {
  background: var(--primary-blue-dark);
}

.rename-form {
  padding: 18px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rename-form .modal-footer {
  margin: 10px -20px 0;
}

.rename-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.rename-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-dark);
}

.btn-rename-shorten {
  padding: 4px 11px;
  border-radius: var(--radius-full);
  border: 1px solid #bae6fd;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-rename-shorten:hover:not(:disabled) {
  background: #bae6fd;
}

/* Smart Filename Editor Box (inside Video Results Card) */
.filename-editor-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filename-editor-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.filename-editor-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dark);
}

.filename-char-count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-subtle);
  background: #e2e8f0;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.filename-editor-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--text-dark);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
}

.filename-editor-input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(0, 159, 252, 0.15);
}

.filename-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filename-chip {
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.14s ease;
}

.filename-chip:hover {
  border-color: var(--primary-blue);
  color: var(--primary-blue-dark);
}

.filename-chip.active {
  background: #e0f2fe;
  border-color: var(--primary-blue);
  color: #0369a1;
}

.rename-ext-hint {
  font-weight: 500;
  color: var(--text-subtle);
  font-size: 12.5px;
}

.rename-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid #cbd5e1;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text-dark);
}

.rename-input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(0, 159, 252, 0.16);
}

.rename-error {
  font-size: 13px;
  color: #b91c1c;
  font-weight: 600;
}

/* ==========================================================================
   Phase 2 Additions: Pro Trim/Subtitles, Playlist Picker, Photo Gallery
   ========================================================================== */

.result-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-thumb-dl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--text-dark);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.btn-thumb-dl:hover {
  background: #e0f2fe;
  border-color: var(--primary-blue);
  color: #0369a1;
}

.playlist-detect-banner {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-open-playlist {
  padding: 6px 13px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--primary-blue);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-open-playlist:hover {
  background: var(--primary-blue-dark);
}

/* Collapsible Pro Trim & Subtitles Box */
.pro-options-box {
  margin-top: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  overflow: hidden;
}

.pro-options-summary {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
  user-select: none;
  list-style: none;
}

.pro-options-summary::-webkit-details-marker {
  display: none;
}

.pro-summary-hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-subtle);
}

.pro-options-body {
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pro-trim-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.pro-trim-field {
  flex: 1;
  min-width: 125px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pro-field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.pro-text-input,
.pro-select {
  height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--text-dark);
  font-size: 13.5px;
  font-family: inherit;
}

.pro-text-input:focus,
.pro-select:focus {
  outline: none;
  border-color: var(--primary-blue);
}

.btn-trim-clear {
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.btn-trim-clear:hover {
  background: #e2e8f0;
  color: var(--text-dark);
}

.pro-subtitles-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

.pro-sub-select-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

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

.pro-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
}

.btn-srt-dl {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid #bae6fd;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-srt-dl:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-srt-dl:hover:not(:disabled) {
  background: #bae6fd;
}

/* Playlist Picker Card */
.playlist-meta-header {
  margin-top: 10px;
  text-align: left;
}

.playlist-controls-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-pl-util {
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-dark);
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.btn-pl-util:hover {
  background: #e2e8f0;
}

.playlist-entries-list {
  list-style: none;
  margin-top: 12px;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.playlist-entry-item {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  transition: background 0.12s ease;
}

.playlist-entry-item:hover {
  background: #eff6ff;
}

.playlist-entry-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
}

.pl-thumb-img,
.pl-thumb-fallback {
  width: 68px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.pl-entry-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pl-entry-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-dark);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pl-entry-sub {
  font-size: 12px;
  color: var(--text-subtle);
}

.playlist-footer-bar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* X / Twitter Photo Gallery Card */
.photo-gallery-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.photo-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
}

.photo-preview-link {
  display: block;
  background: #0f172a;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.photo-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-card-footer {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.photo-dims {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-subtle);
}

.photo-gallery-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

/* Library Trim & Extract Tool Buttons + Trim Modal */
.btn-history-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-dark);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.btn-history-tool:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #93c5fd;
}

.btn-history-tool:disabled {
  opacity: 0.55;
  cursor: wait;
}

.trim-modal-hint {
  font-size: 13px;
  color: var(--text-muted);
}

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

.trim-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ==========================================================================
   Phase 3 Additions: Header Icons, Delete Mode Modal, Settings/QR & Dark Mode
   ========================================================================== */

.btn-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-white);
  color: var(--text-dark);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

.btn-header-icon:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

/* Delete Confirmation Modal (2 Delete Modes) */
.delete-modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.delete-note-box {
  padding: 10px 13px;
  border-radius: var(--radius-md);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 13px;
}

.delete-choice-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.delete-choice-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.14s ease, border-color 0.14s ease;
}

.delete-choice-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.delete-choice-btn.soft {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  color: var(--text-dark);
}

.delete-choice-btn.soft:hover:not(:disabled) {
  background: #eff6ff;
  border-color: var(--primary-blue);
}

.delete-choice-btn.hard {
  background: #fef2f2;
  border: 1.5px solid #fecaca;
  color: #991b1b;
}

.delete-choice-btn.hard:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #ef4444;
}

.delete-choice-icon {
  font-size: 20px;
  line-height: 1.2;
  flex-shrink: 0;
}

.delete-choice-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.delete-choice-text strong {
  font-size: 14px;
}

.delete-choice-text small {
  font-size: 12.5px;
  opacity: 0.82;
}

/* Settings & QR Code Modal */
.settings-dialog {
  max-width: 640px;
}

.settings-body {
  padding: 16px 20px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-body .modal-footer {
  margin: 4px -20px 0;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.settings-section:last-of-type {
  border-bottom: none;
  padding-bottom: 4px;
}

.settings-section-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-dark);
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.settings-field-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.qr-panel {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-color);
}

.qr-img-box {
  width: 136px;
  height: 136px;
  padding: 6px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-img {
  width: 100%;
  height: 100%;
  display: block;
}

.qr-info-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.qr-url-display {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-blue-dark);
  word-break: break-all;
}

.btn-sm {
  align-self: flex-start;
  padding: 5px 12px;
  font-size: 12.5px;
}

.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-color);
}

.settings-toggle-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-dark);
}

.settings-toggle-sub {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 2px;
}

.toggle-switch.dark-track .toggle-slider {
  background: #94a3b8;
  border-color: #94a3b8;
}

.settings-ytdlp-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.settings-log-box {
  width: 100%;
  max-height: 120px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #0f172a;
  color: #e2e8f0;
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.settings-feedback {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #ecfdf5;
  border: 1px solid #86efac;
  color: #065f46;
  font-size: 13px;
  font-weight: 600;
}

.settings-feedback.error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: #991b1b;
}

/* ==========================================================================
   Dark Mode Theme ([data-theme="dark"])
   ========================================================================== */

:root[data-theme="dark"] {
  --bg-page: #0b1120;
  --bg-white: #111827;
  --text-dark: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-subtle: #94a3b8;
  --border-color: #1f2937;
  --danger-bg: #3b1219;
  --danger-border: #7f1d1d;
  --shadow-card: 0 14px 36px rgba(0, 0, 0, 0.48);
  --shadow-soft: 0 4px 18px rgba(0, 0, 0, 0.32);
}

:root[data-theme="dark"] .hero-section {
  background: linear-gradient(135deg, #0c4a6e 0%, #0f172a 100%);
}

:root[data-theme="dark"] .site-header,
:root[data-theme="dark"] .site-footer {
  background: #0f172a;
  border-color: #1e293b;
}

:root[data-theme="dark"] .btn-header-icon {
  background: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}

:root[data-theme="dark"] .btn-header-icon:hover {
  background: #334155;
}

:root[data-theme="dark"] .engine-status.ready {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

:root[data-theme="dark"] .engine-status.warning {
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
}

:root[data-theme="dark"] .input-box-wrapper,
:root[data-theme="dark"] .batch-textarea-wrap {
  background: #1e293b;
  border: 1px solid #334155;
}

:root[data-theme="dark"] .link-input,
:root[data-theme="dark"] .batch-textarea {
  background: transparent;
  color: #f8fafc;
}

:root[data-theme="dark"] .btn-paste {
  background: #0f172a;
  color: #7dd3fc;
}

:root[data-theme="dark"] .cookies-select,
:root[data-theme="dark"] .preset-select {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
}

:root[data-theme="dark"] .download-results-container,
:root[data-theme="dark"] .active-card,
:root[data-theme="dark"] .history-card,
:root[data-theme="dark"] .guide-card,
:root[data-theme="dark"] .modal-dialog {
  background: #111827;
  border-color: #1f2937;
}

:root[data-theme="dark"] .quality-row,
:root[data-theme="dark"] .history-item,
:root[data-theme="dark"] .active-job-item,
:root[data-theme="dark"] .filename-editor-box,
:root[data-theme="dark"] .pro-options-box,
:root[data-theme="dark"] .pro-options-body,
:root[data-theme="dark"] .playlist-entry-item,
:root[data-theme="dark"] .photo-card,
:root[data-theme="dark"] .qr-panel,
:root[data-theme="dark"] .settings-toggle-row,
:root[data-theme="dark"] .history-empty-filter,
:root[data-theme="dark"] .modal-footer,
:root[data-theme="dark"] .format-tabs {
  background: #1e293b;
  border-color: #334155;
}

:root[data-theme="dark"] .format-tab-btn.active {
  background: #0f172a;
  color: #38bdf8;
}

:root[data-theme="dark"] .library-search-input,
:root[data-theme="dark"] .library-sort-select,
:root[data-theme="dark"] .filename-editor-input,
:root[data-theme="dark"] .pro-text-input,
:root[data-theme="dark"] .pro-select,
:root[data-theme="dark"] .rename-input {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

:root[data-theme="dark"] .filter-chip,
:root[data-theme="dark"] .filename-chip,
:root[data-theme="dark"] .btn-thumb-dl,
:root[data-theme="dark"] .btn-pl-util,
:root[data-theme="dark"] .btn-trim-clear,
:root[data-theme="dark"] .btn-modal-secondary,
:root[data-theme="dark"] .btn-history-tool,
:root[data-theme="dark"] .btn-history-rename,
:root[data-theme="dark"] .modal-close-btn,
:root[data-theme="dark"] .btn-dismiss-job {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

:root[data-theme="dark"] .filter-chip.active,
:root[data-theme="dark"] .filename-chip.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
}

:root[data-theme="dark"] .btn-history-play,
:root[data-theme="dark"] .btn-rename-shorten,
:root[data-theme="dark"] .btn-srt-dl,
:root[data-theme="dark"] .btn-retry-job {
  background: rgba(14, 165, 233, 0.18);
  border-color: #0369a1;
  color: #7dd3fc;
}

:root[data-theme="dark"] .btn-history-delete,
:root[data-theme="dark"] .btn-cancel-job {
  background: rgba(239, 68, 68, 0.16);
  border-color: #991b1b;
  color: #fca5a5;
}

:root[data-theme="dark"] .delete-note-box,
:root[data-theme="dark"] .playlist-detect-banner,
:root[data-theme="dark"] .bulk-action-bar {
  background: rgba(37, 99, 235, 0.16);
  border-color: #1d4ed8;
  color: #93c5fd;
}

:root[data-theme="dark"] .delete-choice-btn.soft {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

:root[data-theme="dark"] .delete-choice-btn.soft:hover:not(:disabled) {
  background: #273549;
  border-color: #38bdf8;
}

:root[data-theme="dark"] .delete-choice-btn.hard {
  background: rgba(185, 28, 28, 0.18);
  border-color: #991b1b;
  color: #fecaca;
}

:root[data-theme="dark"] .delete-choice-btn.hard:hover:not(:disabled) {
  background: rgba(185, 28, 28, 0.3);
  border-color: #ef4444;
}

:root[data-theme="dark"] .quick-toast,
:root[data-theme="dark"] .settings-feedback:not(.error),
:root[data-theme="dark"] .download-toast:not(.error) {
  background: rgba(22, 163, 74, 0.2);
  border-color: #15803d;
  color: #86efac;
}

:root[data-theme="dark"] .error-banner,
:root[data-theme="dark"] .active-job-item.failed {
  background: rgba(185, 28, 28, 0.2);
  border-color: #991b1b;
  color: #fecaca;
}

:root[data-theme="dark"] .filename-char-count,
:root[data-theme="dark"] .result-badge,
:root[data-theme="dark"] .count-pill {
  background: #1e293b;
  color: #7dd3fc;
}

:root[data-theme="dark"] .qr-url-display {
  color: #7dd3fc;
}

@media (max-width: 600px) {
  .qr-panel {
    flex-direction: column;
    text-align: center;
  }

  .btn-sm {
    align-self: center;
  }

  .trim-inputs-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Friend Sharing, Lock Screen Gate & Guest Banner (Light + Dark)
   ========================================================================== */

.guest-banner {
  background: linear-gradient(90deg, #0ea5e9 0%, #6366f1 100%);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
}

.guest-banner[hidden] {
  display: none;
}

.guest-banner-inner {
  max-width: 1020px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.btn-guest-logout {
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(15, 23, 42, 0.22);
  color: #ffffff;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-guest-logout:hover {
  background: rgba(15, 23, 42, 0.42);
}

/* Lock Screen Overlay */
.auth-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: linear-gradient(135deg, #0c4a6e 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-gate-overlay[hidden] {
  display: none;
}

.auth-gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.auth-gate-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 12px;
  border-radius: 18px;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.auth-gate-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-dark);
}

.auth-gate-sub {
  font-size: 13.5px;
  color: var(--text-subtle);
  margin-top: 4px;
}

.auth-gate-error {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

:root[data-theme="dark"] .auth-gate-error {
  color: #fecaca;
}

.auth-tabs {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: #f1f5f9;
}

:root[data-theme="dark"] .auth-tabs {
  background: #1e293b;
}

.auth-tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
}

.auth-tab-btn.active {
  background: var(--bg-white);
  color: var(--primary-blue-dark);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

:root[data-theme="dark"] .auth-tab-btn.active {
  background: #0f172a;
  color: #38bdf8;
}

.auth-form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.auth-form[hidden] {
  display: none;
}

.auth-submit-btn {
  height: 44px;
  font-size: 15px;
  width: 100%;
  margin-top: 4px;
}

/* Share Modal & Invite Rows */
.share-security-row,
.create-invite-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.create-invite-row input {
  flex: 1;
  min-width: 160px;
}

.create-invite-row select {
  width: auto;
  min-width: 125px;
}

.invite-created-box {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius-md);
  background: #ecfdf5;
  border: 1px solid #86efac;
}

.invite-created-box[hidden] {
  display: none;
}

:root[data-theme="dark"] .invite-created-box {
  background: rgba(22, 163, 74, 0.14);
  border-color: #15803d;
}

.invites-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-color);
}

:root[data-theme="dark"] .invite-row {
  background: #1e293b;
  border-color: #334155;
}

.invite-row.revoked,
.invite-row.expired {
  opacity: 0.72;
}

.invite-row-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.invite-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-dark);
}

.invite-row-sub {
  font-size: 12px;
  color: var(--text-subtle);
}

.owner-guest-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 8px;
  margin-left: 6px;
  border-radius: var(--radius-full);
  background: #ede9fe;
  color: #6d28d9;
  font-size: 11.5px;
  font-weight: 700;
  vertical-align: middle;
}

:root[data-theme="dark"] .owner-guest-pill {
  background: rgba(139, 92, 246, 0.24);
  color: #c4b5fd;
}

.invite-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
}

.invite-badge.active {
  background: #dcfce7;
  color: #15803d;
}

.invite-badge.revoked {
  background: #fee2e2;
  color: #b91c1c;
}

.invite-badge.expired {
  background: #e2e8f0;
  color: #475569;
}

:root[data-theme="dark"] .invite-badge.active {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

:root[data-theme="dark"] .invite-badge.revoked {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
}

:root[data-theme="dark"] .invite-badge.expired {
  background: #334155;
  color: #cbd5e1;
}

.invite-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-sm-pill {
  padding: 6px 10px;
  font-size: 12px;
}

@media (max-width: 600px) {
  .invite-created-box {
    flex-direction: column;
    text-align: center;
  }

  .invite-row {
    flex-direction: column;
    align-items: stretch;
  }

  .invite-row-actions {
    justify-content: flex-end;
  }
}

/* Direct Link & Zero-Disk Mode Styles */
.delivery-mode-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  margin-bottom: 14px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
}

.delivery-mode-bar[hidden] {
  display: none;
}

.delivery-mode-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}

.delivery-mode-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.delivery-mode-btn.active {
  background: #ffffff;
  color: #0369a1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

.delivery-mode-btn[data-delivery="direct"].active {
  background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
  color: #713f12;
  box-shadow: 0 4px 14px rgba(250, 204, 21, 0.35);
}

:root[data-theme="dark"] .delivery-mode-bar {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.26);
}

:root[data-theme="dark"] .delivery-mode-btn.active {
  background: #0284c7;
  color: #ffffff;
}

:root[data-theme="dark"] .delivery-mode-btn[data-delivery="direct"].active {
  background: linear-gradient(135deg, #facc15 0%, #eab308 100%);
  color: #1e293b;
}

.btn-download-main.direct-active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.btn-download-main.direct-active:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.direct-mode-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ecfdf5 0%, #f0f9ff 100%);
  border: 1px solid #a7f3d0;
  color: #065f46;
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
}

.direct-mode-banner.strict {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fcd34d;
  color: #92400e;
}

:root[data-theme="dark"] .direct-mode-banner {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(52, 211, 153, 0.32);
  color: #6ee7b7;
}

:root[data-theme="dark"] .direct-mode-banner.strict {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(251, 191, 36, 0.34);
  color: #fde68a;
}

.quality-row.muted {
  opacity: 0.62;
}

.quality-pill.direct-cdn {
  background: #dcfce7;
  color: #15803d;
}

.quality-pill.direct-stream {
  background: #e0f2fe;
  color: #0369a1;
}

.quality-pill.ephemeral {
  background: #fef3c7;
  color: #b45309;
}

.quality-pill.server-only {
  background: #f1f5f9;
  color: #64748b;
}

:root[data-theme="dark"] .quality-pill.direct-cdn {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

:root[data-theme="dark"] .quality-pill.direct-stream {
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
}

:root[data-theme="dark"] .quality-pill.ephemeral {
  background: rgba(245, 158, 11, 0.22);
  color: #fcd34d;
}

:root[data-theme="dark"] .quality-pill.server-only {
  background: rgba(148, 163, 184, 0.18);
  color: #94a3b8;
}

.direct-btn-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  flex-shrink: 0;
}

.btn-direct-cdn,
.btn-direct-stream,
.btn-direct-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 13px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease;
}

.btn-direct-cdn {
  border: none;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.26);
}

.btn-direct-cdn.stream {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  box-shadow: 0 3px 10px rgba(14, 165, 233, 0.26);
}

.btn-direct-cdn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn-direct-stream {
  border: 1px solid #bae6fd;
  background: #f0f9ff;
  color: #0369a1;
}

.btn-direct-stream:hover {
  background: #e0f2fe;
}

:root[data-theme="dark"] .btn-direct-stream {
  background: rgba(14, 165, 233, 0.16);
  border-color: rgba(56, 189, 248, 0.34);
  color: #7dd3fc;
}

.btn-direct-copy {
  border: 1px solid var(--border-color);
  background: var(--surface-alt);
  color: var(--text-primary);
}

.btn-direct-copy:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-direct-copy.copied {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

:root[data-theme="dark"] .btn-direct-copy.copied {
  background: rgba(34, 197, 94, 0.24);
  border-color: rgba(74, 222, 128, 0.4);
  color: #86efac;
}

.btn-download-choice.ephemeral {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.btn-download-choice.ephemeral:hover:not(:disabled) {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

.direct-locked-note {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.direct-empty-note {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

.create-invite-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invite-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
}

.invite-mode-badge.direct {
  background: #fef3c7;
  color: #b45309;
}

.invite-mode-badge.hybrid {
  background: #e0f2fe;
  color: #0369a1;
}

.invite-mode-badge.full {
  background: #ede9fe;
  color: #6d28d9;
}

:root[data-theme="dark"] .invite-mode-badge.direct {
  background: rgba(245, 158, 11, 0.22);
  color: #fcd34d;
}

:root[data-theme="dark"] .invite-mode-badge.hybrid {
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
}

:root[data-theme="dark"] .invite-mode-badge.full {
  background: rgba(139, 92, 246, 0.24);
  color: #c4b5fd;
}

.security-hardening-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border-color);
}

.security-status-info {
  font-size: 12.5px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 200px;
}

.btn-danger-outline {
  border: 1px solid #fca5a5;
  background: #fef2f2;
  color: #dc2626;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.12s ease;
}

.btn-danger-outline:hover:not(:disabled) {
  background: #fee2e2;
  transform: translateY(-1px);
}

:root[data-theme="dark"] .btn-danger-outline {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

:root[data-theme="dark"] .btn-danger-outline:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
}

.security-log-details {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-secondary);
}

.security-log-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
}

.security-log-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 150px;
  overflow-y: auto;
}

.security-log-list li {
  line-height: 1.4;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border-color);
}

.security-log-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sec-log-time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-right: 4px;
}

.btn-apk-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(14, 165, 233, 0.25);
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-apk-download:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

/* Responsive */
@media (max-width: 900px) {
  .history-item {
    flex-wrap: wrap;
    align-items: center;
  }

  .history-item-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
  }
}

@media (max-width: 768px) {
  .active-card,
  .history-card {
    padding: 16px 14px;
  }
  .delivery-mode-bar {
    display: flex;
    width: 100%;
    justify-content: center;
  }

  .delivery-mode-btn {
    flex: 1;
    font-size: 12.5px;
    padding: 8px 10px;
  }

  .direct-btn-group {
    width: 100%;
    justify-content: stretch;
  }

  .direct-btn-group > * {
    flex: 1;
    justify-content: center;
  }
  .header-container {
    flex-wrap: wrap;
  }

  .download-form {
    flex-direction: column;
  }

  .btn-download-main {
    width: 100%;
  }

  .batch-actions-row,
  .batch-submit-group {
    flex-direction: column;
    align-items: stretch;
  }

  .preset-select {
    width: 100%;
  }

  .library-search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .result-video-info {
    flex-direction: column;
  }

  .result-thumb-wrapper {
    width: 100%;
  }

  .quality-row {
    flex-direction: column;
    align-items: stretch;
  }

  .history-item {
    flex-wrap: wrap;
    align-items: center;
  }

  .history-item-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: 6px;
    border-top: 1px dashed var(--border-color);
  }

  .btn-download-choice {
    justify-content: center;
  }

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