:root {
  --bg-page: #ffffff;
  --bg-surface: #ffffff;
  --bg-soft: #f5f8ff;
  --bg-muted: #f2f5fa;
  --blue-primary: #007aff;
  --blue-hover: #0066d6;
  --blue-active: #0054b4;
  --blue-tint: #eaf3ff;
  --blue-border: rgba(0, 122, 255, 0.22);
  --text-primary: #0f172a;
  --text-secondary: #5c6b82;
  --text-muted: #8b98ad;
  --border-subtle: rgba(15, 23, 42, 0.08);
  --shadow-island: 0 10px 30px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-card: 0 20px 50px rgba(0, 82, 204, 0.07), 0 2px 8px rgba(15, 23, 42, 0.04);
  --radius-card: 28px;
  --radius-control: 16px;
  --radius-pill: 999px;
  --danger-bg: #fff2f2;
  --danger-text: #c81e1e;
  --danger-border: rgba(200, 30, 30, 0.16);
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter',
    system-ui, sans-serif;
  color: var(--text-primary);
  background: radial-gradient(circle at 50% -10%, #eef5ff 0%, #ffffff 55%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.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;
}

.hidden {
  display: none !important;
}

/* ================================
   iOS Dynamic Island Style Navbar
   ================================ */
.navbar-wrapper {
  position: sticky;
  top: 16px;
  z-index: 50;
  display: flex;
  justify-content: center;
  padding: 0 20px;
  pointer-events: none;
}

.island-nav {
  pointer-events: auto;
  width: 100%;
  max-width: 640px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px 12px 16px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: var(--shadow-island);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.island-nav:hover {
  box-shadow: 0 14px 36px rgba(0, 122, 255, 0.11), 0 2px 6px rgba(15, 23, 42, 0.05);
}

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

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, #2d95ff, var(--blue-primary));
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.32);
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.island-links {
  display: inline-flex;
  align-items: center;
  gap: 20px;
}

.island-link {
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  color: #6b7280;
  transition: color 0.18s ease;
}

.island-link:hover,
.island-link.is-active {
  color: var(--text-primary);
}

.island-link.is-active {
  font-weight: 650;
}

/* ================================
   Main Content & Hero
   ================================ */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 36px 20px 52px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.hero {
  text-align: center;
  margin-bottom: 22px;
}

.hero-title {
  margin: 0 0 10px;
  font-size: clamp(1.85rem, 4vw, 2.45rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.12;
  color: var(--text-primary);
}

.hero-subtitle {
  margin: 0;
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ================================
   Converter Container Card
   ================================ */
.converter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.converter-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.url-field {
  position: relative;
  display: flex;
  align-items: center;
}

.url-icon {
  position: absolute;
  left: 16px;
  display: inline-flex;
  color: var(--blue-primary);
  pointer-events: none;
}

.url-input {
  width: 100%;
  height: 54px;
  padding: 0 42px 0 46px;
  font: inherit;
  font-size: 0.98rem;
  color: var(--text-primary);
  background: var(--bg-muted);
  border: 1.5px solid transparent;
  border-radius: var(--radius-control);
  outline: none;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.url-input:focus {
  background: #ffffff;
  border-color: var(--blue-primary);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.14);
}

.clear-btn {
  position: absolute;
  right: 12px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.clear-btn:hover {
  background: rgba(15, 23, 42, 0.15);
  color: var(--text-primary);
}

.controls-row {
  display: grid;
  grid-template-columns: 204px 1fr;
  gap: 12px;
  align-items: stretch;
}

/* iOS Segmented Radio Control */
.format-radio-group {
  margin: 0;
  padding: 4px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  background: var(--bg-muted);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  height: 50px;
}

.radio-option {
  position: relative;
  display: flex;
  cursor: pointer;
  margin: 0;
}

.radio-option input[type='radio'] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.radio-pill {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--text-secondary);
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.radio-option input[type='radio']:checked + .radio-pill {
  background: #ffffff;
  color: var(--blue-primary);
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.15), 0 1px 2px rgba(15, 23, 42, 0.06);
}

.radio-option input[type='radio']:focus-visible + .radio-pill {
  outline: 2px solid var(--blue-primary);
  outline-offset: 1px;
}

.radio-option:hover .radio-pill {
  color: var(--text-primary);
}

.radio-option input[type='radio']:checked:hover + .radio-pill {
  color: var(--blue-primary);
}

/* Buttons */
.btn {
  height: 50px;
  padding: 0 22px;
  border: none;
  border-radius: var(--radius-control);
  font: inherit;
  font-size: 0.96rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.12s ease, box-shadow 0.2s ease,
    opacity 0.2s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

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

.btn-primary {
  background: var(--blue-primary);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(0, 122, 255, 0.26);
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue-hover);
  box-shadow: 0 10px 24px rgba(0, 122, 255, 0.34);
}

.btn-primary:active:not(:disabled) {
  background: var(--blue-active);
}

.btn-secondary {
  background: var(--blue-tint);
  color: var(--blue-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: #dcebff;
}

/* Error Box */
.error-box {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  animation: fadeSlideIn 0.22s ease;
}

.error-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--danger-text);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.error-text {
  margin: 0;
  line-height: 1.4;
}

/* ================================
   Result Panel (Replaces Form)
   ================================ */
.result-panel {
  animation: fadeSlideIn 0.25s ease;
}

.media-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border-radius: 20px;
  background: var(--bg-soft);
  border: 1px solid rgba(0, 122, 255, 0.12);
}

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

.media-title {
  margin: 0 0 4px;
  font-size: 0.98rem;
  font-weight: 650;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.32;
}

.media-meta {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.process-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2.2px solid rgba(0, 122, 255, 0.2);
  border-top-color: var(--blue-primary);
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

.status-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue-primary);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-text {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--blue-primary);
}

.format-badge {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--blue-primary);
  background: #ffffff;
  border: 1px solid var(--blue-border);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.progress-track {
  width: 100%;
  height: 5px;
  border-radius: var(--radius-pill);
  background: rgba(0, 122, 255, 0.14);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #3ba1ff, var(--blue-primary));
  transition: width 0.35s ease;
}

.progress-bar.is-indeterminate {
  width: 42%;
  animation: indeterminate 1.3s ease-in-out infinite;
}

/* Right Side Small Thumbnail */
.thumb-col {
  flex-shrink: 0;
  width: 132px;
  aspect-ratio: 16 / 9;
  border-radius: 13px;
  overflow: hidden;
  background: #e6eefc;
  position: relative;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.thumb-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #e7effd 25%, #f3f7ff 50%, #e7effd 75%);
  background-size: 200% 100%;
  animation: shimmer 1.25s infinite;
  transition: opacity 0.25s ease;
}

.thumb-skeleton.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.media-thumb {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.media-thumb.is-loaded {
  opacity: 1;
}

/* Action Buttons (Download & Convert More) */
.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
  animation: fadeSlideIn 0.25s ease;
}

/* ================================
   3-Step Instructions
   ================================ */
.steps-section {
  margin-top: 34px;
}

.steps-heading {
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
}

.steps-heading::before,
.steps-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.step-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 18px 16px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.03);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--blue-tint);
  color: var(--blue-primary);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.step-title {
  margin: 0 0 6px;
  font-size: 0.94rem;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.step-desc {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.48;
  color: var(--text-secondary);
}

/* ================================
   Simple Footer
   ================================ */
.site-footer {
  width: 100%;
  margin-top: auto;
  padding: 0 20px;
}

.footer-inner {
  max-width: 640px;
  margin: 0 auto;
  border-top: 1px solid var(--border-subtle);
  padding: 20px 0 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 20px;
}

.footer-link {
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.18s ease;
}

.footer-link:hover,
.footer-link.is-active {
  color: var(--blue-primary);
}

/* ================================
   Subpages (FAQ, Contact & Legal)
   ================================ */
.page-header {
  text-align: center;
  margin-bottom: 24px;
}

.page-title {
  margin: 0 0 8px;
  font-size: clamp(1.65rem, 3.6vw, 2.15rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.page-subtitle {
  margin: 0;
  font-size: 0.96rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.page-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 28px;
  box-shadow: var(--shadow-card);
}

/* FAQ Accordion */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  background: var(--bg-soft);
  overflow: hidden;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.faq-item[open] {
  background: #ffffff;
  border-color: var(--blue-border);
}

.faq-question {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  font-size: 0.96rem;
  font-weight: 650;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: '';
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  margin-right: 4px;
  border-right: 2.2px solid var(--blue-primary);
  border-bottom: 2.2px solid var(--blue-primary);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.22s ease;
}

.faq-item[open] .faq-question::after {
  transform: translateY(2px) rotate(-135deg);
}

.faq-answer {
  padding: 0 18px 16px;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Legal & Contact Typography */
.legal-content h2 {
  margin: 24px 0 8px;
  font-size: 1.04rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.legal-content h2:first-child {
  margin-top: 0;
}

.legal-content p {
  margin: 0 0 12px;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.legal-content ul {
  margin: 0 0 14px;
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.65;
}

.legal-content li {
  margin-bottom: 6px;
}

.legal-content a {
  color: var(--blue-primary);
  text-decoration: none;
  font-weight: 500;
}

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

.legal-updated {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 13px 15px;
  font: inherit;
  font-size: 0.94rem;
  color: var(--text-primary);
  background: var(--bg-muted);
  border: 1.5px solid transparent;
  border-radius: var(--radius-control);
  outline: none;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:focus,
.form-textarea:focus {
  background: #ffffff;
  border-color: var(--blue-primary);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.14);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}

.contact-submit {
  width: 100%;
  margin-top: 4px;
}

/* 404 Page */
.not-found-main {
  justify-content: center;
  padding-top: 40px;
  padding-bottom: 52px;
}

.not-found-card {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 46px 32px 38px;
}

.not-found-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 220px;
  background: radial-gradient(circle at 50% 0%, rgba(0, 122, 255, 0.11) 0%, rgba(0, 122, 255, 0) 70%);
  pointer-events: none;
}

.not-found-code {
  position: relative;
  margin: 0 0 14px;
  font-size: clamp(4.25rem, 11vw, 5.75rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.055em;
  background: linear-gradient(180deg, #0f172a 0%, #334155 62%, #94a3b8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  user-select: none;
}

.not-found-title {
  position: relative;
  margin: 0 0 10px;
  font-size: clamp(1.35rem, 3vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.not-found-desc {
  position: relative;
  max-width: 410px;
  margin: 0 auto 28px;
  font-size: 0.95rem;
  line-height: 1.58;
  color: var(--text-secondary);
}

.not-found-actions {
  position: relative;
  display: inline-flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.not-found-actions .btn {
  min-width: 172px;
}

.not-found-links-section {
  margin-top: 20px;
}

.not-found-links-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.quick-link-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-decoration: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 18px 16px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.03);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.quick-link-card:hover {
  transform: translateY(-2px);
  border-color: var(--blue-border);
  box-shadow: 0 12px 26px rgba(0, 122, 255, 0.09);
}

.quick-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--blue-tint);
  color: var(--blue-primary);
  margin-bottom: 10px;
}

.quick-link-title {
  font-size: 0.94rem;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.quick-link-desc {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.footer-copy {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

@keyframes indeterminate {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(260%);
  }
}

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

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

/* Responsive */
@media (max-width: 560px) {
  .main-content {
    padding: 36px 16px 48px;
  }

  .converter-card {
    padding: 18px;
    border-radius: 22px;
  }

  .controls-row,
  .result-actions,
  .steps-grid,
  .not-found-links-grid {
    grid-template-columns: 1fr;
  }

  .not-found-card {
    padding: 34px 20px 28px;
  }

  .not-found-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .not-found-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .page-card {
    padding: 20px;
    border-radius: 22px;
  }

  .media-status-row {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 14px;
    padding: 14px;
  }

  .media-info-col {
    width: 100%;
  }

  .navbar-wrapper {
    padding: 0 16px;
  }

  .thumb-col {
    width: 100%;
    border-radius: 14px;
  }
}
