:root {
  --bg: #0b0d12;
  --bg-elevated: #141824;
  --surface: #1a2030;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f2f4f8;
  --text-muted: #9aa3b5;
  --accent: #3dd6c6;
  --accent-dim: #2aa89b;
  --primary: #6ea8ff;
  --primary-dim: #4d86e0;
  --danger: #ff6b7a;
  --success: #5ddea0;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font-display: 'Outfit', 'IBM Plex Sans KR', sans-serif;
  --font-body: 'IBM Plex Sans KR', 'Outfit', sans-serif;
}

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

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

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(61, 214, 198, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 20%, rgba(110, 168, 255, 0.12), transparent 50%),
    linear-gradient(180deg, #0e121c 0%, var(--bg) 45%, #080a10 100%);
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  width: min(100%, 440px);
  margin: 0 auto;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem
    max(2.5rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 100dvh;
}

.brand {
  text-align: center;
  padding-top: 1.25rem;
  animation: fade-up 0.55s ease both;
}

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 10vw, 3rem);
  letter-spacing: -0.04em;
  margin: 0;
  background: linear-gradient(120deg, #fff 20%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

.panel {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  animation: fade-up 0.55s ease 0.08s both;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

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

#url-input {
  flex: 1;
  min-width: 0;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#url-input::placeholder {
  color: #667085;
}

#url-input:focus {
  border-color: color-mix(in srgb, var(--primary) 70%, transparent);
  box-shadow: 0 0 0 3px rgba(110, 168, 255, 0.18);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.85rem 1rem;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
  touch-action: manipulation;
}

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

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

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dim));
  color: #081018;
}

.btn-accent {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #061412;
}

.btn-ghost {
  flex-shrink: 0;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  padding-inline: 0.85rem;
  font-size: 0.85rem;
}

.status-msg {
  margin: 0;
  min-height: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.status-msg.is-error {
  color: var(--danger);
}

.status-msg.is-loading {
  color: var(--primary);
}

.result {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  animation: fade-up 0.45s ease both;
}

.result.hidden {
  display: none;
}

.video-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-wrap {
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  aspect-ratio: 9 / 16;
  max-height: min(58vh, 520px);
  margin-inline: auto;
  width: 100%;
}

#preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.save-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  line-height: 1.45;
}

.save-hint.hidden {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  transform: translate(-50%, 120%);
  z-index: 50;
  max-width: min(92vw, 380px);
  padding: 0.8rem 1.1rem;
  border-radius: 999px;
  background: #222838;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s ease, opacity 0.28s ease;
  text-align: center;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.toast.is-success {
  border-color: rgba(93, 222, 160, 0.35);
  color: var(--success);
}

.toast.is-error {
  border-color: rgba(255, 107, 122, 0.35);
  color: var(--danger);
}

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

@media (min-width: 640px) {
  .app {
    padding-top: 2.5rem;
  }
}
