:root {
  --ink: #12100d;
  --panel: #1b1711;
  --panel-edge: #4b3923;
  --cream: #eadfbf;
  --cream-deep: #c9b98f;
  --brass: #b9823d;
  --red: #ba2d2d;
  --red-dark: #6e1515;
  --green: #38d274;
  --green-dark: #06381f;
  --blue: #28546b;
  --needle-deg: 0deg;
  --scale-radius: 148px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent 32%),
    linear-gradient(180deg, #271f16 0%, #0f0e0c 100%);
  transition:
    background-color 180ms ease,
    color 180ms ease;
}

body.tuned {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 32%),
    linear-gradient(180deg, #064b31 0%, #011f14 100%);
}

.tuner-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.meter-panel {
  width: min(960px, 100%);
  display: grid;
  grid-template-rows: auto auto auto auto auto auto;
  gap: 14px;
  padding: 18px;
  border: 2px solid var(--panel-edge);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent 12% 88%, rgba(255, 255, 255, 0.05)),
    linear-gradient(180deg, #2f2518, var(--panel));
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.top-bar,
.control-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.mode-button {
  min-height: 78px;
  border: 1px solid rgba(207, 178, 123, 0.42);
  border-radius: 8px;
  color: #f1dfae;
  background:
    linear-gradient(180deg, rgba(255, 244, 211, 0.08), rgba(0, 0, 0, 0.1)),
    #16120d;
  display: grid;
  align-content: center;
  gap: 6px;
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.2;
  padding: 12px 14px;
  text-align: center;
  cursor: pointer;
}

.mode-button:hover {
  border-color: rgba(241, 197, 111, 0.8);
}

.mode-button.active {
  color: #171109;
  border-color: #e6b45c;
  background: linear-gradient(180deg, #f1c56f, var(--brass));
  box-shadow: 0 0 18px rgba(185, 130, 61, 0.32);
}

.mode-name {
  text-transform: uppercase;
}

.mode-reference {
  color: rgba(255, 244, 211, 0.82);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.28;
  overflow-wrap: anywhere;
  text-transform: none;
}

.mode-button.active .mode-reference {
  color: rgba(23, 17, 9, 0.78);
}

.kicker,
.label,
.status-text {
  margin: 0;
  color: #cfb27b;
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  color: #fff4d3;
  font-size: 2.6rem;
  line-height: 1;
  letter-spacing: 0;
}

.status-lamp {
  width: 28px;
  height: 28px;
  border: 2px solid #321612;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #ffc7b7, var(--red) 48%, var(--red-dark));
  box-shadow: 0 0 18px rgba(186, 45, 45, 0.45);
}

.tuned .status-lamp {
  border-color: #052812;
  background:
    radial-gradient(circle at 35% 30%, #d7ffe5, var(--green) 48%, #0d793e);
  box-shadow: 0 0 30px rgba(56, 210, 116, 0.75);
}

.vu-meter {
  width: 100%;
}

.meter-face {
  position: relative;
  width: 100%;
  height: 330px;
  overflow: hidden;
  border: 10px solid #15110d;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), transparent 34%),
    radial-gradient(ellipse at 50% 96%, rgba(73, 47, 18, 0.22), transparent 42%),
    linear-gradient(180deg, #f1e8c9 0%, var(--cream) 54%, var(--cream-deep) 100%);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.28),
    inset 0 -18px 35px rgba(67, 47, 20, 0.24),
    0 14px 34px rgba(0, 0, 0, 0.35);
}

.tuned .meter-face {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), transparent 34%),
    radial-gradient(ellipse at 50% 92%, rgba(5, 120, 56, 0.2), transparent 45%),
    linear-gradient(180deg, #eaffd9 0%, #bff2b7 58%, #75d889 100%);
}

.scale {
  position: absolute;
  inset: 18px 8% 22%;
}

.tick {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 2px;
  height: 18px;
  background: rgba(18, 16, 13, 0.72);
  transform: rotate(var(--angle)) translateY(calc(-1 * var(--scale-radius)));
  transform-origin: 50% var(--scale-radius);
}

.tick.major {
  width: 3px;
  height: 30px;
  background: var(--ink);
}

.tick.center {
  width: 4px;
  height: 38px;
  background: #14371f;
}

.center-band {
  position: absolute;
  left: calc(50% - 17px);
  top: 17%;
  width: 34px;
  height: 72px;
  border-radius: 0 0 8px 8px;
  border: 1px solid rgba(4, 87, 38, 0.35);
  background: linear-gradient(180deg, rgba(56, 210, 116, 0.36), transparent);
}

.meter-frequency {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: rgba(18, 16, 13, 0.76);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0;
}

.meter-frequency small {
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 0.88rem;
  text-transform: uppercase;
}

.meter-cents {
  position: absolute;
  right: 18%;
  top: 58%;
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: rgba(18, 16, 13, 0.72);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0;
}

.meter-cents small {
  font-size: 0.72rem;
  text-transform: uppercase;
}

.needle {
  position: absolute;
  left: calc(50% - 2px);
  bottom: 18px;
  width: 4px;
  height: 68%;
  border-radius: 999px;
  background: linear-gradient(180deg, #1a1712 0%, #080705 100%);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.42);
  transform: rotate(var(--needle-deg));
  transform-origin: 50% calc(100% - 10px);
  transition: transform 80ms linear;
}

.pivot {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 54px;
  height: 30px;
  transform: translateX(-50%);
  border-radius: 50% 50% 8px 8px;
  background:
    radial-gradient(circle at 50% 38%, #3f3524, #0a0907 62%);
  box-shadow: 0 7px 12px rgba(0, 0, 0, 0.38);
}

.readout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: stretch;
}

.primary-note {
  min-height: 104px;
  border: 1px solid rgba(207, 178, 123, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 244, 211, 0.08), rgba(0, 0, 0, 0.12));
}

.primary-note {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: #fff4d3;
  font-size: 4.4rem;
  font-weight: 700;
  line-height: 1;
}

.note-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
}

.primary-note small {
  margin-left: 4px;
  color: #cfb27b;
  font-size: 1.4rem;
}

.target-inline {
  color: #cfb27b;
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tuned .primary-note {
  color: #dfffe8;
  text-shadow: 0 0 18px rgba(56, 210, 116, 0.55);
}

.start-button {
  min-width: 148px;
  min-height: 54px;
  border: 1px solid #e6b45c;
  border-radius: 8px;
  color: #171109;
  background: linear-gradient(180deg, #f1c56f, var(--brass));
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.start-button:hover {
  filter: brightness(1.08);
}

.start-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.a4-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #cfb27b;
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-weight: 700;
}

.a4-control input {
  width: 86px;
  min-height: 44px;
  border: 1px solid rgba(207, 178, 123, 0.45);
  border-radius: 8px;
  color: #fff4d3;
  background: #0f0e0c;
  font: inherit;
  text-align: center;
}

.level-meter {
  width: 180px;
  height: 14px;
  overflow: hidden;
  border: 1px solid rgba(207, 178, 123, 0.35);
  border-radius: 8px;
  background: #090806;
}

.level-meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green), #f2c66f);
  transition: width 80ms linear;
}

.status-text {
  min-height: 18px;
  text-align: center;
  color: #fff4d3;
}

.status-text.error {
  color: #ff9d8f;
}

@media (max-width: 760px) {
  .tuner-shell {
    padding: 12px;
  }

  .meter-panel {
    min-height: 0;
    padding: 14px;
  }

  h1 {
    font-size: 2rem;
  }

  .meter-face {
    height: 230px;
  }

  .meter-cents {
    right: 12%;
    top: 60%;
    font-size: 1rem;
  }

  :root {
    --scale-radius: 98px;
  }

  .mode-strip {
    grid-template-columns: 1fr 1fr;
  }

  .mode-button {
    min-height: 88px;
    padding: 10px;
  }

  .mode-reference {
    font-size: 0.66rem;
  }

  .primary-note {
    min-height: 82px;
    font-size: 3.2rem;
  }

  .control-strip {
    display: grid;
    grid-template-columns: 1fr;
  }

  .start-button,
  .level-meter {
    width: 100%;
  }

  .a4-control {
    justify-content: center;
  }
}

@media (max-width: 360px) {
  .primary-note {
    min-height: 86px;
  }

  .mode-strip {
    grid-template-columns: 1fr;
  }

  .mode-button {
    min-height: 72px;
  }
}
