:root {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-soft: #eef2ff;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.12);
  --primary: #16a34a;
  --primary-strong: #15803d;
  --accent: #2563eb;
  --danger: #dc2626;
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
  --radius: 24px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #020617;
  --bg-soft: #0f172a;
  --panel: rgba(15, 23, 42, 0.78);
  --panel-strong: #111827;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.18);
  --primary: #22c55e;
  --primary-strong: #4ade80;
  --accent: #38bdf8;
  --danger: #fb7185;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(34, 197, 94, 0.18), transparent 30rem),
    radial-gradient(circle at 82% 0%, rgba(37, 99, 235, 0.18), transparent 32rem),
    linear-gradient(135deg, var(--bg), var(--bg-soft));
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.shell.compact {
  width: min(980px, calc(100% - 32px));
}

.topbar,
.hero,
.grid,
.input-row,
.actions-row,
.section-title,
.status-card,
.brand,
.theme-toggle {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 40px;
}

.brand {
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 14px 34px rgba(34, 197, 94, 0.24);
  font-weight: 800;
}

.brand small,
.hint,
.subtitle,
.status-card small,
.status-line span,
#convertState {
  color: var(--muted);
}

.brand small {
  display: block;
  margin-top: 2px;
}

.theme-toggle,
.ghost-btn,
.copy-btn {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--panel);
}

.theme-toggle {
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
}

.sun {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

.hero {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--primary-strong);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.subtitle {
  max-width: 650px;
  margin: 18px 0 0;
  font-size: 17px;
  line-height: 1.8;
}

.status-card {
  min-width: 220px;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.pulse {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.14);
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.query-panel {
  padding: 22px;
  margin-bottom: 18px;
}

.status-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

label,
.section-title {
  font-weight: 700;
}

.input-row {
  gap: 12px;
  margin-top: 10px;
}

input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  outline: none;
  color: var(--text);
  background: var(--panel-strong);
}

textarea {
  display: block;
  width: 100%;
  min-height: 280px;
  margin-top: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  outline: none;
  resize: vertical;
  color: var(--text);
  background: var(--panel-strong);
  font:
    15px/1.65 "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  line-height: 1.6;
}

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

input:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(34, 197, 94, 0.34);
  outline-offset: 2px;
}

.primary-btn,
.ghost-btn,
.copy-btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

.primary-btn {
  min-width: 104px;
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  font-weight: 800;
}

.ghost-btn:hover,
.copy-btn:hover,
.theme-toggle:hover,
.primary-btn:hover {
  transform: translateY(-1px);
}

.actions-row {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.hint {
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.7;
}

.grid {
  align-items: stretch;
  gap: 18px;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.form-grid input {
  margin-top: 10px;
}

.admin-panel {
  display: block;
  padding: 26px;
}

.source-block {
  display: block;
  width: 100%;
  margin-top: 4px;
}

.source-block label {
  display: block;
}

.source-block textarea {
  display: block;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  min-height: 320px;
}

.grid > .panel {
  flex: 1;
}

.code-card,
.message-card,
.response-panel {
  padding: 22px;
}

.section-title {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

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

.code-box {
  display: grid;
  min-height: 150px;
  place-items: center;
  border-radius: 20px;
  color: var(--primary-strong);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(44px, 7vw, 76px);
  font-weight: 900;
  letter-spacing: 0.08em;
}

pre {
  min-height: 150px;
  max-height: 360px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--text);
  background: color-mix(in srgb, var(--panel-strong) 86%, transparent);
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 24px, 1120px);
    padding-top: 16px;
  }

  .hero,
  .grid,
  .input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .status-card {
    min-width: 0;
  }

  .primary-btn {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
