:root {
  --bg: #121314;
  --surface: #1c1e20;
  --line: #2c2f33;
  --text: #e8e9ea;
  --muted: #8d9399;
  --accent: #6cb6ff;
  --warn: #ffb454;
  --vertical: #5fd4ff;
  --horizontal: #ffb454;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
}

header.bar {
  justify-content: space-between;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding-top: max(8px, env(safe-area-inset-top));
}

footer.bar {
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  touch-action: manipulation;
}

button:active {
  border-color: var(--accent);
}

select {
  min-width: 0;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

button:disabled,
input:disabled {
  opacity: 0.4;
}

button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#view,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}

#message[hidden],
#loupe[hidden],
#badge[hidden],
#no-snapshots[hidden],
#panel[hidden],
.toolset[hidden],
.effect[hidden],
.tool[hidden] {
  display: none;
}

#badge {
  position: absolute;
  top: 10px;
  left: 50%;
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgb(0 0 0 / 65%);
  color: #fff;
  font-size: 13px;
  transform: translateX(-50%);
  pointer-events: none;
}

#loupe {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 132px;
  height: 132px;
  border: 2px solid var(--text);
  border-radius: 50%;
  box-shadow: 0 2px 12px rgb(0 0 0 / 60%);
  pointer-events: none;
}

#loupe.right {
  left: auto;
  right: 12px;
}

.shade {
  fill: var(--bg);
  pointer-events: none;
}

.crop,
.corners,
.thirds,
.guide,
.guide-outline,
.guide-end {
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.crop {
  fill: none;
  stroke: #fff;
  stroke-width: 1;
}

.crop.faint {
  stroke-opacity: 0.5;
  stroke-dasharray: 4 4;
}

.corners {
  fill: none;
  stroke: #fff;
  stroke-width: 4;
}

.thirds {
  fill: none;
  stroke: #fff;
  stroke-opacity: 0.45;
  stroke-width: 1;
}

.target,
.target-line {
  fill: transparent;
  stroke: transparent;
  pointer-events: all;
}

.target-line {
  stroke-width: 36;
  stroke-linecap: round;
}

.guide-outline,
.centre-outline {
  fill: none;
  stroke: rgb(0 0 0 / 55%);
  stroke-width: 4;
}

.centre {
  fill: none;
  stroke: #fff;
  stroke-width: 1.5;
}

.centre,
.centre-outline {
  pointer-events: none;
}

.guide {
  stroke-width: 2;
}

.guide.selected {
  stroke-width: 3;
}

.guide.vertical {
  stroke: var(--vertical);
}

.guide.horizontal {
  stroke: var(--horizontal);
}

.guide-end {
  fill: var(--bg);
  stroke-width: 2;
}

.guide-end.vertical {
  stroke: var(--vertical);
}

.guide-end.horizontal {
  stroke: var(--horizontal);
}

.guide-end.selected {
  fill: #fff;
}

#panel {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.row input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 36px;
  margin: 0;
  accent-color: var(--accent);
}

.row output {
  min-width: 52px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row button {
  flex: 1;
  padding: 0 6px;
  white-space: nowrap;
}

.row .toggle {
  flex: 3;
}

.row label[for] {
  min-width: 92px;
}

#snapshot-list {
  max-height: 40vh;
  overflow-y: auto;
}

#snapshot-list .name {
  flex: 3;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row.tabs button {
  padding: 0 4px;
  font-size: 14px;
}

.row.tabs {
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  padding-bottom: 6px;
}

.sliders .row {
  min-height: 36px;
}

.sliders label,
.sliders output {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

header.bar select {
  flex: 1;
}

header.bar {
  gap: 6px;
}

header.bar button {
  padding: 0 9px;
  font-size: 14px;
}

#panel .hint {
  margin: 4px 0;
  font-size: 13px;
}

#tools {
  border-top: 1px solid var(--line);
}

#tools {
  gap: 8px;
}

#tools button {
  flex: 1;
  padding: 0 4px;
  font-size: 13px;
  white-space: nowrap;
}

.hint {
  color: var(--muted);
}

.status {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  color: var(--text);
}

.toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

#refresh-status[data-state="offline"] {
  color: var(--warn);
}

#build-status {
  margin-left: auto;
}
