:root {
  color-scheme: light;
  --bg: #eef3f1;
  --panel: #ffffff;
  --panel-2: #f7faf9;
  --ink: #16201d;
  --muted: #687773;
  --line: #d8e0dd;
  --green: #177b5b;
  --green-2: #22a06b;
  --red: #c94b44;
  --gold: #d9a441;
  --blue: #2f75b5;
  --shadow: 0 18px 45px rgba(33, 45, 40, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 16px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px 22px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(23, 123, 91, 0.92), rgba(47, 117, 181, 0.86)),
    radial-gradient(circle at 28% 22%, #fff 0 10%, transparent 11%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
  flex: 0 0 auto;
}

h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  line-height: 1.1;
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.control-row,
.control-grid {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}

.control-grid {
  grid-column: 1 / -1;
  justify-content: stretch;
}

button,
select,
input[type="number"] {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 6px;
  min-height: 38px;
  padding: 0 12px;
}

button {
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  border-color: #b9c8c3;
  background: #edf5f2;
}

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

label select,
label input {
  min-width: 118px;
}

input[type="range"] {
  width: min(22vw, 210px);
  accent-color: var(--green);
}

label.check {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: end;
}

label.check input {
  min-width: 0;
  accent-color: var(--green);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  min-height: 0;
}

.sim-panel {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

canvas {
  width: 100%;
  height: 100%;
  min-height: 520px;
  display: block;
  background: #e9f0ec;
}

.metrics {
  display: grid;
  align-content: start;
  gap: 10px;
}

.metric,
.state-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 1.55rem;
  letter-spacing: 0;
}

.state-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.state-bar {
  height: 68px;
  border-radius: 5px;
  background: #e8efec;
  border: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.state-bar span {
  display: block;
  width: 100%;
  min-height: 3px;
  background: linear-gradient(180deg, var(--green-2), var(--blue));
}

@media (max-width: 940px) {
  .toolbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-row,
  .control-grid {
    justify-content: flex-start;
  }

  input[type="range"] {
    width: min(62vw, 230px);
  }

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

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

  .toolbar {
    padding: 12px;
  }

  .brand {
    align-items: flex-start;
  }

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

  button,
  label select,
  label input,
  input[type="range"] {
    width: 100%;
    min-width: 0;
  }

  canvas {
    min-height: 430px;
  }

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