:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #101010;
  --panel-strong: #171717;
  --hero-white: #f2f0ea;
  --line: rgba(244, 241, 235, 0.12);
  --text: var(--hero-white);
  --muted: #a8a39c;
  --soft: #d8d5ce;
  --hero-muted: rgba(242, 240, 234, 0.72);
  --hero-line: rgba(242, 240, 234, 0.14);
  --accent: #8fa7a2;
  --accent-2: #c7d8d4;
  --danger: #ff6b86;
  font-family: "Helvetica Neue", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(244, 241, 235, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 241, 235, 0.028) 1px, transparent 1px),
    var(--bg);
  background-size: 25vw 25vw;
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.hero-section {
  min-height: clamp(620px, 84vh, 880px);
  display: grid;
  grid-template-rows: auto 1fr;
  border-bottom: 1px solid var(--hero-line);
  padding: 0 0 clamp(34px, 5vw, 64px);
  position: relative;
}

.hero-topline {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(360px, 1.6fr) minmax(230px, 1fr);
  align-items: center;
  gap: 22px;
  min-height: 76px;
  border-bottom: 1px solid var(--hero-line);
}

.hero-info-block {
  display: grid;
  gap: 6px;
  color: var(--hero-muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.hero-info-block strong {
  color: var(--hero-white);
  font-size: 0.92rem;
  font-weight: 650;
}

.hero-info-block a,
.hero-info-block span {
  color: var(--hero-muted);
  text-decoration: none;
}

.hero-info-block a:hover {
  color: var(--hero-white);
}

.hero-info-block--right {
  justify-items: end;
  text-align: right;
  align-self: center;
}

.offline-status {
  grid-column: 1 / -1;
  width: fit-content;
  border: 1px solid var(--hero-line);
  color: var(--hero-muted);
  padding: 5px 8px;
  font-size: 0.64rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.install-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  border-bottom: 1px solid var(--hero-line);
  color: var(--hero-muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.install-strip[hidden] {
  display: none;
}

.install-button {
  min-height: 30px;
  border: 1px solid rgba(242, 240, 234, 0.22);
  border-radius: 2px;
  background: transparent;
  color: var(--hero-white);
  cursor: pointer;
  padding: 0 12px;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.install-button:disabled {
  cursor: default;
  opacity: 0.58;
}

.hero-quick-links {
  display: flex;
  justify-content: center;
  gap: clamp(12px, 2vw, 28px);
  color: var(--hero-muted);
  font-size: 0.76rem;
  line-height: 1.1;
  white-space: nowrap;
}

.hero-quick-links span:first-child {
  color: var(--hero-white);
  font-weight: 650;
}

.export-button {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 30px;
  border: 0;
  border-left: 1px solid rgba(5, 5, 5, 0.18);
  border-radius: 0;
  background: transparent;
  color: var(--bg);
  cursor: pointer;
  padding: 0 12px;
  font-size: clamp(0.58rem, 1vw, 0.72rem);
  font-weight: 620;
  letter-spacing: 0.02em;
}

.export-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.hero-layout {
  display: grid;
  grid-template-rows: auto auto 1fr;
  align-content: start;
  gap: clamp(28px, 4.2vw, 50px);
  padding-top: clamp(48px, 6.2vw, 84px);
  position: relative;
}

.hero-brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: clamp(220px, 32vw, 430px);
  overflow: hidden;
}

.hero-brand-mark img {
  display: block;
  width: min(100%, 1320px);
  max-width: 100%;
  max-height: clamp(220px, 31vw, 420px);
  height: auto;
  object-fit: contain;
  object-position: center;
  filter: brightness(0.965) sepia(0.08) saturate(0.82);
}

.hero-brand-mark span {
  color: var(--hero-white);
  font-size: clamp(4.3rem, 18vw, 15rem);
  font-weight: 950;
  line-height: 0.78;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
}

.hero-copy {
  display: grid;
  gap: 20px;
  max-width: 1040px;
}

.hero-title-lockup {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  width: fit-content;
  max-width: 100%;
}

.hero-title-lockup h1 {
  max-width: min-content;
}

.hero-title-mark {
  flex: 0 0 auto;
  width: 92px;
  height: auto;
  filter: brightness(0) saturate(100%) invert(94%) sepia(10%) saturate(216%) hue-rotate(3deg) brightness(105%) contrast(90%);
  transform: translate(-18px, 96px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--hero-white);
  font-size: clamp(3.7rem, 10.2vw, 9.2rem);
  font-weight: 520;
  line-height: 0.91;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.hero-copy p:not(.eyebrow) {
  max-width: 760px;
  color: var(--hero-white);
  font-size: clamp(1.08rem, 2.25vw, 2.28rem);
  font-weight: 430;
  line-height: 1.22;
}

.hero-category-bar {
  display: grid;
  grid-template-columns: 1.15fr repeat(4, 1fr);
  min-height: 34px;
  background: var(--hero-white);
  color: var(--bg);
  font-size: clamp(0.58rem, 1vw, 0.72rem);
  font-weight: 620;
  letter-spacing: 0.02em;
  line-height: 1;
}

.hero-category-bar span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-right: 1px solid rgba(5, 5, 5, 0.18);
  padding: 0 10px;
  white-space: nowrap;
}

.hero-category-bar .bar-intro {
  justify-content: flex-start;
  gap: 10px;
  padding-left: 14px;
  text-transform: none;
}

.bar-intro i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--bg);
  flex: 0 0 auto;
}

.shape-tab {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
}

.capture-panel,
.panel,
.preset-panel,
.controls-panel,
.map-card,
.mobile-debug-panel {
  border: 1px solid rgba(242, 240, 234, 0.13);
  background: rgba(8, 8, 8, 0.92);
  box-shadow: none;
  backdrop-filter: none;
}

.capture-panel {
  margin: 28px 0 16px;
  border-radius: 2px;
}

.mobile-debug-panel {
  margin: 0 0 16px;
  border-radius: 2px;
}

.mobile-debug-panel[hidden] {
  display: none;
}

.mobile-debug-output {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  padding: 16px 18px 18px;
  border-top: 1px solid rgba(242, 240, 234, 0.11);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.35;
}

.mobile-debug-output strong {
  color: var(--hero-white);
  font-weight: 700;
}

.mobile-debug-output span {
  word-break: break-word;
}

.mobile-debug-action {
  margin: 0 18px 18px;
  min-height: 42px;
  border: 1px solid rgba(242, 240, 234, 0.28);
  border-radius: 2px;
  background: var(--hero-white);
  color: var(--bg);
  cursor: pointer;
  padding: 0 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.capture-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px;
}

.upload-action-card {
  display: grid;
  justify-content: center;
  justify-items: center;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 580px;
  min-height: 148px;
  border: 1px solid rgba(242, 240, 234, 0.14);
  background: rgba(242, 240, 234, 0.018);
  color: var(--hero-white);
  cursor: pointer;
  padding: 24px;
  text-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.upload-action-card:last-child {
  border-bottom: 1px solid rgba(242, 240, 234, 0.14);
}

.upload-action-card:hover,
.upload-action-card:focus-visible {
  background: rgba(242, 240, 234, 0.055);
  outline: none;
}

.upload-action-icon {
  display: block;
  width: 60px;
  height: 60px;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(94%) sepia(10%) saturate(216%) hue-rotate(3deg) brightness(105%) contrast(90%);
}

.upload-action-copy {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.upload-action-copy strong {
  color: var(--hero-white);
  font-size: 0.82rem;
  font-weight: 620;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.upload-action-copy small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.native-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.workspace-grid {
  display: grid;
  gap: 14px;
}

.panel {
  border-radius: 2px;
  overflow: hidden;
}

.panel-heading {
  min-height: 68px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(242, 240, 234, 0.11);
}

.status-pill {
  border: 1px solid rgba(242, 240, 234, 0.18);
  border-radius: 2px;
  color: var(--hero-white);
  padding: 6px 9px;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#cropCanvas,
.three-mount {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
    #080808;
  background-size: 20px 20px;
}

.three-mount {
  min-height: 310px;
  aspect-ratio: 1 / 0.95;
  pointer-events: auto;
  position: relative;
  contain: layout paint;
}

.three-mount canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.three-mount canvas:active {
  cursor: grabbing;
}

.shape-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: min(240px, 54vw);
}

.preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid rgba(242, 240, 234, 0.11);
  background: rgba(242, 240, 234, 0.025);
}

.secondary-button {
  min-height: 36px;
  border: 1px solid rgba(242, 240, 234, 0.18);
  border-radius: 2px;
  background: transparent;
  color: var(--hero-white);
  cursor: pointer;
  padding: 0 12px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.preset-panel {
  display: grid;
  gap: 14px;
  margin: 16px 0;
  padding: 18px;
  border-radius: 2px;
}

.preset-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preset-tab {
  min-height: 38px;
  border: 1px solid rgba(242, 240, 234, 0.13);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.preset-tab.is-active {
  border-color: rgba(242, 240, 234, 0.7);
  background: var(--hero-white);
  color: var(--bg);
}

.shape-tab {
  min-height: 32px;
  border-radius: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  padding: 0 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.shape-tab.is-active {
  background: var(--text);
  color: var(--bg);
  border-color: transparent;
  font-weight: 800;
}

.controls-panel {
  display: grid;
  gap: 20px;
  margin: 16px 0;
  padding: 18px;
  border-radius: 2px;
}

.control {
  display: grid;
  gap: 10px;
}

.control label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.control span {
  color: var(--text);
  font-weight: 800;
}

.control small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.toggle-control input {
  width: 16px;
  height: 16px;
  accent-color: var(--hero-white);
}

.export-resolution-control {
  align-self: stretch;
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid rgba(242, 240, 234, 0.12);
  background: rgba(242, 240, 234, 0.018);
}

.preview-quality-control {
  align-self: stretch;
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid rgba(242, 240, 234, 0.12);
  background: rgba(242, 240, 234, 0.018);
}

.preview-mapping-control {
  align-self: stretch;
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid rgba(242, 240, 234, 0.12);
  background: rgba(242, 240, 234, 0.018);
}

.resolution-options,
.quality-options,
.mapping-options {
  display: grid;
  gap: 8px;
}

.resolution-options {
  grid-template-columns: repeat(3, 1fr);
}

.quality-options {
  grid-template-columns: repeat(2, 1fr);
}

.mapping-options {
  grid-template-columns: minmax(88px, 0.72fr) minmax(160px, 1.28fr);
}

.resolution-option,
.quality-option,
.mapping-option {
  min-height: 44px;
  border: 1px solid rgba(242, 240, 234, 0.2);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  touch-action: manipulation;
}

.resolution-option.is-active,
.quality-option.is-active,
.mapping-option.is-active {
  background: var(--hero-white);
  border-color: var(--hero-white);
  color: var(--bg);
}

.invert-toggle {
  align-self: end;
}

.direction-controls {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  padding: 14px;
  border: 1px solid rgba(242, 240, 234, 0.12);
  background: rgba(242, 240, 234, 0.018);
}

.direction-controls small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--hero-white);
  min-height: 34px;
}

.maps-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding-bottom: 28px;
}

.map-card {
  border-radius: 2px;
  overflow: hidden;
}

.map-card canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: #080808;
}

.map-card span {
  display: block;
  padding: 10px 12px;
  border-top: 1px solid rgba(242, 240, 234, 0.1);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

  .workspace-grid {
    grid-template-columns: 0.92fr 1.08fr;
  }

  .controls-panel {
    grid-template-columns: repeat(3, 1fr);
  }

  .preset-panel {
    grid-template-columns: 0.5fr 1fr;
    align-items: center;
  }

  .maps-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1024px) {
  .hero-brand-mark img {
    width: min(100%, 1320px);
  }
}

@media (max-width: 900px) {
  .hero-topline {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 16px;
    padding: 18px 0;
  }

  .hero-quick-links {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .hero-info-block--right {
    justify-items: start;
    text-align: left;
  }

  .offline-status {
    grid-column: auto;
  }

  .install-strip {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 0;
  }

  .hero-category-bar {
    grid-template-columns: 1fr 1fr;
  }

  .hero-category-bar .bar-intro {
    grid-column: 1 / -1;
    border-bottom: 1px solid rgba(5, 5, 5, 0.18);
  }

  .hero-category-bar span:nth-child(3) {
    border-right: 0;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .app-shell {
    padding: 24px;
  }

  .hero-section {
    min-height: auto;
  }

  .hero-copy p:not(.eyebrow) {
    max-width: 680px;
  }

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

  .three-mount {
    min-height: 420px;
    aspect-ratio: 1 / 0.74;
  }

  .controls-panel {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  body {
    background-size: 50vw 50vw;
  }

  .app-shell {
    padding: 14px;
  }

  .hero-section {
    min-height: auto;
    padding-bottom: 32px;
  }

  .hero-topline {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px 0;
  }

  .hero-quick-links {
    display: none;
  }

  .hero-info-block--right {
    display: none;
  }

  .hero-info-block {
    gap: 4px;
  }

  .hero-layout {
    gap: 24px;
    padding-top: 36px;
  }

  .hero-title-lockup {
    align-items: flex-start;
    gap: 14px;
  }

  .hero-title-mark {
    width: clamp(48px, 13vw, 56px);
    margin-bottom: 0;
    transform: translate(-8px, 52px);
  }

  h1 {
    font-size: clamp(3.25rem, 18vw, 5.6rem);
    line-height: 0.92;
  }

  .hero-copy {
    gap: 16px;
  }

  .hero-copy p:not(.eyebrow) {
    max-width: 28rem;
    font-size: clamp(1.05rem, 5vw, 1.55rem);
    line-height: 1.24;
  }

  .hero-category-bar {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .hero-category-bar span,
  .export-button {
    justify-content: flex-start;
    min-height: 38px;
    border-right: 0;
    border-bottom: 1px solid rgba(5, 5, 5, 0.18);
    padding: 0 14px;
  }

  .export-button {
    border-left: 0;
    border-top: 0;
    text-align: left;
  }

  .hero-brand-mark {
    min-height: 118px;
  }

  .hero-brand-mark img {
    width: 100%;
    max-height: 150px;
  }

  .capture-panel {
    margin-top: 20px;
  }

  .mobile-debug-output {
    grid-template-columns: 1fr;
  }

  .capture-actions {
    align-items: stretch;
    gap: 14px;
    padding: 18px;
  }

  .upload-action-card {
    max-width: none;
    width: 100%;
    min-height: 136px;
    padding: 20px 18px;
  }

  .upload-action-icon {
    width: 54px;
    height: 54px;
  }

  .workspace-grid,
  .controls-panel,
  .maps-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .shape-tabs {
    width: 100%;
  }

  .shape-tab,
  .preset-tab,
  .secondary-button {
    min-height: 44px;
  }

  .three-mount {
    min-height: 360px;
    aspect-ratio: 1 / 0.9;
  }

  .preview-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .preset-panel,
  .controls-panel {
    padding: 16px;
  }

  .export-resolution-control,
  .preview-quality-control,
  .preview-mapping-control {
    order: -1;
    padding: 16px;
  }

  .resolution-options,
  .quality-options,
  .mapping-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .mapping-options {
    grid-template-columns: 1fr;
  }

  .resolution-option,
  .quality-option,
  .mapping-option {
    min-height: 48px;
    font-size: 0.78rem;
  }

  .direction-controls {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .preset-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .control {
    gap: 12px;
  }

  .control label,
  .toggle-control {
    font-size: 0.74rem;
  }

  input[type="range"] {
    min-height: 44px;
  }
}

@media (max-width: 420px) {
  .hero-section {
    min-height: auto;
  }

  .hero-layout {
    gap: 22px;
    padding-top: 30px;
  }

  .app-shell {
    padding: 12px;
  }

  h1 {
    font-size: clamp(3rem, 18vw, 4.7rem);
  }

  .hero-brand-mark {
    min-height: 96px;
  }

  .hero-brand-mark img {
    max-height: 120px;
  }

  .preset-tabs {
    grid-template-columns: 1fr;
  }

  .resolution-options,
  .quality-options,
  .mapping-options {
    grid-template-columns: 1fr;
  }

  .three-mount {
    min-height: 360px;
  }
}
