:root {
  color-scheme: dark light;
  --bg: #101211;
  --ink: #f5f5ef;
  --muted: #a6aaa7;
  --panel: #191d1b;
  --line: #323934;
  --button: #171b19;
  --button-pressed: #152629;
  --accent: #0b7c86;
  --accent-2: #e05535;
  --led-off: #303832;
  --led-on: #16c172;
  --button-accent: var(--accent);
  --button-surface: #eef6f6;
  --button-surface-active: #e2f0f0;
  --button-ink: var(--ink);
  --shadow: 0 18px 50px rgb(0 0 0 / 38%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) 24px;
  height: 100vh;
  height: 100dvh;
  padding: clamp(14px, 3vw, 28px);
  gap: clamp(12px, 2.5vw, 22px);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  font-weight: 720;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 2.5vw, 22px);
  height: 100%;
  min-height: 0;
}

@media (max-aspect-ratio: 1/1) {
  .button-grid {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
}

.feedback-button {
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 0.95fr) minmax(0, 1fr) 32px;
  align-items: center;
  justify-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: clamp(20px, 5vw, 48px);
  border: 2px solid var(--button-accent);
  border-radius: 8px;
  background: var(--button-surface);
  color: var(--button-ink);
  cursor: pointer;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 18%);
  transition: border-color 120ms ease, background 120ms ease;
  touch-action: manipulation;
  contain: layout paint;
}

.feedback-button::before {
  position: absolute;
  inset: 6%;
  display: block;
  pointer-events: none;
  content: "";
  background: center / contain no-repeat url("/thumbs-down.svg");
  opacity: 0.13;
  transform: rotate(-8deg) scale(1.18);
}

.feedback-button[data-tone="coral"] {
  --button-accent: #ff735c;
  --button-surface: #251714;
  --button-surface-active: #321c18;
  --button-ink: #fff1ec;
}

.feedback-button[data-tone="teal"] {
  --button-accent: #35c4c9;
  --button-surface: #102223;
  --button-surface-active: #132f31;
  --button-ink: #e7fffd;
}

.feedback-button:active,
.feedback-button.is-charging {
  background: var(--button-surface-active);
  border-color: var(--button-accent);
}

.feedback-button:focus-visible {
  outline: 0;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 18%);
}

.button-label {
  position: relative;
  z-index: 1;
  max-width: 12ch;
  text-align: center;
  font-size: clamp(1.5rem, 5.625vw, 4.35rem);
  font-weight: 780;
  line-height: 0.96;
}

.power-meter {
  position: relative;
  z-index: 1;
  align-self: stretch;
  display: grid;
  grid-template-columns: repeat(3, minmax(64px, 1fr));
  width: min(520px, 84%);
  height: 100%;
  gap: clamp(10px, 1.6vw, 16px);
}

.power-meter span {
  min-width: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.feedback-button[data-power="1"] .power-meter span:nth-child(-n + 1),
.feedback-button[data-power="2"] .power-meter span:nth-child(-n + 2),
.feedback-button[data-power="3"] .power-meter span:nth-child(-n + 3) {
  background: color-mix(in srgb, var(--button-accent) 72%, transparent);
  color: var(--button-ink);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 45%);
}

.button-cue {
  position: relative;
  z-index: 1;
  align-self: center;
  min-width: 0;
  max-width: 92%;
  color: var(--button-ink);
  font-size: clamp(0.95rem, 2vw, 1.45rem);
  font-weight: 760;
  line-height: 1;
  min-height: 1em;
  opacity: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feedback-button[data-cue]:not([data-cue=""]) .button-cue {
  opacity: 0.92;
}

.counts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  height: 24px;
  min-height: 24px;
  gap: 14px;
  color: var(--muted);
  font-size: clamp(0.78rem, 2.4vw, 0.95rem);
  line-height: 1;
  overflow: hidden;
}

.counts span:nth-child(2) {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  text-align: right;
}

.counts strong {
  color: var(--ink);
}

#status-text {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  min-width: 9ch;
  text-align: center;
}

.settings-modal {
  width: min(420px, calc(100vw - 30px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: auto;
}

.settings-modal::backdrop {
  background: rgb(0 0 0 / 34%);
}

.settings-modal form {
  display: grid;
  gap: 12px;
  padding: clamp(14px, 3vh, 18px);
}

.settings-modal label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.settings-modal input:not([type="checkbox"]) {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: transparent;
  color: var(--ink);
}

.checkbox-row {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 10px !important;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.form-error {
  min-height: 1em;
  color: var(--accent-2);
  font-size: 0.9rem;
}

.primary-action {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 760;
  cursor: pointer;
}
