:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #182235;
  --editor: #0b1220;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --line: #2b3648;
  --button: #1f2937;
  --button-hover: #273449;
  --gutter: #101827;
  --accent: #3b82f6;
  --accent-2: #10b981;
  --danger: #fb7185;
  --warning: #f59e0b;
  --primary-text: #ffffff;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --editor: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --line: #d7dee8;
  --button: #ffffff;
  --button-hover: #f1f5f9;
  --gutter: #f8fafc;
  --accent: #2563eb;
  --accent-2: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --primary-text: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--button);
  color: var(--text);
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}

button:hover {
  border-color: var(--accent);
  background: var(--button-hover);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.app {
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--accent);
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .93rem;
  line-height: 1.35;
}

.toolbar,
.pane-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--primary-text);
  font-weight: 700;
}

.primary:hover {
  background: var(--accent);
}

.danger {
  color: var(--danger);
}

.layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.pane-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.pane-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-weight: 700;
}

.dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 99px;
  background: var(--muted);
}

.dot.ok {
  background: var(--accent-2);
}

.dot.err {
  background: var(--danger);
}

.dot.wait {
  background: var(--warning);
}

.editor-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  background: var(--editor);
}

.line-numbers,
textarea,
pre {
  height: 100%;
  min-height: 0;
  margin: 0;
  border: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  line-height: 1.62;
  tab-size: 2;
}

.line-numbers {
  overflow: hidden;
  padding: 14px 10px 14px 6px;
  border-right: 1px solid var(--line);
  background: var(--gutter);
  color: var(--muted);
  text-align: right;
  user-select: none;
  white-space: pre;
}

textarea,
pre {
  width: 100%;
  outline: none;
  resize: none;
  background: var(--editor);
  color: var(--text);
}

textarea {
  overflow: auto;
  padding: 14px;
  caret-color: var(--accent);
}

pre {
  overflow: auto;
  padding: 14px;
  white-space: pre;
}

.drop-hint {
  position: absolute;
  inset: 10px;
  display: none;
  place-items: center;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent), transparent 86%);
  color: var(--text);
  pointer-events: none;
  font-weight: 700;
}

.is-dragging .drop-hint {
  display: grid;
}

.statusbar {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.status {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status.ok {
  color: var(--accent-2);
}

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

.metrics {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: .9rem;
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--editor);
}

.segmented button {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.segmented button[aria-pressed="true"] {
  background: var(--button-hover);
  color: var(--text);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .app {
    min-height: 100vh;
    height: auto;
  }

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

  .toolbar {
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(360px, 46vh);
  }

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

  .metrics {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 10px;
  }

  .pane-head {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .pane-actions {
    justify-content: stretch;
  }

  .toolbar button,
  .pane-actions button,
  .segmented {
    flex: 1 1 auto;
  }
}
