:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #1d252c;
  --muted: #66727d;
  --line: #d9e0e5;
  --accent: #21735d;
  --accent-dark: #185744;
  --danger: #a23d35;
  --focus: #d6efe7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  max-width: 1440px;
  margin: 0 auto;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

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

h1 {
  font-size: 28px;
}

h2 {
  font-size: 16px;
  margin-bottom: 10px;
}

.status-stack {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge,
.save-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 14px;
}

.badge {
  color: var(--accent-dark);
  background: var(--focus);
  border-color: #b6d9ce;
}

.badge.live {
  color: #255d78;
  background: #e4f2f8;
  border-color: #bdd9e6;
}

.badge.error {
  color: var(--danger);
  background: #fff0ee;
  border-color: #e7c0bc;
}

.connection-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid #bdd9e6;
  border-radius: 8px;
  background: #eef8fc;
  color: #255d78;
}

.connection-panel[hidden] {
  display: none;
}

.connection-panel.error {
  border-color: #e7c0bc;
  background: #fff5f3;
  color: #762c27;
}

.connection-panel p {
  margin: 4px 0 0;
  line-height: 1.4;
}

.connection-panel button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: #fff;
  color: inherit;
  cursor: pointer;
}

.editor-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.job-banner {
  display: grid;
  grid-template-columns: 130px 220px minmax(220px, 1fr) 140px;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  margin-bottom: 16px;
}

.job-banner div {
  display: grid;
  gap: 5px;
  min-width: 0;
  background: var(--panel);
  padding: 12px;
}

.job-banner span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.job-banner strong {
  overflow-wrap: anywhere;
}

.job-banner .uuid-cell {
  grid-column: 1 / -1;
}

.sidebar,
.editor-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.button-list,
.note-list,
.history-list {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.button-list button,
.note-list button,
.history-list button,
.actions button,
.toolbar button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.wide-button {
  width: 100%;
  min-height: 40px;
  margin: 10px 0 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.button-list button,
.note-list button,
.history-list button {
  min-height: 42px;
  text-align: left;
  padding: 9px 10px;
}

.button-list button:hover,
.note-list button:hover,
.history-list button:hover,
.toolbar button:hover {
  border-color: var(--accent);
}

.form-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(220px, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

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

input:focus,
select:focus,
.editor:focus {
  outline: 3px solid var(--focus);
  border-color: var(--accent);
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.toolbar button {
  min-width: 38px;
  height: 34px;
  padding: 0 8px;
  display: grid;
  place-items: center;
}

.editor {
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.actions button {
  min-height: 40px;
  padding: 9px 12px;
}

.actions button:first-child {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.actions button:first-child:hover {
  background: var(--accent-dark);
}

.actions .danger {
  color: var(--danger);
}

.actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.history-list p,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

pre {
  min-height: 520px;
  max-height: 70vh;
  overflow: auto;
  margin: 0;
  padding: 12px;
  background: #111820;
  color: #e9f2f1;
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1080px) {
  .editor-grid {
    grid-template-columns: 220px minmax(0, 1fr);
  }

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

  .preview-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .connection-panel,
  .form-row,
  .job-banner,
  .editor-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .status-stack {
    justify-content: start;
  }

  .connection-panel button {
    width: 100%;
  }
}
