@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;600;800;900&family=Nunito+Sans:ital,wght@0,400;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* === Reset & Base === */

:root {
  --bg:             #0e0e10;
  --surface:        #18181b;
  --surface-raised: #222228;
  --border:         #2c2c32;
  --border-focus:   #e8a040;

  --text:           #eae6e1;
  --text-secondary: #85817c;
  --text-hint:      #5c5955;

  --accent:         #e8a040;
  --accent-hover:   #d49030;
  --accent-glow:    rgba(232, 160, 64, 0.12);
  --accent-text:    #111;
  --error:          #e85c4a;
  --error-bg:       rgba(232, 92, 74, 0.08);
  --success:        #4aba7a;
  --success-bg:     rgba(74, 186, 122, 0.08);

  --radius:         6px;
  --radius-lg:      10px;
  --font-display:   'Archivo', system-ui, sans-serif;
  --font-body:      'Nunito Sans', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  line-height: 1.55;
}

/* subtle noise overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* === Layout === */

.app {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* === Header & Logo === */

.header { text-align: center; }

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.logo h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2.2rem;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.4rem;
}

/* === Platforms === */

.platforms {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
}

.platforms img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: contain;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 2px;
  transition: filter 0.2s;
  filter: brightness(0.95) saturate(0.85);
  cursor: default;
}

.platforms img:hover {
  filter: brightness(1.1) saturate(1);
}

.platform-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.5rem 0.75rem;
  height: 32px;
  min-width: 32px;
  transition: filter 0.2s, border-color 0.2s, color 0.2s;
  letter-spacing: 0.01em;
  cursor: default;
  filter: brightness(0.95) saturate(0.85);
}

.platform-chip:hover {
  filter: brightness(1.1) saturate(1);
  border-color: var(--accent);
  color: var(--text);
}

.platform-chip-text {
  font-family: var(--font-mono);
  font-weight: 500;
}

/* === URL Input === */

.url-section { display: flex; flex-direction: column; gap: 0.5rem; }

.url-bar {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.url-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.url-bar.shake {
  animation: shake 0.4s ease;
}

.url-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  outline: none;
  min-width: 0;
}

.url-bar input::placeholder { color: var(--text-hint); }

.fetch-btn {
  background: var(--accent);
  border: none;
  color: var(--accent-text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0 1.25rem;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.fetch-btn:hover { background: var(--accent-hover); }
.fetch-btn:active:not(:disabled) { background: var(--accent-hover); }
.fetch-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.url-hint {
  font-size: 0.75rem;
  color: var(--text-hint);
  text-align: center;
}

.url-hint strong { color: var(--text-secondary); }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: var(--accent-text);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* === Info Card === */

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.875rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  animation: slideUp 0.3s ease;
}

.thumb-wrap {
  position: relative;
  flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.thumb-wrap img {
  display: block;
  width: 180px;
  height: auto;
  object-fit: cover;
  aspect-ratio: 16 / 9;
  background: var(--surface-raised);
}

.duration-badge {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.03em;
}

.info-details { flex: 1; min-width: 0; }

.info-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

.info-uploader {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

/* === Options & Mode Tabs === */

.options-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: slideUp 0.3s ease;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.mode-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.7rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: all 0.2s;
  position: relative;
}

.mode-tab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-block;
}

.mode-tab.active {
  background: var(--accent);
  color: var(--accent-text);
}

.mode-tab:not(.active):hover {
  background: var(--surface-raised);
  color: var(--text);
}

.mode-tab:not(.active):active {
  background: var(--surface-raised);
}

.options-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.option-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.select {
  appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2385817c'/%3E%3C/svg%3E") no-repeat right 0.65rem center;
  background-size: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.55rem 2rem 0.55rem 0.7rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.select:hover { border-color: var(--text-secondary); }
.select:focus { border-color: var(--accent); }

.advanced-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.3rem 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.15s;
}

.advanced-toggle:hover { color: var(--text); }

.advanced-chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.advanced-toggle.open .advanced-chevron {
  transform: rotate(180deg);
}

.advanced-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.advanced-hint {
  font-size: 0.7rem;
  color: var(--text-hint);
  margin-top: 0.25rem;
  line-height: 1.45;
}

/* === Clip Segment === */

.clip-toggle-row {
  display: flex;
  align-items: center;
  margin: 0.15rem 0;
}

.clip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.clip-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.clip-toggle-track {
  position: relative;
  width: 34px;
  height: 18px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.clip-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.clip-toggle input:checked + .clip-toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.clip-toggle input:checked + .clip-toggle-track .clip-toggle-knob {
  transform: translateX(16px);
}

.clip-toggle input:focus-visible + .clip-toggle-track {
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.clip-toggle input:disabled + .clip-toggle-track {
  opacity: 0.35;
  cursor: not-allowed;
}

.clip-toggle input:disabled ~ .clip-toggle-label {
  opacity: 0.35;
  cursor: not-allowed;
}

.clip-toggle-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.clip-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  animation: slideUp 0.3s ease;
}

.clip-inputs {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.clip-inputs .option-group {
  flex: 1;
}

.clip-separator {
  color: var(--text-hint);
  font-size: 1rem;
  padding-bottom: 0.55rem;
  flex-shrink: 0;
}

.clip-time-input {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.55rem 0.7rem;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}

.clip-time-input::placeholder {
  color: var(--text-hint);
}

.clip-time-input:focus {
  border-color: var(--accent);
}

.clip-time-input.invalid {
  border-color: var(--error);
}

.clip-error {
  color: var(--error);
  font-size: 0.72rem;
  margin-top: 0.4rem;
  line-height: 1.4;
}

.clip-hint {
  font-size: 0.7rem;
  color: var(--text-hint);
  margin-top: 0.25rem;
  line-height: 1.45;
}

/* === Download & Cancel === */

.download-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-lg);
  color: var(--accent-text);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  padding: 0.8rem 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.01em;
}

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

.download-btn:active:not(:disabled) { transform: translateY(0); }

.download-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.download-btn svg {
  width: 20px;
  height: 20px;
}

.cancel-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.4rem 1rem;
  cursor: pointer;
  align-self: center;
  transition: color 0.15s, border-color 0.15s;
}

.cancel-btn:hover {
  color: var(--error);
  border-color: var(--error);
}

.cancel-btn:active {
  color: var(--error);
  border-color: var(--error);
}

.cancel-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === Progress === */

.progress-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  animation: slideUp 0.3s ease;
  transition: border-color 0.3s;
}

.progress-section.is-complete {
  border-color: var(--success);
}

.dl-progress { display: flex; flex-direction: column; gap: 0.55rem; }

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.progress-row span:first-child {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.progress-pct {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
}

.progress-track {
  height: 6px;
  background: var(--surface-raised);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f0c060);
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease;
  position: relative;
}

.progress-fill.active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  animation: shimmer 1.5s ease infinite;
}

.progress-fill.phase-save {
  background: linear-gradient(90deg, var(--accent), var(--success));
}

.progress-fill.phase-save.active::after {
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.25) 50%, transparent 100%);
  animation: shimmer 1.2s ease infinite;
}

.progress-fill.indeterminate {
  width: 100% !important;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.progress-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  min-height: 1.1em;
  letter-spacing: 0.02em;
}

.dl-complete {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.complete-check {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--success-bg);
  border: 2px solid var(--success);
  color: var(--success);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: popIn 0.3s ease;
}

.complete-text { flex: 1; min-width: 0; }

.complete-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.complete-filename {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
}

.complete-filename-link {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.complete-filename-link:hover {
  color: var(--accent-hover);
  text-decoration: none;
}

.complete-support {
  font-size: 0.72rem;
  color: var(--text-hint);
  margin-top: 0.5rem;
}

.complete-support a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.complete-support a:hover {
  text-decoration: underline;
}

/* === Toast Notifications === */

.toast-container {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top, 0px));
  right: max(1rem, env(safe-area-inset-right, 0px));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  line-height: 1.4;
  max-width: 380px;
  transform: translateX(calc(100% + 1rem));
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-left-width: 4px;
  color: var(--text);
}

.toast-visible { transform: translateX(0); }

.toast-error { border-left-color: var(--error); }
.toast-success { border-left-color: var(--success); }
.toast-info { border-left-color: var(--accent); }

.toast-icon {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
  color: inherit;
}

.toast-error .toast-icon { color: var(--error); }
.toast-success .toast-icon { color: var(--success); }
.toast-info .toast-icon { color: var(--accent); }

.toast-body { flex: 1; min-width: 0; }

.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.toast-close:hover { opacity: 1; }

/* === Footer === */

.footer {
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.footer p {
  font-size: 0.72rem;
  color: var(--text-hint);
}

.footer strong { color: var(--text-secondary); font-weight: 600; }

.footer-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
  font-size: 0.72rem;
}

.footer-nav a {
  color: var(--text-hint);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-nav a:hover { color: var(--accent); }

.footer-dot { color: var(--text-hint); }

/* === Legal Pages === */

.legal-page { gap: 0; }

.legal-page h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.legal-updated {
  font-size: 0.78rem;
  color: var(--text-hint);
  margin-bottom: 1.5rem;
}

.legal-page section {
  margin-bottom: 1.5rem;
}

.legal-page h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.legal-page p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 0.5rem;
}

.legal-page ul {
  list-style: disc;
  padding-left: 1.25rem;
  margin-bottom: 0.5rem;
}

.legal-page li {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 0.25rem;
}

.legal-page a {
  color: var(--accent);
  text-decoration: none;
}

.legal-page a:hover { text-decoration: underline; }

.legal-page .footer { margin-top: 1.5rem; }

.back-link {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--text-hint);
  text-decoration: none;
  margin-bottom: 1.25rem;
  transition: color 0.15s;
}

.back-link:hover { color: var(--accent); }

/* === Changelog === */

.changelog-entry {
  margin-bottom: 2rem;
}

.changelog-version-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.changelog-version {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent-text);
  background: var(--accent);
  padding: 0.15rem 0.6rem;
  border-radius: 3px;
  letter-spacing: 0.02em;
}

.changelog-date {
  font-size: 0.78rem;
  color: var(--text-hint);
  font-family: var(--font-mono);
}

/* === Error Page === */

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 2rem 1rem;
}

.error-code {
  font-family: var(--font-mono);
  font-size: 6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin: 0;
}

.error-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text);
  margin: 0.75rem 0 0.5rem;
}

.error-message {
  font-family: var(--font-body);
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 360px;
  margin: 0 auto 2rem;
}

.error-home {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.15s ease;
}

.error-home:hover {
  background: var(--accent-hover);
}

/* === Utilities & Animations === */

.hidden { display: none !important; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(200%); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes popIn {
  0% { transform: scale(0); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* === Focus Visible === */

.select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.fetch-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.download-btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.mode-tab:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.cancel-btn:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

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

.footer-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.error-home:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* === Touch Targets === */

@media (pointer: coarse) {
  .select { min-height: 44px; font-size: 0.9rem; }
  .mode-tab { min-height: 44px; }
  .fetch-btn { min-height: 44px; }
  .download-btn { min-height: 48px; }
  .cancel-btn { min-height: 44px; padding: 0.5rem 1.2rem; }
  .advanced-toggle { min-height: 44px; }
  .clip-time-input { min-height: 44px; }
  .back-link { padding: 0.25rem 0; }
  .footer-nav a { padding: 0.35rem 0.25rem; }
}

/* === Responsive === */

@media (max-width: 768px) {
  .app { padding: 2rem 1rem 3.5rem; gap: 1.5rem; }
  .thumb-wrap img { width: 150px; }
  .info-title { font-size: 0.9rem; }
}

@media (max-width: 500px) {
  .app { padding: 1.5rem 1rem 5rem; gap: 1.25rem; }
  .logo h1 { font-size: 1.8rem; }
  .info-card { flex-direction: column; align-items: center; text-align: center; }
  .thumb-wrap img { width: 100%; max-width: 280px; }
  .info-title { -webkit-line-clamp: 2; line-clamp: 2; }
  .options-row { grid-template-columns: 1fr; }
  .progress-meta { word-break: break-all; }
  .toast { max-width: calc(100vw - 2rem); }
  .toast-container { left: 1rem; }
  .error-code { font-size: 4rem; }
  .error-title { font-size: 1.2rem; }
  .floatingchat-container-wrap,
  .floatingchat-container-wrap-mo498 { transform: scale(0.75); transform-origin: bottom right; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .app { padding-top: 1rem; padding-bottom: 2rem; gap: 1rem; }
  .platforms { gap: 0.3rem; }
  .platforms img { width: 26px; height: 26px; }
  .platform-chip { height: 26px; font-size: 0.65rem; padding: 0.3rem 0.6rem; }
  .logo h1 { font-size: 1.6rem; }
}

@supports (padding: max(0px)) {
  .app {
    padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
  }
}
