:root {
  --bg: #eef1f3;
  --panel: #f6f7f8;
  --panel-strong: #fcfdfe;
  --ink: #1d2929;
  --muted: #5d6a6a;
  --accent: #2f7a43;
  --accent-deep: #1f542d;
  --border: rgba(29, 41, 41, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.35 "Segoe UI", Tahoma, sans-serif;
}

.page-shell {
  width: min(1240px, calc(100% - 1rem));
  margin: 0 auto;
  padding: 0.5rem 0 4.5rem;
}

.hero {
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel);
}

.eyebrow,
.section-kicker,
.card-kicker {
  margin: 0 0 0.15rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.hero h1,
.section-heading h2,
.oscillator-title {
  margin: 0;
  font-weight: 700;
}

.hero h1 {
  font-size: 1.35rem;
  line-height: 1.15;
  max-width: none;
}

.hero-copy,
.section-note,
.status-text {
  color: var(--muted);
  line-height: 1.35;
}

.hero-copy {
  max-width: 80ch;
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.state-panel {
  margin-top: 0.65rem;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel-strong);
}

.state-control {
  display: grid;
  gap: 0.3rem;
}

.state-control > span {
  font-weight: 700;
}

.state-code {
  width: 100%;
  min-height: 4.5rem;
  resize: vertical;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(30, 47, 47, 0.15);
  border-radius: 0;
  background: #f7f9fa;
  color: var(--ink);
  font: 12px/1.35 Consolas, "Courier New", monospace;
}

.state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.state-note {
  margin: 0.45rem 0 0;
  color: var(--muted);
  line-height: 1.3;
  font-size: 0.85rem;
}

.global-panel,
.oscillator-card {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  border-radius: 0;
}

.global-panel {
  margin-top: 0.65rem;
  padding: 0.65rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  align-items: center;
}

.global-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.primary-button,
.secondary-button,
.ghost-button {
  appearance: none;
  border-radius: 0;
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  border: 1px solid #255f35;
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  border: 1px solid rgba(47, 122, 67, 0.22);
  background: #eef2f0;
  color: #254030;
}

.ghost-button {
  border: 1px solid rgba(30, 47, 47, 0.12);
  background: #f7f9fa;
  color: var(--ink);
}

.global-control,
.control {
  display: grid;
  gap: 0.2rem;
}

.global-control strong,
.control strong {
  font-size: 0.82rem;
}

.editable-value {
  display: inline-block;
  min-width: 4.6rem;
  padding: 0.1rem 0.25rem;
  border-radius: 0;
  cursor: text;
  user-select: text;
  border: 1px dashed rgba(47, 122, 67, 0.4);
  background: #f1f4f2;
}

.editable-value:focus {
  outline: 1px solid rgba(47, 122, 67, 0.45);
  outline-offset: 1px;
}

.editable-value.is-editing {
  background: #f7f9fa;
  border-style: solid;
}

.value-editor {
  width: 100%;
  min-width: 0;
  border: none;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  outline: none;
}

.status-text {
  margin: 0;
  font-size: 0.85rem;
}

.oscillator-section {
  margin-top: 0.65rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: end;
}

.section-note {
  margin: 0;
  max-width: 56ch;
  text-align: right;
  font-size: 0.85rem;
}

.oscillator-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.oscillator-card {
  padding: 0.55rem;
}

.oscillator-header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: start;
  margin-bottom: 0.45rem;
}

.oscillator-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 700;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
}

.control {
  padding: 0.35rem 0.4rem;
  border: 1px solid rgba(30, 47, 47, 0.08);
  border-radius: 0;
  background: #f7f9fa;
}

.control-label,
.global-control > span {
  font-weight: 700;
  font-size: 0.8rem;
}

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

select {
  width: 100%;
  padding: 0.3rem 0.4rem;
  border-radius: 0;
  border: 1px solid rgba(30, 47, 47, 0.15);
  background: #f7f9fa;
  color: var(--ink);
  font: inherit;
}

.floating-add-wrap {
  position: fixed;
  right: 0.6rem;
  bottom: 0.6rem;
  z-index: 20;
}

.floating-add-button {
  min-width: 9.5rem;
}

@media (max-width: 900px) {
  .global-panel {
    grid-template-columns: 1fr;
  }

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

  .section-note {
    text-align: left;
  }

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

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 0.5rem, 1240px);
    padding-top: 0.25rem;
  }

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

  .oscillator-header,
  .oscillator-actions {
    flex-direction: column;
    align-items: start;
  }

  .floating-add-wrap {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
  }

  .floating-add-button {
    width: 100%;
  }
}
