:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-strong: #f0f4f2;
  --text: #17201b;
  --muted: #60706a;
  --line: #cad5cf;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warning: #9a3412;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(23, 32, 27, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.14), transparent 38%),
    linear-gradient(225deg, rgba(190, 97, 36, 0.12), transparent 40%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: clamp(16px, 3vw, 36px);
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.workspace__header {
  display: flex;
  gap: 24px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 22px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2.1rem, 2.9rem, 3.1rem);
  line-height: 1.03;
}

.article-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  margin-top: 14px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
}

.article-link:hover {
  color: #ffffff;
  background: var(--accent);
}

h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.session-panel {
  display: grid;
  gap: 8px;
  justify-items: end;
  min-width: min(330px, 100%);
}

.enter-vr,
.share-action {
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.25);
  cursor: pointer;
}

.enter-vr:hover:not(:disabled),
.share-action:hover {
  background: var(--accent-strong);
}

.share-action {
  border: 1px solid var(--accent);
  color: var(--accent-strong);
  background: #ffffff;
  box-shadow: none;
}

.share-action:hover {
  color: #ffffff;
}

.enter-vr:disabled {
  color: #67736e;
  background: #d8e1dd;
  box-shadow: none;
  cursor: not-allowed;
}

.session-status {
  max-width: 360px;
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
  text-align: right;
}

.session-status[data-tone="error"] {
  color: var(--danger);
}

.session-status[data-tone="warn"] {
  color: var(--warning);
}

.link-status,
.link-output {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
  text-align: right;
}

.link-status[data-tone="success"] {
  color: var(--accent-strong);
}

.link-status[data-tone="warn"] {
  color: var(--warning);
}

.link-output {
  overflow-wrap: anywhere;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
}

.link-output[hidden] {
  display: none;
}

.experiment-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.experiment-tabs label {
  position: relative;
  cursor: pointer;
}

.experiment-tabs input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.experiment-tabs span {
  display: grid;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 7px;
  place-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.experiment-tabs input:checked + span {
  color: #ffffff;
  background: var(--accent);
}

.preview-grid,
.controls-grid,
.cfs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.eye-panel,
.control-panel,
.mode-panel,
.diagnostic-panel,
.cfs-section,
.custom-media-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.eye-panel,
.control-panel,
.cfs-section,
.custom-media-panel {
  display: grid;
  gap: 16px;
  padding: clamp(16px, 2vw, 22px);
}

.eye-panel__header,
.mode-panel {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.eye-summary {
  width: min(260px, 48%);
  min-height: 4.8em;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  text-align: right;
  white-space: pre-line;
}

.preview-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 42%, #eef4f0 0, #dfe9e5 58%, #ccd9d4 100%);
}

.preview-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.experiment-panel[hidden] {
  display: none;
}

.experiment-panel {
  margin-top: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.field[hidden] {
  display: none;
}

.field:first-child {
  grid-column: 1 / -1;
}

select,
input[type="color"],
input[type="range"],
input[type="number"] {
  width: 100%;
}

.stepper-control {
  display: grid;
  grid-template-columns: 36px minmax(88px, 1fr) 36px minmax(56px, auto);
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.stepper-control > input[type="range"],
.stepper-control > input[type="number"] {
  min-width: 0;
}

.stepper-control__button {
  display: grid;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 8px;
  place-items: center;
  color: var(--accent-strong);
  background: #ffffff;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1;
}

.stepper-control__button:hover:not(:disabled) {
  color: #ffffff;
  background: var(--accent);
}

.stepper-control__button:disabled {
  border-color: #cbd6d1;
  color: #8a9791;
  background: #edf2ef;
  cursor: not-allowed;
}

.stepper-control__value {
  min-width: 56px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: right;
  overflow-wrap: anywhere;
}

select,
input[type="color"],
input[type="number"] {
  min-height: 42px;
  border: 1px solid #bdccc5;
  border-radius: 8px;
  background: #ffffff;
}

select,
input[type="number"] {
  padding: 0 12px;
}

input[type="color"] {
  padding: 4px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.mode-panel,
.diagnostic-panel,
.cfs-section,
.custom-media-panel {
  margin-top: 18px;
  padding: 16px 18px;
}

.diagnostic-panel {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.diagnostic-panel--hidden {
  display: none !important;
}

.diagnostic-status {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.45;
}

.diagnostic-action {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-strong);
  background: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

.diagnostic-action:hover {
  color: #ffffff;
  background: var(--accent);
}

.section-header {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.cfs-rule {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
  text-align: right;
}

.cfs-grid .cfs-section:last-child {
  grid-column: 1 / -1;
}

.custom-media-status,
.custom-media-help,
.media-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.custom-media-status {
  max-width: 420px;
  text-align: right;
}

.custom-media-status[data-state="ready"],
.media-status[data-state="valid"] {
  color: var(--accent-strong);
}

.custom-media-status[data-state="incomplete"],
.media-status[data-state="pending"] {
  color: var(--warning);
}

.custom-media-status[data-state="invalid"],
.media-status[data-state="rejected"] {
  color: var(--danger);
}

.custom-media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.media-field {
  display: grid;
  gap: 12px;
  min-width: 0;
}

input[type="file"] {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #bdccc5;
  border-radius: 8px;
  background: #ffffff;
}

.custom-media-actions {
  display: flex;
  justify-content: flex-end;
}

.media-action {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-strong);
  background: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

.media-action:hover {
  color: #ffffff;
  background: var(--accent);
}

.checkbox-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #bdccc5;
  border-radius: 8px;
  background: #ffffff;
}

.checkbox-field input {
  inline-size: 18px;
  block-size: 18px;
  accent-color: var(--accent);
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.segmented label {
  position: relative;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 40px;
  padding: 0 16px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.segmented input:checked + span {
  color: #ffffff;
  background: var(--accent);
}

:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.45);
  outline-offset: 3px;
}

@media (max-width: 820px) {
  .workspace__header,
  .preview-grid,
  .controls-grid,
  .cfs-grid,
  .custom-media-grid,
  .eye-panel__header,
  .section-header,
  .mode-panel,
  .diagnostic-panel {
    grid-template-columns: 1fr;
  }

  .workspace__header,
  .eye-panel__header,
  .section-header,
  .mode-panel,
  .diagnostic-panel {
    display: grid;
  }

  .session-panel,
  .eye-summary,
  .cfs-rule,
  .custom-media-status,
  .link-status,
  .link-output {
    justify-items: start;
    width: 100%;
    text-align: left;
  }

  .preview-grid,
  .controls-grid,
  .cfs-grid,
  .custom-media-grid {
    display: grid;
  }

  .cfs-grid .cfs-section:last-child {
    grid-column: auto;
  }
}

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

  .stepper-control {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }

  .stepper-control__value {
    grid-column: 1 / -1;
    text-align: left;
  }
}
