:root {
  --bg: #0f1216;
  --panel: #171c22;
  --panel-2: #1e242c;
  --border: #2a323c;
  --text: #e6eaf0;
  --muted: #8b97a6;
  --accent: #4c8dff;

  --ai: #ff5a5f;
  --ai-bg: rgba(255, 90, 95, 0.18);
  --assisted: #ffa53b;
  --assisted-bg: rgba(255, 165, 59, 0.18);
  --human: #3ddc84;
  --human-bg: rgba(61, 220, 132, 0.16);
  --unknown: #6b7280;
  --unknown-bg: rgba(107, 114, 128, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

.error {
  color: var(--ai);
  min-height: 1.2em;
  margin: 0;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--accent);
  color: #fff;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

button.ghost:hover {
  background: var(--panel-2);
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

/* Login */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login .card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  display: grid;
  gap: 12px;
}

.login h1 {
  margin: 0;
  font-size: 20px;
}

.login label {
  font-size: 13px;
  color: var(--muted);
}

/* App */
.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand {
  font-weight: 600;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panes {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--border);
}

.pane:last-child {
  border-right: none;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

#editor {
  flex: 1;
  width: 100%;
  resize: none;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 16px;
  line-height: 1.7;
}

#editor:focus {
  outline: none;
}

.result {
  flex: 1;
  overflow: auto;
  padding: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.7;
}

.result:empty::before {
  content: "Highlighted text will appear here.";
  color: var(--muted);
}

.hl {
  border-radius: 3px;
  padding: 1px 0;
  cursor: help;
  border-bottom: 2px solid transparent;
}

.hl-ai {
  background: var(--ai-bg);
  border-bottom-color: var(--ai);
}

.hl-assisted {
  background: var(--assisted-bg);
  border-bottom-color: var(--assisted);
}

.hl-human {
  background: var(--human-bg);
  border-bottom-color: var(--human);
}

.hl-unknown {
  background: var(--unknown-bg);
  border-bottom-color: var(--unknown);
}

.status {
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
          color: var(--muted);
}

.status[data-state="working"] {
  color: var(--accent);
}

.status[data-state="done"] {
  color: var(--human);
}

.status[data-state="error"] {
  color: var(--ai);
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  font-size: 13px;
}

.summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  background: var(--panel-2);
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.swatch.hl-ai {
  background: var(--ai);
}

.swatch.hl-assisted {
  background: var(--assisted);
}

.swatch.hl-human {
  background: var(--human);
}

.swatch.hl-unknown {
  background: var(--unknown);
}

.note {
  color: var(--assisted);
  font-size: 12px;
  padding: 0 16px 6px;
}

@media (max-width: 760px) {
  .app {
    height: auto;
  }

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

  .pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  #editor,
  .result {
    min-height: 40vh;
  }
}
