:root {
  color-scheme: light;
  --bg: #f6f8f5;
  --panel: #ffffff;
  --text: #18201a;
  --muted: #59665d;
  --line: #cfd8cf;
  --accent: #146c5f;
  --accent-2: #2457a6;
  --warn: #a46300;
  --bad: #a02a2a;
  --ok: #1f7a46;
  --shadow: 0 18px 50px rgb(20 35 25 / 14%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
select {
  font: inherit;
}

button,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

button {
  padding: 0 12px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  filter: brightness(0.96);
}

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

select {
  width: 100%;
  padding: 0 10px;
}

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

.app-shell {
  height: 100%;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 92%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-actions button {
  min-width: 72px;
}

button.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eaf4ef;
  color: var(--ok);
  border: 1px solid #bfdbc9;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.muted {
  background: #eef1ef;
  color: var(--muted);
  border-color: var(--line);
}

.status-pill.warn {
  background: #fff5df;
  color: var(--warn);
  border-color: #e5c981;
}

.status-pill.bad {
  background: #fff0ef;
  color: var(--bad);
  border-color: #e7b6b2;
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(0, 1fr);
  overflow: hidden;
}

.workspace.sidebar-hidden {
  grid-template-columns: minmax(0, 1fr);
}

.workspace.sidebar-hidden .controls {
  display: none;
}

.panel {
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.controls {
  padding: 8px 16px 16px;
  overflow: auto;
}

.sidebar-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

#closeSidebarButton {
  width: 19px;
  min-width: 19px;
  height: 19px;
  min-height: 19px;
  border-radius: 4px;
}

#closeSidebarButton svg {
  width: 10px;
  height: 10px;
}

fieldset {
  margin: 0 0 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.check-row {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.viewer {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(45deg, #202420 25%, transparent 25%),
    linear-gradient(-45deg, #202420 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #202420 75%),
    linear-gradient(-45deg, transparent 75%, #202420 75%),
    #171a17;
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: pointer;
}

.viewer:focus {
  outline: 3px solid var(--accent-2);
  outline-offset: -3px;
}

video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}

video.cover {
  object-fit: cover;
}

video.fill {
  object-fit: fill;
}

.video-overlay {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 48%);
  pointer-events: none;
}

.video-overlay[hidden] {
  display: none;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100%;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .status-strip {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .topbar-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
  }

  .sidebar-toolbar {
    grid-column: 1 / -1;
  }

  .workspace.sidebar-hidden .controls {
    display: none;
  }

  fieldset {
    margin: 0;
  }

  .viewer {
    height: 62vh;
    min-height: 62vh;
  }
}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .status-strip {
    grid-column: 1;
  }

  .topbar-actions {
    grid-row: 2;
    justify-content: flex-start;
  }

  .status-strip {
    grid-row: 3;
  }
}
