:root {
  --green: #114a3f;
  --green-light: #1b6b59;
  --ink: #16241f;
  --muted: #66716c;
  --paper: #f5f1e8;
  --line: rgba(17, 74, 63, 0.18);
  --gold: #c98923;
}

* {
  box-sizing: border-box;
}

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

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

button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
}

button:hover:not(:disabled) {
  border-color: var(--green);
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(201, 137, 35, 0.5);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

.shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  height: 100vh;
  min-height: 620px;
  padding: 18px;
}

.tool-header {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 24px;
  min-height: 74px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.title-block {
  text-align: center;
}

.eyebrow {
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 3vw, 2.35rem);
  font-weight: 500;
  letter-spacing: -0.025em;
}

.privacy-note {
  max-width: 280px;
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: right;
}

.visualizer {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(28, 45, 38, 0.08);
}

.canvas-wrap {
  position: relative;
  min-height: 0;
}

#visualizer {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 24px;
  padding: 32px;
  pointer-events: none;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state p {
  max-width: 410px;
  margin: 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 2vw, 1.4rem);
  line-height: 1.5;
}

.pulse {
  width: 86px;
  height: 86px;
  border: 1px solid rgba(17, 74, 63, 0.25);
  border-radius: 50%;
  box-shadow: 0 0 0 18px rgba(17, 74, 63, 0.05), 0 0 0 38px rgba(17, 74, 63, 0.025);
}

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.actions,
.pedal-meter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pedal-meter {
  min-height: 42px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.metric-label,
.metric span {
  color: var(--muted);
  font-size: 0.76rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 5px 11px;
  border-radius: 999px;
  background: #e8ece9;
  color: #435049;
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.on {
  background: var(--green-light);
  color: #fff;
}

.pill.warning {
  min-width: 108px;
  background: #b73c2c;
  color: #fff;
}

.pill[hidden] {
  display: none;
}

.diagnostics {
  position: relative;
}

.diagnostics summary {
  color: var(--green);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.metrics {
  position: absolute;
  right: 0;
  bottom: calc(100% + 20px);
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 1px;
  width: min(520px, calc(100vw - 36px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--line);
  box-shadow: 0 20px 50px rgba(22, 36, 31, 0.16);
}

.metric {
  display: grid;
  gap: 5px;
  padding: 12px;
  background: #fff;
}

.metric strong {
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.connection {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.connection::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--gold);
  content: "";
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .shell {
    min-height: 700px;
    padding: 10px;
  }

  .tool-header {
    grid-template-columns: 1fr auto;
    gap: 12px;
  }

  .title-block {
    text-align: right;
  }

  .privacy-note {
    grid-column: 1 / -1;
    max-width: none;
    margin: 0;
    text-align: center;
  }

  .controls {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .actions {
    flex: 1 1 100%;
  }

  .actions button {
    flex: 1;
  }

  .pedal-meter {
    padding-left: 0;
    border-left: 0;
  }

  .diagnostics {
    margin-left: auto;
  }

  .connection {
    width: 100%;
    margin-left: 0;
  }

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