:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #172026;
  --muted: #68737d;
  --line: #dfe5ea;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

.panel,
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  margin-bottom: 14px;
  padding: 14px;
}

.grid {
  display: grid;
  gap: 12px;
}

.stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.stat {
  padding: 14px;
}

.stat span,
.muted {
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 0 -16px 14px;
  padding: 0 16px 8px;
  overflow-x: auto;
}

.tab,
button,
.icon-btn {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.tab {
  flex: 0 0 auto;
  min-width: 96px;
  padding: 0 12px;
  background: #e9eef2;
  color: var(--text);
}

.tab.active {
  background: var(--primary);
  color: #fff;
}

.icon-btn {
  width: 42px;
  font-size: 20px;
}

button {
  padding: 0 14px;
}

button:hover {
  background: var(--primary-dark);
}

button.ghost {
  background: #e9eef2;
  color: var(--text);
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.editor-grid {
  display: grid;
  gap: 14px;
}

.message-editor textarea {
  min-height: 180px;
}

.template-hint {
  margin: 8px 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.message-preview {
  min-height: 130px;
  margin: 12px 0 0;
  border: 1px solid #263640;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hidden {
  display: none;
}

.switch-list,
.list,
.chips,
.check-list {
  display: grid;
  gap: 8px;
}

.switch-row,
.item-row,
.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.switch-row input,
.check-row input {
  width: auto;
  min-height: auto;
}

.item-row {
  align-items: flex-start;
}

.item-row button,
.chip button {
  min-height: 32px;
  padding: 0 10px;
}

.chips {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

pre {
  max-height: 460px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #111820;
  color: #dbe7ef;
  white-space: pre-wrap;
}

#toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100% - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #172026;
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  transition: 160ms ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 760px) {
  .shell {
    padding: 24px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .row {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  #security .row {
    grid-template-columns: 1fr 1fr auto;
  }

  .editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
