:root {
  --bg: #0f0f12;
  --surface: #18181c;
  --border: #2a2a30;
  --text: #e8e8ec;
  --muted: #888894;
  --accent: #fe2c55;
  --accent-hover: #ff4d6d;
  --success: #25f4a0;
  --error: #ff4757;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  text-align: center;
  margin-bottom: 2.5rem;
}

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

.logo-icon {
  font-size: 1.75rem;
  color: var(--accent);
}

.logo h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.main {
  flex: 1;
}

.form {
  margin-bottom: 1.5rem;
}

.input-wrap {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.input {
  flex: 1;
  min-width: 0;
  padding: 0.875rem 1rem;
  font: inherit;
  font-size: 16px; /* prevents zoom on focus in iOS */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.input:hover {
  border-color: #3a3a42;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(254, 44, 85, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  min-width: 120px;
}

.btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

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

.btn-loader {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn.loading .btn-text {
  visibility: hidden;
}

.btn.loading .btn-loader {
  display: block;
  position: absolute;
}

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

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.message {
  min-height: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.message.error {
  color: var(--error);
}

.message.success {
  color: var(--success);
}

.result {
  margin-top: 1rem;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.result-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

.result-card h3.result-actions-title {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.video-preview-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  margin-bottom: 0.5rem;
}

.video-preview {
  display: block;
  width: 100%;
  max-height: 360px;
  vertical-align: middle;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.result-actions a,
.result-actions button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s;
}

.result-actions a:hover,
.result-actions button:hover {
  background: var(--accent-hover);
}

.result-actions .secondary {
  background: var(--border);
  color: var(--text);
}

.result-actions .secondary:hover {
  background: #3a3a42;
}

.external-preview {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.external-preview-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

.external-preview-iframe {
  display: block;
  width: 100%;
  height: 280px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.footer {
  margin-top: 2rem;
  padding-top: 2rem;
  padding-bottom: env(safe-area-inset-bottom, 0);
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Mobile-friendly layout */
@media (max-width: 600px) {
  .page {
    padding: 1.25rem 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .header {
    margin-bottom: 1.75rem;
  }

  .logo h1 {
    font-size: 1.5rem;
  }

  .logo-icon {
    font-size: 1.5rem;
  }

  .tagline {
    font-size: 0.9rem;
  }

  .input-wrap {
    flex-direction: column;
    gap: 0.75rem;
  }

  .input-wrap .btn {
    width: 100%;
    min-width: 0;
    padding: 1rem 1.5rem;
    min-height: 48px;
  }

  .input {
    min-height: 48px;
  }

  .result-card {
    padding: 1rem;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions a,
  .result-actions button {
    width: 100%;
    justify-content: center;
    padding: 0.875rem 1rem;
    min-height: 48px;
  }

  .video-preview {
    max-height: 280px;
  }

  .external-preview {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
  }

  .external-preview-iframe {
    height: 200px;
    min-height: 160px;
  }

  .footer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
  }
}

/* Large touch targets for any interactive element */
@media (pointer: coarse) {
  .btn {
    min-height: 48px;
  }

  .result-actions a,
  .result-actions button {
    min-height: 48px;
  }
}
