:root {
  --bg: #0f1115;
  --panel: rgba(23, 26, 34, 0.65);
  --text: #f5f7ff;
  --muted: #9ca6c0;
  --accent: #6f8dff;
  --accent-2: #8f62ff;
  --danger: #ff6b6b;
  --ok: #35d07f;
  --border: #313958;
  --editor-bg: rgba(13, 16, 22, 0.95);
  --gutter-bg: rgba(9, 11, 17, 0.9);
}

body.light {
  --bg: #f6f8ff;
  --panel: rgba(255, 255, 255, 0.8);
  --text: #1d2740;
  --muted: #607095;
  --accent: #536dfe;
  --accent-2: #7b5dff;
  --danger: #d64242;
  --ok: #168f53;
  --border: #d5dcef;
  --editor-bg: #ffffff;
  --gutter-bg: #f4f6fc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 500px at 15% -5%, rgba(111, 141, 255, 0.22), transparent 60%),
    radial-gradient(1000px 500px at 85% -10%, rgba(143, 98, 255, 0.20), transparent 60%),
    linear-gradient(180deg, #0c0f15, #101521 30%, #0f1115);
  color: var(--text);
  min-height: 100dvh;
}

body.light {
  background:
    radial-gradient(1200px 500px at 15% -5%, rgba(83, 109, 254, 0.20), transparent 60%),
    radial-gradient(1000px 500px at 85% -10%, rgba(123, 93, 255, 0.18), transparent 60%),
    linear-gradient(180deg, #eef3ff, #f6f8ff 35%, #eef2ff);
}

.app {
  width: 100%;
  max-width: none;
  min-height: 100dvh;
  margin: 0;
  padding: 16px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 10px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: 0.2px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(111, 141, 255, 0.35);
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.editor-wrap {
  margin-top: 0;
  min-height: 0;
  height: auto;
}

.glass {
  backdrop-filter: blur(10px);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 4px 10px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  padding: 5px 10px;
  border-radius: 999px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.editor-shell {
  display: grid;
  grid-template-columns: 56px 1fr;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.line-numbers {
  height: 100%;
  overflow: hidden;
  background: var(--gutter-bg);
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace;
  text-align: right;
  padding: 14px 10px 14px 6px;
  user-select: none;
}

.line-numbers span {
  display: block;
}

textarea {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  background: var(--editor-bg);
  color: var(--text);
  border: 0;
  border-radius: 0;
  padding: 14px;
  font-size: 14px;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace;
  outline: none;
}

textarea:focus {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
}

.editor-shell.invalid {
  animation: pulseError 0.35s ease;
  border-color: color-mix(in srgb, var(--danger) 65%, var(--border));
}

@keyframes pulseError {
  0% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  50% { transform: translateX(2px); }
  75% { transform: translateX(-1px); }
  100% { transform: translateX(0); }
}

.controls {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 24px rgba(111, 141, 255, 0.25);
  transition: transform 0.12s ease, opacity 0.12s ease;
}

button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }

button.secondary {
  background: #252b3d;
  color: #dfe6ff;
  box-shadow: none;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  padding: 6px 10px;
  font-size: 12px;
}

body.light button.secondary {
  background: #e4eaf9;
  color: #2b3a61;
}

#statusArea {
  margin-top: 12px;
  min-height: 26px;
  display: flex;
  align-items: center;
  font-size: 14px;
  padding-left: 2px;
}

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

@media (max-width: 720px) {
  .controls { flex-wrap: wrap; }
  .head-actions .hint { display: none; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
