/* Browser-only overrides. Load after app/styles.css; desktop files stay intact. */
:root {
  font-size: 16px;
  --muted: #a3b5a9;
  --dim: #80998a;
}

html { min-width: 0; }
body {
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  font-size: 16px;
  line-height: 1.5;
}
button, input, select { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
button:disabled { opacity: .48; }
[hidden] { display: none !important; }
.workspace { height: 100vh; height: 100dvh; }
.workspace, .studio-layout, .monitor-column, .settings-panel,
.settings-scroll, .header-actions, .camera-selector,
.position-fields > div, .output-fields > div { min-width: 0; }

.rail { width: 76px; }
.rail-item { font-size: 12px; gap: 6px; }
.rail-version { font-size: 10px; }
.offline-label { font-size: 10px; }
.app-header { min-height: 96px; height: auto; padding: 18px 24px; gap: 18px; }
.app-heading { flex-shrink: 0; }
.app-heading h1 { font-size: 26px; }
.eyebrow { font-size: 10px; letter-spacing: 1.5px; }
.header-actions { gap: 10px; }
.status-pill { font-size: 13px; margin-right: 4px; }
.button { min-height: 42px; padding: 0 14px; font-size: 14px; }
.button .icon { width: 18px; height: 18px; }
.button-small { min-height: 36px; padding: 0 11px; font-size: 13px; }
.button-icon { width: 44px; min-width: 44px; padding: 0; }
.button-quiet { padding-inline: 10px; }

.studio-layout { grid-template-columns: minmax(0, 1fr) 380px; }
.monitor-column { padding: 18px 24px 0; }
.section-heading { min-height: 36px; margin-bottom: 14px; }
.section-heading h2, .settings-header h2 { font-size: 16px; letter-spacing: .2px; }
.section-index { font-size: 12px; }
.section-subtitle { font-size: 10px; }
.preview-shell { min-height: 220px; }
.canvas-frame { min-height: 0; max-height: none; aspect-ratio: auto; }
#previewCanvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.preview-indicator { font-size: 12px; }
.monitor-caption { font-size: 10px; }
.preview-bottomline { gap: 12px; padding: 14px 16px 12px; font-size: 11px; }
.preview-bottomline > span { min-width: 0; }
.preview-dimensions { font-size: 11px; margin-left: 7px; }
.quick-actions { gap: 10px; margin-top: 12px; }
.quick-action { min-height: 72px; padding: 12px 10px; gap: 9px; }
.quick-action > span { min-width: 0; gap: 4px; }
.quick-action strong { font-size: 14px; }
.quick-action small { font-size: 11px; white-space: normal; line-height: 1.5; }
.quick-action kbd { display: none; }
.quick-action > .icon { width: 19px; height: 19px; }
.camera-card { margin-top: 14px; padding: 14px; }
.card-heading h2 { font-size: 15px; }
.card-heading > .icon { width: 18px; height: 18px; }
.local-badge { font-size: 11px; white-space: nowrap; }
.camera-selector select { min-height: 44px; }
.helper-text, .camera-card .helper-text { font-size: 13px; line-height: 1.7; }
.message-box { margin-top: 12px; padding: 10px 13px; font-size: 14px; line-height: 1.65; }
.obs-tip { display: none; }
.telemetry { margin-top: 12px; padding: 12px 0; min-height: 70px; gap: 20px; }
.telemetry > div { min-width: 0; gap: 5px; }
.telemetry-label { font-size: 12px; }
.telemetry strong { font-size: 13px; overflow-wrap: anywhere; }
.telemetry strong small { font-size: 10px; }

.settings-header { padding: 22px; gap: 10px; }
.save-status { font-size: 12px; }
.setting-section { padding: 21px 22px; }
.setting-section-title { margin-bottom: 17px; gap: 10px; }
.setting-section-title h3 { font-size: 15px; }
.setting-section-title > span { font-size: 10px; }
.field-label, .range-field > label, .position-fields .range-field label,
.color-row, .switch-row { font-size: 14px; }
.field-label { margin-bottom: 8px; color: #b3c7ba; }
select { min-width: 0; max-width: 100%; min-height: 42px; padding: 0 11px; font-size: 14px; }
.mode-switch { gap: 6px; padding: 5px; margin-top: 14px; }
.mode-button { min-height: 72px; padding: 10px 3px; font-size: 14px; gap: 8px; }
.mode-button[data-mode="halftone"], .mode-button[data-mode="glitch"] { min-height: 50px; gap: 10px; }
.mode-description { padding-bottom: 15px; font-size: 13px; line-height: 1.75; color: #a4c1ae; }
.range-field { margin-top: 19px; }
.range-field > label { gap: 8px; margin-bottom: 11px; }
.range-field output { flex-shrink: 0; font-size: 14px; }
.range-endpoints { font-size: 11px; color: #86a792; }
input[type="range"] { height: 6px; margin: 15px 0; }
input[type="range"]::-webkit-slider-thumb { height: 18px; width: 18px; }
input[type="range"]::-moz-range-thumb { height: 14px; width: 14px; border: 2px solid #293f2e; border-radius: 50%; background: #aae6bd; }
.effect-strength-field { margin-top: 0; padding-bottom: 18px; }
.color-row { margin-bottom: 19px; gap: 12px; }
.color-row > div > span { font-size: 13px; }
input[type="color"] { width: 39px; height: 32px; }
.switch-row { min-height: 44px; gap: 14px; }
.switch-row > span:first-child { min-width: 0; }
.switch-row small { font-size: 12px; line-height: 1.6; }
.switch-row:has(small) { min-height: 62px; }
.switch-row input { width: 38px; height: 32px; }
.switch-track { width: 35px; height: 20px; }
.switch-track::after { width: 12px; height: 12px; top: 3px; left: 3px; }
.switch-row input:checked + .switch-track::after { transform: translateX(15px); }
.position-fields { gap: 20px; }
.output-fields { grid-template-columns: minmax(0, 1fr) 112px; gap: 12px; }
.output-fields select { font-size: 14px; padding-inline: 9px; }
.custom-size-fields { margin-top: 15px; padding: 14px; }
.custom-size-inputs { grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr); gap: 10px; }
.custom-size-inputs input { min-height: 44px; padding: 10px; font-size: 16px; }
.custom-size-inputs .field-label span { font-size: 12px; }
.dimension-separator { font-size: 16px; line-height: 44px; }
.custom-size-fields .helper-text { margin-top: 11px; font-size: 12px; }
.custom-size-error { font-size: 13px; }
.apply-size-button { min-height: 42px; font-size: 14px; }
.output-dimensions-label { font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.profile-buttons .button { min-height: 42px; font-size: 14px; }
.profile-buttons .icon { width: 17px; height: 17px; }
.text-button { min-height: 40px; margin-top: 10px; font-size: 14px; }

.help-dialog { width: 640px; max-width: calc(100vw - 40px); max-height: calc(100dvh - 40px); padding: 26px; }
.dialog-heading { gap: 15px; }
.dialog-heading h2 { font-size: 24px; }
.dialog-heading .button-icon { width: 40px; min-width: 40px; min-height: 40px; }
.help-step { gap: 15px; }
.help-step > div { min-width: 0; }
.help-step h3 { font-size: 16px; }
.help-step p, .privacy-note { font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.help-step code { font-size: 13px; }
.shortcut-help h3 { font-size: 15px; flex-wrap: wrap; gap: 8px; }
.shortcut-help h3 > span { font-size: 12px; }
.shortcut-help > div { gap: 14px 10px; }
.shortcut-help > div > span { font-size: 13px; }
.shortcut-help kbd { font-size: 12px; }

@media (min-width: 1041px) {
  .camera-card { display: grid; grid-template-columns: 128px minmax(0, 1fr); column-gap: 14px; row-gap: 5px; align-items: center; }
  .camera-card .card-heading { margin: 0; flex-wrap: wrap; gap: 5px 7px; }
  .camera-card .local-badge { margin-left: 25px; }
  .camera-card .helper-text { grid-column: 2; margin: 0; font-size: 12px; }
}

@media (min-width: 1041px) and (max-width: 1300px) {
  .workspace { margin-left: 68px; }
  .rail { width: 68px; }
  .studio-layout { grid-template-columns: minmax(0, 1fr) 356px; }
  .app-header { padding-inline: 20px; }
  .monitor-column { padding-inline: 20px; }
  .settings-header, .setting-section { padding-inline: 20px; }
  .section-subtitle { display: none; }
  .header-actions { gap: 7px; }
  .status-pill { font-size: 12px; }
  .header-actions .button { padding-inline: 10px; }
  .quick-action { flex-direction: column; align-items: flex-start; gap: 5px; }
  .quick-action > .icon { display: none; }
  .preview-bottomline > span:last-child { max-width: 45%; text-align: right; }
}

/* Tablet and phone use the page scroll, with settings following the monitor. */
@media (max-width: 1040px) {
  body { height: auto; min-height: 100dvh; overflow: visible; }
  .rail {
    position: relative; inset: auto; width: 100%; min-height: 64px;
    padding: 9px 22px; flex-direction: row; gap: 18px;
    border-right: 0; border-bottom: 1px solid var(--line-soft);
  }
  .brand-mark { font-size: 29px; margin-right: 4px; }
  .rail-divider, .rail-version { display: none; }
  .rail-item { flex-direction: row; width: auto; min-height: 42px; padding: 8px 11px; gap: 8px; font-size: 13px; }
  .rail-item .icon { width: 20px; height: 20px; }
  .rail-spacer { min-width: 0; }
  .offline-label { transform: none; margin: 0; font-size: 10px; }
  .workspace { height: auto; min-height: 0; margin-left: 0; }
  .app-header { min-height: 0; padding: 22px; flex-wrap: wrap; gap: 18px; }
  .app-heading h1 { font-size: 27px; }
  .header-actions { flex: 1 1 auto; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
  .status-pill { font-size: 13px; }
  .studio-layout { display: block; }
  .monitor-column { overflow: visible; padding: 22px; }
  .section-heading { margin-bottom: 15px; }
  .section-subtitle { display: inline; }
  .preview-shell { flex: none; height: clamp(240px, 53vw, 470px); min-height: 0; max-height: none; }
  .canvas-frame { height: 100%; min-height: 0; max-height: none; }
  .quick-actions { margin-top: 14px; }
  .quick-action { min-height: 78px; padding: 14px; }
  .camera-card { margin-top: 17px; padding: 17px; }
  .camera-card .card-heading { margin-bottom: 12px; }
  .camera-card .helper-text { margin-top: 10px; font-size: 13px; }
  .message-box { font-size: 14px; padding: 12px 14px; margin-top: 14px; }
  .telemetry { margin-top: 18px; min-height: 70px; padding-bottom: 0; }
  .settings-panel { border-left: 0; border-top: 1px solid var(--line); }
  .settings-header { padding: 24px; }
  .settings-scroll { overflow: visible; height: auto; }
  .setting-section { padding: 24px; }
  .settings-scroll .mode-switch { max-width: 560px; }
  .mode-button { min-height: 76px; }
  .mode-button[data-mode="halftone"], .mode-button[data-mode="glitch"] { min-height: 54px; }
  .profile-section { padding-bottom: 30px; }
  .profile-buttons { max-width: 440px; }
}

@media (max-width: 640px) {
  .rail { min-height: 60px; gap: 9px; padding: 8px 16px; }
  .brand-mark { font-size: 27px; margin-right: 3px; }
  .rail-item { font-size: 12px; gap: 6px; padding: 8px; }
  .rail-item .icon { width: 18px; height: 18px; }
  .offline-label { font-size: 9px; gap: 4px; }
  .app-header { padding: 19px 16px 18px; gap: 15px; }
  .app-heading { width: 100%; }
  .app-heading h1 { font-size: 26px; }
  .eyebrow { font-size: 10px; }
  .header-actions {
    display: grid; flex: none; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "status stop" "start output"; gap: 8px 10px;
  }
  .status-pill { grid-area: status; margin: 0; white-space: normal; }
  #stopCamera { grid-area: stop; justify-self: end; min-height: 34px; }
  #startCamera { grid-area: start; }
  #openOutput { grid-area: output; }
  .header-actions .button { padding-inline: 8px; min-width: 0; }
  .header-actions .button:not(#stopCamera) { min-height: 46px; }
  .header-actions .button > span { min-width: 0; white-space: normal; }
  .button { min-height: 44px; }
  .button-small { min-height: 38px; }
  .monitor-column { padding: 18px 16px 22px; }
  .section-heading { gap: 10px; margin-bottom: 12px; }
  .section-heading > div { gap: 8px; }
  .section-subtitle { display: none; }
  .preview-shell { height: clamp(220px, 65vw, 360px); }
  .preview-topline { padding: 13px; }
  .preview-bottomline { padding: 13px; }
  .preview-bottomline > span:last-child, .monitor-caption { display: none; }
  .preview-dimensions { display: inline-block; margin-left: 7px; }
  .quick-actions { gap: 7px; margin-top: 10px; }
  .quick-action { min-height: 70px; padding: 12px 6px; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
  .quick-action > .icon { display: block; width: 18px; height: 18px; }
  .quick-action > span { flex: none; }
  .quick-action strong { font-size: 14px; }
  .quick-action small { display: none; }
  .camera-card { padding: 15px; margin-top: 15px; }
  .camera-card .card-heading { margin-bottom: 11px; }
  .camera-selector { gap: 9px; }
  .camera-selector .button-icon { min-width: 44px; width: 44px; }
  select { font-size: 16px; min-height: 44px; }
  .telemetry { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 10px; padding-top: 16px; }
  .telemetry .output-telemetry { margin: 0; text-align: left; grid-column: 1 / -1; flex-direction: row; gap: 14px; }
  .telemetry strong { font-size: 14px; }
  .settings-header, .setting-section { padding: 21px 18px; }
  .settings-header > div { gap: 9px; }
  .save-status { font-size: 11px; }
  .setting-section-title > span { font-size: 10px; letter-spacing: .8px; }
  .mode-switch { gap: 5px; padding: 5px; }
  .mode-button { min-height: 74px; font-size: 14px; }
  .mode-button[data-mode="halftone"], .mode-button[data-mode="glitch"] { min-height: 52px; }
  .mode-description { font-size: 14px; }
  .field-label, .range-field > label, .position-fields .range-field label,
  .color-row, .switch-row { font-size: 15px; }
  .position-fields { gap: 18px; }
  .position-fields .range-field label { flex-wrap: wrap; gap: 5px; }
  .output-fields { grid-template-columns: minmax(0, 1fr) 108px; gap: 12px; }
  .output-fields select { font-size: 14px; min-height: 44px; }
  .custom-size-fields { padding: 13px; }
  .custom-size-inputs { grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr); gap: 9px; }
  .custom-size-inputs input { padding: 10px 8px; min-height: 46px; font-size: 16px; }
  .custom-size-fields .helper-text { font-size: 13px; }
  .output-dimensions-label { font-size: 14px; }
  .help-dialog { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); padding: 20px 17px; }
  .dialog-heading h2 { font-size: 22px; }
  .help-step { gap: 11px; }
  .help-step > span { width: 28px; height: 28px; font-size: 11px; }
  .shortcut-help > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 360px) {
  .rail .is-active { padding-inline: 7px; }
  .rail .is-active > .icon { display: none; }
  .offline-label { display: none; }
  .header-actions .button { font-size: 13px; gap: 6px; }
  .output-fields { grid-template-columns: minmax(0, 1fr); }
  .custom-size-fields { padding: 11px; }
  .custom-size-inputs { gap: 6px; }
  .custom-size-inputs .field-label { font-size: 14px; }
}
