:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #175ddc;
  --accent-text: #ffffff;
  --field: #f7f8fa;
  --ok: #1a9c55;
  --err: #d1443a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --card: #1e2126;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #2d3138;
    --accent: #6ea8fe;
    --accent-text: #0b0c0f;
    --field: #262a30;
    --ok: #4ade80;
    --err: #ff7b86;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 20px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.page-head { text-align: center; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
.subtitle { margin: 0; color: var(--muted); font-size: .88rem; }

.app {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.toolbar__group { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.toolbar__group--actions { align-items: center; }

.select-field { display: flex; flex-direction: column; gap: 5px; font-size: .78rem; color: var(--muted); }
.select-field select {
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
}

.btn {
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s, transform .05s, border-color .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: scale(.97); }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn--primary:hover { color: var(--accent-text); filter: brightness(1.08); }

/* Panes */
.panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.pane {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pane__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--field);
}
.pane__title { font-weight: 600; font-size: .85rem; }
.pane__meta { font-size: .75rem; color: var(--muted); margin-right: auto; }
.pane__actions { display: flex; gap: 4px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.icon-btn:active { transform: scale(.94); }

.editor {
  flex: 1;
  width: 100%;
  min-height: 340px;
  resize: vertical;
  border: 0;
  outline: 0;
  padding: 14px;
  background: var(--card);
  color: var(--text);
  font-family: var(--mono);
  font-size: .86rem;
  line-height: 1.55;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}
.editor::placeholder { color: var(--muted); opacity: .7; }
.editor:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

/* Status bar */
.status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: .85rem;
  color: var(--muted);
}
.status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.status.is-ok { color: var(--ok); }
.status.is-ok .status__dot { background: var(--ok); }
.status.is-err { color: var(--err); }
.status.is-err .status__dot { background: var(--err); }
#status-text { font-family: var(--mono); font-size: .82rem; }

.page-foot {
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
}

button:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .panes { grid-template-columns: 1fr; }
  .toolbar { justify-content: flex-start; }
  .editor { min-height: 240px; }
}
