:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d8dee4;
  --accent: #197278;
  --accent-dark: #12565b;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #287d3c;
  --shadow: 0 8px 24px rgba(20, 30, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: #101820;
  color: #fff;
  border-bottom: 1px solid #26313c;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  font-weight: 700;
}

h3 {
  font-size: 13px;
  margin-bottom: 8px;
  text-transform: uppercase;
  color: var(--muted);
}

.topbar p,
.panel-header p,
.mock-box p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.topbar p {
  color: #b8c2cc;
}

.top-actions,
.inline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(380px, 0.9fr);
  gap: 16px;
  padding: 16px;
}

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

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.saved-panel,
.catalog-panel,
.device-panel {
  grid-column: 1 / -1;
}

.device-code {
  display: inline-flex;
  align-items: center;
  min-height: 54px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label,
.wide-label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  min-height: 154px;
  resize: vertical;
  line-height: 1.45;
  font-family: "Cascadia Code", "Consolas", monospace;
}

.wide-label {
  margin-top: 12px;
}

.button,
button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button.primary,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.button.secondary,
button.secondary {
  background: #fff;
}

.button.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 280px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: #17212b;
  color: #d7dee6;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.warning {
  background: #3b2a12;
  color: #ffd89a;
}

.status-pill.ok {
  background: #123326;
  color: #9ce8c1;
}

.hidden {
  display: none !important;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
}

.segmented button {
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--muted);
}

.segmented button.active {
  background: #e5f2f3;
  color: var(--accent-dark);
}

.inline-controls {
  margin-top: 12px;
}

.mock-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfd;
}

.mock-box textarea {
  margin-top: 10px;
  min-height: 80px;
}

.chat-preview {
  min-height: 92px;
  border: 1px solid #27313c;
  border-radius: 8px;
  padding: 14px;
  background: #111827;
  color: #eef4f8;
}

.chat-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.7;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #374151;
  color: #e5e7eb;
  font-size: 12px;
  font-weight: 700;
}

.chat-emote {
  width: 28px;
  height: 28px;
  object-fit: contain;
  vertical-align: middle;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.plain-list li {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fbfcfd;
  overflow-wrap: anywhere;
}

.plain-list .warning {
  border-color: #f2c94c;
  color: var(--warn);
}

.plain-list .error {
  border-color: #fda29b;
  color: var(--danger);
}

.emote-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-height: 118px;
  overflow: auto;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.emote-strip img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.command-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

.command-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.command-item code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.item-actions {
  display: flex;
  gap: 8px;
}

.examples {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfd;
  padding: 6px 10px;
  cursor: pointer;
  color: #344054;
}

.catalog-table {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.variable-row {
  display: grid;
  grid-template-columns: 190px 160px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.variable-row code {
  font-weight: 700;
  color: var(--accent-dark);
}

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-header,
  .status-grid {
    display: grid;
  }

  .form-grid,
  .variable-row {
    grid-template-columns: 1fr;
  }
}
