:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --panel: #ffffff;
  --panel-soft: #f0f4f1;
  --text: #1e2422;
  --muted: #66736f;
  --line: #d8ded9;
  --accent: #17775b;
  --accent-dark: #0f5d47;
  --warn: #a85d13;
  --error: #b13f3f;
  --ok: #17775b;
  --shadow: 0 10px 28px rgba(28, 36, 32, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 24px;
}

.topbar {
  align-items: flex-start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.topbar h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 6px;
}

.topbar p {
  color: var(--muted);
  margin: 0;
  max-width: 680px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-span {
  grid-column: 1 / -1;
}

.primary-panel {
  border-color: rgba(23, 119, 91, 0.28);
}

.section-title {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title h2 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0;
  margin: 0;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary-button,
.icon-button {
  background: var(--panel-soft);
  color: var(--text);
}

.secondary-button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  background: #e4ece7;
}

.status-badge,
.state-pill {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 650;
  min-height: 28px;
  padding: 0 10px;
}

.status-idle,
.state-pill {
  background: #e8ece9;
  color: #44504c;
}

.status-connected {
  background: #dceddf;
  color: var(--ok);
}

.status-error {
  background: #f6dddd;
  color: var(--error);
}

.status-busy {
  background: #f5eadb;
  color: var(--warn);
}

.connection-grid,
.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.connection-grid > div,
.metric-tile {
  background: var(--panel-soft);
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 70px;
  padding: 12px;
}

.label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 5px;
}

.connection-grid strong,
.metric-tile strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.info-list,
.compact-list {
  display: grid;
  gap: 9px;
  margin: 0;
}

.info-list div,
.compact-list div {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(120px, 170px) minmax(0, 1fr);
  padding: 8px 0;
}

.info-list div:last-child,
.compact-list div:last-child {
  border-bottom: 0;
}

dt {
  color: var(--muted);
  font-size: 13px;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.playback-bar {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 14px;
}

.playback-bar input[type="range"] {
  accent-color: var(--accent);
  width: 100%;
}

.playback-bar span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 86px;
  text-align: right;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.event-log {
  background: #111615;
  border-radius: 6px;
  color: #e8f0ec;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 13px;
  list-style: none;
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 12px;
}

.event-log li {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 5px 0;
}

.event-log li:last-child {
  border-bottom: 0;
}

@media (max-width: 880px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    display: block;
  }

  .topbar-actions {
    justify-content: flex-start;
    margin-top: 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .connection-grid,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .topbar h1 {
    font-size: 23px;
  }

  .connection-grid,
  .metric-grid,
  .info-list div,
  .compact-list div {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .playback-bar {
    grid-template-columns: 1fr;
  }

  .playback-bar span {
    text-align: left;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
