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

:root {
  --bg: #080808;
  --card-bg: #111111;
  --border: #1e1e1e;
  --border-focus: #6366f1;
  --accent: #6366f1;
  --accent-hover: #4f52d9;
  --text: #f0f0f0;
  --muted: #666;
  --error: #f87171;
  --success: #4ade80;
  --info: #94a3b8;
  --radius: 14px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
}

/* background grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

main {
  width: 100%;
  max-width: 480px;
  position: relative;
  z-index: 1;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* glow behind card */
.card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--radius) + 1px);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), transparent 60%);
  pointer-events: none;
  z-index: -1;
}

.header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  flex-shrink: 0;
}

h1 {
  font-family: 'Syne', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-top: -0.75rem;
}

#form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.input-wrap {
  position: relative;
}

#url-input {
  width: 100%;
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

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

#url-input:focus {
  border-color: var(--border-focus);
}

#url-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.format-toggle {
  display: flex;
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.fmt-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.04em;
}

.fmt-btn:hover:not(.active) {
  color: var(--text);
}

.fmt-btn.active {
  background: var(--accent);
  color: #fff;
}

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

#btn {
  width: 100%;
  padding: 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.2s, opacity 0.2s, transform 0.1s;
  min-height: 48px;
}

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

#btn:active:not(:disabled) {
  transform: scale(0.99);
}

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

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

#status {
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  line-height: 1.5;
  animation: fadein 0.2s ease;
}

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

#status.error {
  color: var(--error);
  background: rgba(248, 113, 113, 0.06);
  border-color: rgba(248, 113, 113, 0.2);
}

#status.success {
  color: var(--success);
  background: rgba(74, 222, 128, 0.06);
  border-color: rgba(74, 222, 128, 0.2);
}

#status.info {
  color: var(--info);
  background: rgba(148, 163, 184, 0.06);
  border-color: rgba(148, 163, 184, 0.15);
}

.hidden {
  display: none !important;
}

@media (max-width: 480px) {
  .card {
    padding: 2rem 1.25rem;
  }

  h1 {
    font-size: 1.4rem;
  }
}
