:root {
  color-scheme: light;
  --bg: #eef3f6;
  --panel: #ffffff;
  --ink: #172326;
  --muted: #657377;
  --line: #d9e4e7;
  --accent: #11b8b5;
  --danger: #e54f4f;
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 10px 14px;
}

button.secondary {
  background: #e7f3f4;
  color: #0f6268;
}

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

.sr-only {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.app-shell {
  max-width: 1420px;
  margin: 0 auto;
  padding: 24px;
}

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

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

.topbar p {
  color: var(--muted);
  margin: 4px 0 0;
}

.status-pill {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
}

.layout {
  display: grid;
  gap: 16px;
  grid-template-areas: "sidebar editor runner";
  grid-template-columns: 220px minmax(520px, 1fr) 360px;
}

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

.sidebar {
  align-self: start;
  display: grid;
  gap: 10px;
  grid-area: sidebar;
}

.editor,
.runner {
  min-width: 0;
}

.editor {
  grid-area: editor;
}

.runner {
  grid-area: runner;
}

.section-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

h2,
h3 {
  margin: 0 0 12px;
}

.run-mode-control {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 18px;
}

.device-control {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 18px;
}

.download-link {
  align-items: center;
  background: #e7f3f4;
  border-radius: 8px;
  color: #0f6268;
  display: flex;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  text-decoration: none;
}

.run-mode-control h3 {
  margin-bottom: 4px;
}

.run-mode-control p,
.device-control p {
  color: var(--muted);
  margin: 0;
}

.segmented {
  background: #e7f3f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 4px;
}

.mode-button {
  background: transparent;
  color: #0f6268;
}

.mode-button.active {
  background: var(--accent);
  color: #fff;
}

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

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field span,
.checkbox span {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

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

.grid.compact {
  gap: 8px;
}

.checkbox {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.checkbox input {
  width: auto;
}

.notice {
  background: #fff8e5;
  border: 1px solid #ecd899;
  border-radius: 8px;
  color: #66500c;
  padding: 10px;
}

.button-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.button-row.small {
  margin: 6px 0 18px;
}

.state-list {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
}

.state-list div {
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding-bottom: 8px;
}

.state-list dt {
  color: var(--muted);
}

.state-list dd {
  margin: 0;
}

.logs {
  background: #f7fafb;
  border-radius: 8px;
  max-height: 320px;
  overflow: auto;
  padding: 10px;
}

.log-entry {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.log-entry:last-child {
  border-bottom: 0;
}

@media (max-width: 1100px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
  }

  .layout {
    grid-template-areas:
      "runner"
      "sidebar"
      "editor";
    grid-template-columns: 1fr;
  }
}

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

  .topbar {
    display: grid;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .status-pill {
    border-radius: 8px;
    width: 100%;
  }

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