:root {
  color-scheme: light dark;
  --bg: #111316;
  --panel: #1b1f24;
  --panel-soft: #242a31;
  --border: #343b45;
  --text: #eef2f6;
  --muted: #9aa4b2;
  --accent: #3b82f6;
  --danger: #ef4444;
  --ok: #22c55e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  min-height: 36px;
  padding: 0 14px;
}

button.secondary {
  background: var(--panel-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  background: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0f1216;
  color: var(--text);
  padding: 8px 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.topbar p,
.status-row,
.muted {
  color: var(--muted);
}

.session {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

main {
  padding: 20px 24px 28px;
}

.toolbar,
.status-row,
.panel-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar label {
  display: grid;
  gap: 4px;
  min-width: 260px;
}

.status-row {
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.42fr) minmax(420px, 0.58fr);
  gap: 16px;
}

.panel {
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.panel-heading {
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 12px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
}

#filterInput {
  width: 180px;
}

.flag-list {
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.flag-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 12px;
}

.flag-row:last-child {
  border-bottom: 0;
}

.flag-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
}

.pill {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  background: #364152;
  color: var(--text);
}

.pill.enabled {
  background: #14532d;
  color: #bbf7d0;
}

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

.editor-panel {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto minmax(120px, 0.45fr);
}

#rawEditor {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  border: 0;
  border-radius: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}

.editor-panel h3 {
  margin: 0;
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 14px;
}

.diff {
  margin: 0;
  overflow: auto;
  border-top: 1px solid var(--border);
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
}

.signed-out {
  max-width: 420px;
  margin: 120px auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 24px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(460px, calc(100vw - 40px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px 14px;
  box-shadow: 0 10px 25px rgb(0 0 0 / 0.35);
}

dialog {
  width: min(480px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

dialog form {
  display: grid;
  gap: 12px;
}

dialog label {
  display: grid;
  gap: 5px;
}

dialog .checkbox {
  display: flex;
  align-items: center;
}

.dialog-actions {
  justify-content: flex-end;
}

.hidden {
  display: none !important;
}

@media (max-width: 920px) {
  .topbar,
  .layout {
    grid-template-columns: 1fr;
  }

  .layout {
    display: grid;
  }
}
