:root {
  color-scheme: light;
  --bg: #f7f7f3;
  --panel: #ffffff;
  --ink: #111111;
  --muted: #67706d;
  --line: #d9dedb;
  --teal: #56b7ad;
  --teal-dark: #174f4a;
  --gold: #f2a900;
  --red: #d44832;
  --green: #5fbf88;
  --shadow: 0 16px 42px rgba(17, 17, 17, 0.08);
  font-family: "Avenir Next", Avenir, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: block;
  padding: 10px 0 28px;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 7.2vw, 76px);
  font-weight: 900;
  line-height: 0.92;
  max-width: 820px;
  white-space: nowrap;
}

.subheader {
  max-width: 680px;
  margin: 14px 0 0;
  color: #2b302f;
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 800;
  line-height: 1.25;
}

.subheader p {
  margin: 0;
}

.subheader p + p {
  margin-top: 4px;
}

.file-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.output-control {
  width: 100%;
}

.file-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

.file-field input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(17, 106, 107, 0.14);
}

.info-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.info-panel details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: var(--shadow);
}

.info-panel summary {
  cursor: pointer;
  padding: 14px 16px;
  color: var(--ink);
  font-weight: 900;
}

.info-copy {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
  color: #38413f;
  font-size: 14px;
  line-height: 1.48;
}

.info-copy p {
  margin: 0;
}

.how-to-image {
  display: block;
  width: min(50%, 720px);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--line);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.measurement-panel,
.plot-panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: var(--shadow);
}

.measurement-panel {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 18px;
}

.frequency-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.frequency-readout div {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 14px;
}

.frequency-readout strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  line-height: 1.1;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.select-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.select-field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #f7f6f2;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

.select-field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(17, 106, 107, 0.14);
}

.rating-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
}

.rating-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  background: #f8f8f5;
  border: 1px solid var(--line);
}

.rating-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.rating-card strong {
  font-size: 28px;
  line-height: 1;
}

.rating-panel p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.primary-controls,
.utility-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

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

.level-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.button,
.step-button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #f8f8f5;
  color: var(--ink);
  cursor: pointer;
}

.button:hover,
.step-button:hover {
  border-color: #a99f92;
}

.button:disabled,
.step-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.button.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
  font-weight: 900;
}

.button.accent {
  border-color: var(--teal);
  background: var(--teal);
  color: #071514;
  font-weight: 900;
}

.button.subtle {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.step-button {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 20px 12px;
}

.step-button span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.step-button strong {
  font-size: 18px;
}

.status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.plot-panel {
  padding: 12px;
}

.plot-canvas-frame {
  aspect-ratio: 16 / 10;
}

#plotCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.reference-key {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.reference-key-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  color: #27312f;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.reference-swatch {
  width: 34px;
  border-top: 3px solid #111111;
}

.reference-live {
  border-top-style: dashed;
}

.reference-open {
  border-color: #56b7ad;
  border-top-style: dashed;
}

.reference-mid {
  border-color: #f2a900;
  border-top-style: dashed;
}

.reference-closed {
  border-color: #d44832;
  border-top-style: dotted;
}

.table-panel {
  margin-top: 18px;
  overflow: auto;
}

.minuendo-ad {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.minuendo-shop-link {
  display: block;
  width: 100%;
  color: inherit;
  text-decoration: none;
}

.minuendo-shop-link img {
  display: block;
  width: 100%;
  height: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr.active-row {
  background: #eef5f3;
}

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

  .topbar,
  .workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

  #plotCanvas {
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .how-to-image {
    width: 100%;
  }

  .frequency-readout,
  .primary-controls,
  .utility-controls,
  .level-controls {
    grid-template-columns: 1fr;
  }
}
