/* ── Design tokens (shadcn/ui-inspired, AMOLED black) ── */
:root {
  color-scheme: dark;
  --background: #000000;
  --foreground: #fafafa;
  --card: #0a0a0a;
  --card-foreground: #fafafa;
  --popover: #0a0a0a;
  --primary: #fafafa;
  --primary-foreground: #0a0a0a;
  --secondary: #1a1a1a;
  --secondary-foreground: #fafafa;
  --muted: #171717;
  --muted-foreground: #a1a1aa;
  --accent: #171717;
  --accent-foreground: #fafafa;
  --destructive: #ef4444;
  --border: #1e1e1e;
  --input: #1e1e1e;
  --ring: #3f3f46;
  --success: #22c55e;

  --radius: 0.75rem;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
}

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

/* ── Body ── */
body {
  font-family: var(--sans);
  color: var(--foreground);
  background: var(--background);
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* subtle noise texture overlay */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 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");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ── Layout ── */
.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 640px;
  animation: enter 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Card ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 1.5rem 1.5rem 0;
}

.card-content {
  padding: 0 1.5rem 1.5rem;
}

/* ── Badge ── */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.2rem 0.65rem;
  line-height: 1.4;
}

/* ── Typography ── */
h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-top: 0.75rem;
}

.description {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
}

/* ── Field ── */
.field {
  margin-bottom: 1rem;
}

.field > label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--foreground);
}

/* ── Input with icon ── */
.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--muted-foreground);
  pointer-events: none;
}

input[type="url"] {
  width: 100%;
  height: 2.5rem;
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  color: var(--foreground);
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0 0.75rem 0 2.5rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input[type="url"]::placeholder {
  color: var(--muted-foreground);
  opacity: 0.5;
}

input[type="url"]:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(63, 63, 70, 0.3);
}

/* ── Textarea ── */
textarea {
  width: 100%;
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  color: var(--foreground);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.6;
  padding: 0.625rem 0.75rem;
  resize: vertical;
  min-height: 100px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea::placeholder {
  color: var(--muted-foreground);
  opacity: 0.4;
}

textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(63, 63, 70, 0.3);
}

/* ── Switch (shadcn-style) ── */
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
}

.switch-label {
  cursor: pointer;
}

.switch-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.switch-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
}

.switch-hint {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  line-height: 1.4;
}

.switch-hint code {
  font-family: var(--mono);
  font-size: 0.7rem;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.3rem;
}

.switch {
  position: relative;
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.5rem;
  border-radius: 9999px;
  border: none;
  background: var(--input);
  cursor: pointer;
  padding: 0;
  transition: background-color 150ms ease;
}

.switch[aria-checked="true"] {
  background: var(--foreground);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.5rem - 4px);
  height: calc(1.5rem - 4px);
  border-radius: 9999px;
  background: var(--background);
  transition: transform 150ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.switch[aria-checked="true"] .switch-thumb {
  transform: translateX(calc(2.75rem - 1.5rem));
}

.switch:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}

/* ── Separator ── */
.separator {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0 1rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, opacity 150ms ease;
  white-space: nowrap;
}

.btn svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.btn-primary {
  width: 100%;
  height: 2.5rem;
  background: var(--primary);
  color: var(--primary-foreground);
  margin-bottom: 1.25rem;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:active {
  opacity: 0.8;
}

.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
  padding: 0.375rem 0.625rem;
}

.btn-ghost:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-sm {
  height: 2rem;
  font-size: 0.8rem;
  border-radius: calc(var(--radius) - 4px);
}

/* ── Output header row ── */
.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.output-header label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
  margin: 0;
}

/* ── Status ── */
#status {
  font-size: 0.8rem;
  min-height: 1.2rem;
  margin-top: 0.25rem;
  color: var(--muted-foreground);
  transition: color 150ms ease;
}

#status.error {
  color: var(--destructive);
}

#status.success {
  color: var(--success);
}

/* ── Utility ── */
.hidden {
  display: none !important;
}

/* ── Animation ── */
@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .card-header {
    padding: 1.25rem 1.25rem 0;
  }

  .card-content {
    padding: 0 1.25rem 1.25rem;
  }

  h1 {
    font-size: 1.25rem;
  }

  .field-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.625rem;
  }
}
