:root {
  --bg: #0a0e14;
  --text: #edf3fb;
  --muted: #a8b6c8;
  --accent: #6ee7b7;
  --accent-2: #82b5ff;
  --danger: #ff8f9c;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --app-shell-max: 1280px;
  --app-shell-gap: 14px;
  --page-gutter: 18px;
  --sans: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 15px/1.42 var(--sans);
  background:
    linear-gradient(135deg, rgba(110, 231, 183, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(130, 181, 255, 0.14), transparent 34%),
    var(--bg);
}

.app-shell > .hero,
.app-shell > .panel { width: min(1180px, 100%); }

.hero,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
  box-shadow: var(--shadow);
}

.hero { padding: 18px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(32px, 5vw, 46px); line-height: 1; }
.hero p, .panel-copy, .status { margin: 0; color: rgba(237, 243, 251, 0.74); }

.panel { display: grid; gap: 12px; padding: 14px; }
.panel h2 { margin: 0 0 4px; font-size: 22px; }

.panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
}

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

button, input, select {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.24);
  color: var(--text);
  font: inherit;
}

button { min-height: 40px; padding: 9px 12px; cursor: pointer; font-weight: 750; }
button:hover { border-color: rgba(237, 243, 251, 0.28); background: rgba(255, 255, 255, 0.06); }
button.primary { border-color: rgba(110, 231, 183, 0.52); background: linear-gradient(180deg, rgba(110, 231, 183, 0.24), rgba(110, 231, 183, 0.1)); }
button.danger-soft.is-active { border-color: rgba(255, 143, 156, 0.48); background: linear-gradient(180deg, rgba(255, 143, 156, 0.22), rgba(255, 143, 156, 0.1)); }
button:disabled { cursor: not-allowed; opacity: 0.5; }

label { display: grid; gap: 6px; color: rgba(237, 243, 251, 0.72); font-size: 12px; font-weight: 650; }
input, select { width: 100%; padding: 9px 10px; outline: none; }
input:focus, select:focus { border-color: rgba(110, 231, 183, 0.72); box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.14); }
select option { background: #111928; }

.preview-shell {
  position: relative;
  width: 100%;
  min-height: 480px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #05070a;
}

#screenVideo, #selectionCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#screenVideo { object-fit: contain; }
#selectionCanvas { z-index: 1; cursor: crosshair; touch-action: none; }

.preview-empty, .output-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(237, 243, 251, 0.55);
  pointer-events: none;
}
[hidden] { display: none !important; }

.navigation-help {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(130, 181, 255, 0.055);
  color: var(--muted);
  font-size: 13px;
}
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.help-head strong { color: var(--text); }
.help-head button { min-height: 34px; padding: 6px 10px; }
.navigation-help ul, .limitations-panel ul { margin: 8px 0 0; padding-left: 20px; }
.navigation-help ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 24px; }

.coordinate-grid { display: grid; gap: 10px; }
.coordinate-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.output-preview-wrap {
  position: relative;
  min-height: 240px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #05070a;
}
#outputCanvas { display: block; max-width: 100%; max-height: 60vh; width: auto; height: auto; }
.pip-video { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.status { min-height: 20px; font-size: 13px; }
.status.is-ok { color: var(--accent); }
.status.is-warn { color: #ffd18a; }
.status.is-error { color: var(--danger); }

@media (max-width: 900px) {
  .panel-head { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
  .coordinate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .navigation-help ul { grid-template-columns: 1fr; }
  .preview-shell { min-height: 360px; }
}

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