:root {
  color-scheme: dark;
  --bg: #050a12;
  --surface: #0a1321;
  --surface-raised: #101c2d;
  --surface-soft: #132238;
  --border: #203149;
  --border-strong: #2e4666;
  --text: #f3f7fc;
  --text-muted: #9dafc7;
  --text-dim: #71839a;
  --primary: #54a8ff;
  --primary-strong: #2d90f5;
  --accent: #2ed994;
  --accent-strong: #15b97a;
  --danger: #ff6b75;
  --warning: #f5bc4d;
  --shadow: 0 18px 55px rgb(0 0 0 / 28%);
  --radius: 22px;
  --radius-small: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgb(48 112 179 / 20%), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
select,
input {
  font: inherit;
}

button,
select,
input[type="range"] {
  touch-action: manipulation;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(84 168 255 / 45%);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 0 16px calc(34px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding-top: env(safe-area-inset-top, 0px);
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand > span:last-child {
  display: grid;
  line-height: 1.16;
}

.brand strong {
  font-size: 1rem;
  letter-spacing: -0.015em;
}

.brand small {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgb(84 168 255 / 34%);
  border-radius: 13px;
  background: linear-gradient(145deg, #183e64, #0c2035);
  box-shadow: inset 0 1px rgb(255 255 255 / 10%);
}

.brand-mark::before {
  width: 22px;
  height: 15px;
  border: 2px solid #87c4ff;
  border-radius: 5px;
  content: "";
}

.brand-mark::after {
  position: absolute;
  width: 6px;
  height: 6px;
  border: 2px solid #87c4ff;
  border-radius: 50%;
  content: "";
}

.brand-mark span {
  position: absolute;
  top: 10px;
  left: 12px;
  width: 8px;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: #87c4ff;
}

.main-grid {
  display: grid;
  gap: 18px;
}

.preview-column,
.controls-column {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.preview-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #03070c;
  box-shadow: var(--shadow);
}

#cameraPreview {
  width: 100%;
  height: 100%;
  background: #03070c;
  object-fit: contain;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 32px 32px 68px;
  background:
    linear-gradient(135deg, rgb(29 66 105 / 28%), transparent 55%),
    repeating-linear-gradient(135deg, transparent 0 16px, rgb(255 255 255 / 1.5%) 16px 17px),
    #08111d;
  color: var(--text-muted);
  text-align: center;
}

.camera-placeholder strong {
  margin: 14px 0 5px;
  color: var(--text);
  font-size: 1rem;
}

.camera-placeholder span:last-child {
  max-width: 310px;
  font-size: 0.84rem;
}

.placeholder-icon {
  position: relative;
  width: 48px;
  height: 36px;
  border: 2px solid var(--border-strong);
  border-radius: 10px;
}

.placeholder-icon::before {
  position: absolute;
  inset: 8px 14px;
  border: 2px solid var(--text-dim);
  border-radius: 50%;
  content: "";
}

.placeholder-icon::after {
  position: absolute;
  top: -7px;
  left: 8px;
  width: 15px;
  height: 7px;
  border-radius: 4px 4px 0 0;
  background: var(--border-strong);
  content: "";
}

.preview-overlay {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.status-pill,
.resolution-pill {
  display: inline-flex;
  min-height: 31px;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 999px;
  background: rgb(4 10 18 / 74%);
  box-shadow: 0 5px 18px rgb(0 0 0 / 22%);
  color: #dbe7f5;
  font-size: 0.72rem;
  font-weight: 700;
  backdrop-filter: blur(12px);
}

.status-dot {
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-pill.ready .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgb(46 217 148 / 14%);
}

.shutter-flash {
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
}

.shutter-flash.flash {
  animation: flash 280ms ease-out;
}

@keyframes flash {
  0% { opacity: 0; }
  22% { opacity: 0.75; }
  100% { opacity: 0; }
}

.privacy-note,
.ios-warning,
.active-panel,
.settings-card,
.summary-card,
.photos-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(155deg, rgb(16 28 45 / 98%), rgb(8 19 33 / 98%));
}

.privacy-note {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.privacy-note strong {
  color: #dce8f5;
}

.privacy-icon {
  display: grid;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: rgb(46 217 148 / 14%);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
}

.active-panel {
  padding: 16px;
}

.active-panel-heading {
  display: flex;
  gap: 12px;
  align-items: center;
}

.active-panel-heading > div {
  display: grid;
  min-width: 0;
}

.active-panel-heading strong {
  font-size: 0.94rem;
}

.active-panel-heading span:last-child {
  overflow: hidden;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-indicator {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text-dim);
}

.run-indicator.active {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgb(46 217 148 / 12%);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 10px rgb(46 217 148 / 2%); }
}

.run-stats,
.storage-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.run-stats > div,
.storage-stats > div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgb(255 255 255 / 5%);
  border-radius: 11px;
  background: rgb(255 255 255 / 2.5%);
}

.run-stats span,
.storage-stats span {
  color: var(--text-dim);
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.run-stats strong,
.storage-stats strong {
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ios-warning {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 14px;
  border-color: rgb(245 188 77 / 28%);
  background: rgb(245 188 77 / 7%);
}

.ios-warning > span {
  display: grid;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid rgb(245 188 77 / 45%);
  border-radius: 50%;
  color: var(--warning);
  font-weight: 800;
}

.ios-warning p {
  margin: 0;
  color: #c8b68f;
  font-size: 0.77rem;
}

.ios-warning strong {
  color: #f1d69a;
}

.settings-card,
.summary-card,
.photos-card {
  padding: 18px;
}

.card-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.step-number {
  display: grid;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgb(84 168 255 / 35%);
  border-radius: 10px;
  background: rgb(84 168 255 / 11%);
  color: #91caff;
  font-size: 0.78rem;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 2px;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.card-heading p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.79rem;
}

.field-grid,
.field-group,
.custom-pair {
  display: grid;
  gap: 12px;
}

.field-group {
  gap: 7px;
}

.camera-fields {
  margin-top: 16px;
}

.field-group label {
  color: #c9d6e6;
  font-size: 0.76rem;
  font-weight: 700;
}

.field-help,
.action-help {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.7rem;
  line-height: 1.45;
}

select,
input[type="number"] {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #081321;
  color: var(--text);
  appearance: none;
}

select {
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 20px,
    calc(100% - 13px) 20px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

select:disabled,
input:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
}

.custom-pair {
  grid-template-columns: minmax(0, 1fr) minmax(112px, 0.55fr);
}

.range-field {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgb(255 255 255 / 2.5%);
}

.range-heading,
.range-scale,
.summary-heading,
.photos-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.range-heading output {
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 800;
}

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

.range-scale {
  color: var(--text-dim);
  font-size: 0.64rem;
}

.button,
.icon-button,
.text-button {
  border: 0;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.button {
  display: inline-flex;
  min-height: 50px;
  gap: 9px;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border-radius: 13px;
  box-shadow: inset 0 1px rgb(255 255 255 / 10%);
  font-size: 0.86rem;
}

.button-full {
  width: 100%;
}

.button-primary {
  border: 1px solid rgb(84 168 255 / 45%);
  background: linear-gradient(180deg, #237fdc, #1266b9);
}

.button-accent {
  background: linear-gradient(180deg, #2bd895, #0caa6c);
  color: #02130d;
}

.button-danger {
  border: 1px solid rgb(255 107 117 / 35%);
  background: rgb(255 107 117 / 10%);
  color: #ff9da4;
}

.button-ghost {
  border: 1px solid var(--border-strong);
  background: rgb(255 255 255 / 3%);
  color: #c6d4e5;
}

.button:not(:disabled):active,
.icon-button:not(:disabled):active {
  transform: translateY(1px);
}

.install-button {
  min-height: 38px;
  padding: 7px 12px;
  font-size: 0.72rem;
}

.icon-button {
  width: 48px;
  min-height: 48px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #0d1a2a;
  font-size: 1.3rem;
}

.text-button {
  min-height: 40px;
  padding: 5px;
  background: transparent;
  color: var(--primary);
  font-size: 0.72rem;
}

.summary-card {
  border-color: rgb(84 168 255 / 30%);
  background:
    radial-gradient(circle at 100% 0, rgb(44 139 231 / 16%), transparent 17rem),
    linear-gradient(155deg, #101e30, #091522);
}

.summary-heading,
.photos-heading {
  margin-bottom: 17px;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--primary);
  font-size: 0.63rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.summary-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.summary-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid rgb(255 255 255 / 6%);
}

.summary-list dt {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.summary-list dd {
  margin-left: 12px;
  color: #e6f0fb;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.estimate-box {
  display: grid;
  margin-top: 16px;
  padding: 15px;
  border: 1px solid rgb(46 217 148 / 22%);
  border-radius: 14px;
  background: rgb(46 217 148 / 7%);
}

.estimate-box > span {
  color: #89ac9f;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.estimate-box strong {
  margin-top: 3px;
  color: #75eab9;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.estimate-box p {
  margin: 5px 0 0;
  color: #83a598;
  font-size: 0.7rem;
}

.validation-message,
.alert {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid rgb(255 107 117 / 35%);
  border-radius: 11px;
  background: rgb(255 107 117 / 8%);
  color: #ffafb5;
  font-size: 0.75rem;
}

.alert {
  margin-top: 0;
}

.primary-actions,
.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.action-help {
  margin-top: 10px;
  text-align: center;
}

.photos-heading h2,
.summary-heading h2 {
  margin: 0;
}

.photo-count-badge {
  display: grid;
  min-width: 38px;
  height: 38px;
  padding: 0 8px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  color: #b8d9f7;
  font-size: 0.85rem;
}

.storage-stats {
  grid-template-columns: 1fr 1fr;
  margin-top: 0;
}

.gallery-empty {
  display: grid;
  min-height: 122px;
  margin-top: 14px;
  place-content: center;
  justify-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  color: var(--text-dim);
  text-align: center;
}

.gallery-empty span {
  font-size: 1.55rem;
}

.gallery-empty p {
  margin: 6px 0 0;
  font-size: 0.72rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.gallery:empty {
  display: none;
}

.photo-tile {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #050a11;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-download {
  position: absolute;
  right: 5px;
  bottom: 5px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 9px;
  background: rgb(3 8 14 / 78%);
  color: white;
  font-size: 0.85rem;
  text-decoration: none;
  backdrop-filter: blur(8px);
}

.toast {
  position: fixed;
  z-index: 20;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  left: 16px;
  max-width: 520px;
  margin: 0 auto;
  padding: 13px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: #15243a;
  box-shadow: 0 16px 45px rgb(0 0 0 / 45%);
  color: var(--text);
  font-size: 0.8rem;
}

.toast.error {
  border-color: rgb(255 107 117 / 45%);
  background: #351922;
  color: #ffc1c5;
}

footer {
  padding: 26px 8px 0;
  color: var(--text-dim);
  font-size: 0.7rem;
  text-align: center;
}

footer p {
  margin: 0;
}

noscript {
  display: block;
  padding: 18px;
  background: #411c23;
  color: white;
  text-align: center;
}

@media (min-width: 700px) {
  .app-shell {
    padding-right: 24px;
    padding-left: 24px;
  }

  .topbar {
    min-height: 88px;
  }

  .settings-card,
  .summary-card,
  .photos-card {
    padding: 22px;
  }

  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-pair,
  .range-field {
    grid-column: 1 / -1;
  }
}

@media (min-width: 960px) {
  .main-grid {
    grid-template-columns: minmax(0, 0.92fr) minmax(460px, 1.08fr);
    gap: 24px;
  }

  .preview-column {
    position: sticky;
    top: 18px;
    align-self: start;
  }

  .preview-card {
    aspect-ratio: 4 / 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
