:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f172a;
  color: #f8fafc;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(20, 184, 166, 0.22), transparent 32rem),
    linear-gradient(145deg, #0f172a 0%, #111827 52%, #172554 100%);
}

.orientationGuard {
  display: none;
}

body.landscapeBlocked {
  overflow: hidden;
}

body.landscapeBlocked .app {
  display: none;
}

body.landscapeBlocked .orientationGuard {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  gap: 0.5rem;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
  background: #0f172a;
  color: #f8fafc;
  text-align: center;
}

.orientationGuard strong {
  font-size: 1.35rem;
}

.orientationGuard p {
  color: #cbd5e1;
  line-height: 1.5;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: #2dd4bf;
  color: #042f2e;
  font: inherit;
  font-weight: 700;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 3px;
}

button.secondary {
  background: rgba(148, 163, 184, 0.22);
  color: #f8fafc;
  padding: 0.65rem 0.8rem;
}

.app {
  width: min(100%, 48rem);
  min-width: 0;
  min-height: 100vh;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom));
  display: grid;
  gap: 1rem;
}

.app > * {
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
  letter-spacing: 0;
}

.topbar p,
.safetyNotice p,
.probe,
.hint,
.historyList {
  color: #cbd5e1;
  line-height: 1.5;
}

.hint {
  margin-bottom: 0.8rem;
  font-size: 0.92rem;
}

.probe:empty {
  display: none;
}

.calibrationStrip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0 0 0.85rem;
  padding: 0.75rem 0;
  border-block: 1px solid rgba(148, 163, 184, 0.2);
}

.calibrationStrip span {
  min-width: 0;
}

.calibrationStrip small,
.calibrationStrip strong {
  display: block;
  overflow-wrap: anywhere;
}

.calibrationStrip small {
  color: #94a3b8;
  font-size: 0.75rem;
}

.calibrationStrip strong {
  margin-top: 0.2rem;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  background: rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
  font-size: 0.85rem;
}

.panel {
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  padding: 1rem;
}

.sessionControl {
  display: grid;
  gap: 0.65rem;
}

.subjective {
  display: grid;
  gap: 1.25rem;
  padding: 0.25rem 0;
}

.subjective[hidden] {
  display: none;
}

.rating {
  display: grid;
  gap: 0.35rem;
}

.ratingHeader,
.ratingAnchors {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.ratingHeader label {
  font-weight: 700;
}

.ratingHeader output {
  min-width: 2rem;
  color: #2dd4bf;
  font-size: 1.35rem;
  font-weight: 800;
  text-align: right;
}

.rating input[type="range"] {
  width: 100%;
  min-height: 44px;
  margin: 0;
  accent-color: #2dd4bf;
}

.ratingAnchors {
  color: #94a3b8;
  font-size: 0.78rem;
}

.subjective button {
  width: 100%;
}

.controls {
  display: block;
}

.controls button {
  width: 100%;
  min-height: 52px;
}

.progressHeader {
  min-height: 1.4rem;
  color: #e2e8f0;
  font-size: 0.9rem;
  font-weight: 650;
}

.progressTrack {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.24);
}

.progressTrack span {
  display: block;
  width: 0;
  height: 100%;
  background: #2dd4bf;
  transition: width 100ms linear;
}

.safetyNotice {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.safetyNotice p {
  margin-top: 0.35rem;
  font-size: 0.88rem;
}

.task {
  aspect-ratio: 1;
  width: 100%;
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 8px;
  overflow: hidden;
  background: #020617;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  touch-action: none;
}

.result dl,
.baseline dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0.75rem 0 0;
}

.result dl > div,
.baseline dl > div {
  min-width: 0;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.74);
  padding: 0.75rem;
}

.sectionHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.historyList {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.historyItem {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.74);
  padding: 0.75rem;
}

.historyItem time {
  color: #f8fafc;
  font-weight: 700;
}

.historyItem span {
  color: #cbd5e1;
  font-size: 0.9rem;
}

dt {
  color: #94a3b8;
  font-size: 0.8rem;
}

dd {
  margin: 0.2rem 0 0;
  font-weight: 700;
}

@media (max-width: 520px) {
  .controls,
  .sectionHeader,
  .historyItem {
    grid-template-columns: 1fr;
  }

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

}

@media (max-width: 360px) {
  .result dl,
  .baseline dl {
    grid-template-columns: 1fr;
  }
}
