html, body {
  height: 100%;
  overflow: hidden;
}

body.test-mode {
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  flex-shrink: 0;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--sundial-text);
  border: none;
  font-size: 18px;
  cursor: pointer;
  text-decoration: none;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.stimulus-area {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.stimulus-band {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/*
 * Deliberately not styled with a fixed color/background. A solid dark
 * button would vanish on a black stimulus, a light one would vanish on
 * white. mix-blend-mode: difference inverts against whatever's directly
 * behind it instead, so it reads as dark-on-white, light-on-black, or a
 * contrasting hue against any color, with no per-color-swatch logic needed.
 */
.fullscreen-exit-button {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  mix-blend-mode: difference;
}

.fullscreen-exit-button:hover,
.fullscreen-exit-button:focus-visible {
  transform: scale(1.15);
}

body.fullscreen-mode .fullscreen-exit-button {
  display: inline-flex;
}

.controls-panel {
  flex-shrink: 0;
  background: var(--sundial-ink);
  padding: var(--sundial-panel-padding);
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-height: 60vh;
  overflow-y: auto;
}

body.fullscreen-mode .top-bar,
body.fullscreen-mode .controls-panel {
  display: none;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
}

.control-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pattern-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pattern-option {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: var(--sundial-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.pattern-option.selected {
  background: var(--sundial-accent);
  border-color: var(--sundial-accent);
  color: #fff;
}

.mini-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--sundial-text-muted);
}

input[type="number"] {
  width: 64px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: var(--sundial-text);
  font-size: 14px;
}

input[type="checkbox"] {
  accent-color: var(--sundial-accent);
  width: 16px;
  height: 16px;
}

.control-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--sundial-accent);
  height: 24px;
}

.brightness-note {
  font-size: 13px;
  color: var(--sundial-text-muted);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0;
  line-height: 1.4;
}

.swatch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--sundial-text-muted);
  cursor: pointer;
  padding: 0;
}

.swatch.selected {
  outline: 2px solid var(--sundial-accent);
  outline-offset: 2px;
}

input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  padding: 0;
  background: none;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 50%;
}

input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--sundial-text-muted);
  border-radius: 50%;
}

.swatch-row input[type="color"] {
  margin-left: auto;
}

.height-hint {
  font-size: 12px;
  color: var(--sundial-text-muted);
  opacity: 0.7;
  margin: 0;
}

.wake-lock-note {
  font-size: 12px;
  color: var(--sundial-text-muted);
  margin: 0;
}

/* Setup checklist modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  background: #0d0d0d;
  border-radius: 20px 20px 0 0;
  padding: 24px;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
  }
  .modal-sheet {
    border-radius: 20px;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.modal-done {
  background: none;
  border: none;
  color: var(--sundial-accent);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.checklist {
  background: var(--sundial-ink);
  border-radius: var(--sundial-radius);
  overflow: hidden;
}

.checklist-item {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.checklist-item:last-child {
  border-bottom: none;
}

.checklist-item h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.checklist-item p {
  margin: 0;
  font-size: 13px;
  color: var(--sundial-text-muted);
  line-height: 1.4;
}

.modal-footer-note {
  margin: 16px 4px 0;
  font-size: 12px;
  color: var(--sundial-text-muted);
  opacity: 0.7;
  line-height: 1.4;
}
