* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: #0b0b0b;
  color: #e6e6e6;
}

.app {
  display: flex;
  height: 100vh;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0a0a0a;
}

#lifeCanvas {
  display: block;
  cursor: crosshair;
  max-width: 100%;
  max-height: 100%;
  background: #000;
  border-radius: 6px;
}

.panel {
  flex: 0 0 380px;
  padding: 24px;
  background: #111;
  border-left: 1px solid #1f1f1f;
  overflow-y: auto;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel h1 {
  margin: 0;
  font-size: 20px;
}

/* Language switch: the current flag and name, and a two-column list under it. */
.lang-menu {
  position: relative;
  flex: 0 0 auto;
  font-size: 12px;
}

.lang-menu > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  background: #0d0d0d;
  color: #c7c7c7;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.lang-menu > summary::-webkit-details-marker {
  display: none;
}

.lang-menu > summary:hover,
.lang-menu[open] > summary {
  color: #f0f0f0;
  border-color: #3d3d3d;
}

.lang-flag {
  display: block;
  width: 20px;
  height: 15px;
  border-radius: 2px;
  object-fit: cover;
}

.lang-list {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 2px;
  padding: 6px;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  background: #131313;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: #c7c7c7;
  font: inherit;
  text-align: start;
  white-space: nowrap;
  cursor: pointer;
}

.lang-option:hover {
  background: #1f1f1f;
  color: #f0f0f0;
}

.lang-option[aria-pressed="true"] {
  color: #16c172;
}

.panel-section {
  margin-bottom: 24px;
}

.panel-section h2 {
  margin: 0 0 12px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9d9d9d;
}

.panel-fold > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.panel-fold > summary::-webkit-details-marker {
  display: none;
}

.panel-fold > summary h2 {
  margin: 0;
}

.panel-fold[open] > summary {
  margin-bottom: 12px;
}

/* Caret rotates from pointing right (folded) to down (open). */
.panel-fold > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  color: #9d9d9d;
  transition: transform 0.15s ease;
}

.panel-fold[open] > summary::before {
  transform: rotate(90deg);
}

/* Right-to-left: the folded caret points left; open still points down. */
[dir="rtl"] .panel-fold:not([open]) > summary::before {
  transform: rotate(180deg);
}

.panel-fold > summary:hover h2,
.panel-fold > summary:hover::before {
  color: #e6e6e6;
}

.control {
  margin-bottom: 16px;
}

.control label {
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
  color: #c7c7c7;
}

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

.control-row input[type="range"] {
  flex: 1;
}

/* The region cards fold away under their own caret inside the Sound section. */
.region-fold > summary {
  font-size: 12px;
  color: #c7c7c7;
}

.region-fold > summary:hover {
  color: #f0f0f0;
}

.region-fold[open] > summary {
  margin-bottom: 8px;
}

.region-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.ghost-button {
  background: #0d0d0d;
  color: #c7c7c7;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 3px 8px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.ghost-button:hover {
  color: #f0f0f0;
  border-color: #3d3d3d;
}

.ghost-button[aria-pressed="true"] {
  color: #16c172;
  border-color: #16c172;
}

.ghost-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.action-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.action-row .ghost-button {
  flex: 1;
  padding: 8px 10px;
  font-size: 12px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-row .ghost-button {
  padding: 4px 10px;
}

.control-row input[type="number"] {
  width: 72px;
  background: #0d0d0d;
  color: #f0f0f0;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 4px 6px;
}

/* One card per voice region, ordered bass (top of the field) to treble. */
.region-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.region-card {
  border: 1px solid #1f1f1f;
  border-radius: 6px;
  background: #0d0d0d;
  padding: 8px;
}

.region-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.region-tag {
  font-size: 11px;
  font-weight: 600;
  color: #f0f0f0;
}

.region-range {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: #7d7d7d;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.region-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Name, slider, exact value. */
.region-field {
  display: grid;
  grid-template-columns: 70px 1fr 58px;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: #8a8a8a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.region-field input[type="range"] {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.region-field input[type="number"],
.region-head select {
  width: 100%;
  min-width: 0;
  background: #131313;
  color: #f0f0f0;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 3px 4px;
  font: inherit;
  font-size: 11px;
}

.region-head select {
  width: auto;
  min-width: 96px;
  max-width: 140px;
  flex: 0 0 auto;
}

.color-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: #9d9d9d;
}

.color-group input[type="color"] {
  width: 48px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
}

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

.status-item {
  background: #0d0d0d;
  border: 1px solid #1f1f1f;
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #9d9d9d;
}

.status-item strong {
  font-size: 16px;
  color: #f0f0f0;
}

/* Full screen: the field alone, fitted to the display. script.js sizes the
   canvas; the bars around a field of another ratio take the field background. */
body.is-fullscreen .panel {
  display: none;
}

body.is-fullscreen .canvas-wrap {
  position: fixed;
  inset: 0;
  padding: 0;
  overflow: hidden;
  background: var(--field-bg, #000);
}

body.is-fullscreen #lifeCanvas {
  max-width: none;
  max-height: none;
  border-radius: 0;
}

/* Shown once on the way into full screen, then gone: nothing else is drawn
   over the field. The animation restarts each time the body class returns. */
.stage-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  margin: 0;
  padding: 10px 18px;
  border: 1px solid #2a2a2a;
  border-radius: 999px;
  background: rgba(13, 13, 13, 0.85);
  color: #e6e6e6;
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}

body.is-fullscreen .stage-hint {
  display: block;
  animation: stage-hint-fade 3.5s ease forwards;
}

@keyframes stage-hint-fade {
  0%,
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* The pointer goes away once it rests. */
body.is-idle .canvas-wrap,
body.is-idle #lifeCanvas {
  cursor: none;
}
