:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: #090909;
  color: #f4f4f4;
  --panel: #111;
  --panel-2: #181818;
  --border: #303030;
  --muted: #8b8b8b;
  --text: #f4f4f4;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #090909;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

button,
select,
input {
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button,
select {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

button {
  min-height: 32px;
  padding: 0 10px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.35;
  cursor: default;
}

button.active {
  background: #f4f4f4;
  color: #090909;
  border-color: #f4f4f4;
}

select {
  min-height: 30px;
  padding: 0 24px 0 8px;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px;
}

.topbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.18em;
}

.status {
  max-width: 55%;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  text-align: right;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
  align-items: start;
}

.preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
}

#video {
  display: none;
}

#output {
  display: block;
  width: 100%;
  height: 100%;
  background: #050505;
}

.permission-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #000;
  display: grid;
  place-items: center;
  padding: 0;
}

.permission-layer.hidden {
  display: none;
}

.permission-title {
  align-self: center;
  font-size: clamp(22px, 5vw, 40px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.permission-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 20px;
  color: #8c8c8c;
  font-size: 12px;
  font-weight: 400;
}

.preview-actions {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.preview-actions button {
  pointer-events: auto;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(12px);
}

.controls {
  display: grid;
  gap: 6px;
}

.presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.presets button {
  min-height: 30px;
  padding: 0 6px;
  font-size: 10px;
}

.control-card {
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.section-heading h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.14em;
}

.control-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 6px;
  min-height: 27px;
}

.control-row > span,
.control-row output {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.07em;
}

.control-row output {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.control-row input[type="range"] {
  width: 100%;
  accent-color: #e9e9e9;
}

.control-row.disabled {
  opacity: 0.35;
}

.line-heading-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.color-well {
  width: 30px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
}

.color-well::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-well::-webkit-color-swatch {
  border: 0;
  border-radius: 3px;
}

.toggle-chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel-2);
}

.toggle-chip input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: #f4f4f4;
}

.toggle-chip span {
  font-size: 9px;
  letter-spacing: 0.08em;
}

.note {
  margin: 0;
  padding: 0 2px;
  color: #707070;
  font-size: 10px;
  line-height: 1.45;
}

dialog {
  width: min(92vw, 620px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0d0d0d;
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.76);
}

.dialog-body {
  padding: 10px;
}

.dialog-body img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #000;
  border-radius: 4px;
}

.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 8px;
  }

  .topbar {
    min-height: 42px;
    margin-bottom: 8px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .controls {
    gap: 6px;
  }

  .control-card {
    padding: 6px 7px;
  }

  .control-row {
    grid-template-columns: 54px minmax(0, 1fr) 40px;
    min-height: 26px;
  }
}
