:root {
  color-scheme: dark;
  --bg: #101412;
  --panel: #171b18;
  --panel-2: #20251f;
  --line: #374036;
  --text: #f4efe5;
  --muted: #b9b2a6;
  --gold: #d6a851;
  --gold-2: #f1cf84;
  --danger: #e08d75;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
select {
  font: inherit;
}

button,
.file-action {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #252b24;
  color: var(--text);
  min-height: 44px;
  padding: 0 14px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 0 12px;
  background: #111513;
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1280px;
  margin: 0 auto 16px;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--gold-2);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

.stage-wrap {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.stage {
  position: relative;
  width: min(100%, 78vh);
  max-width: 760px;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.06) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.06) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.06) 75%),
    #1b211d;
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  box-shadow: var(--shadow);
}

#camera,
#frameOverlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#camera {
  object-fit: cover;
  transform: scaleX(var(--mirror, 1));
}

#frameOverlay {
  object-fit: fill;
  pointer-events: none;
  z-index: 2;
}

.stage-message {
  position: absolute;
  inset: auto 18px 18px;
  z-index: 3;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(16, 20, 18, 0.84);
  color: var(--text);
  text-align: center;
}

.capture-row,
.button-row,
.post-capture-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.post-capture-actions button {
  min-width: 132px;
  border-color: rgba(214, 168, 81, 0.75);
  background: #342817;
}

.capture-button {
  width: 72px;
  height: 72px;
  min-height: 72px;
  border-radius: 50%;
  border: 4px solid var(--gold-2);
  background: radial-gradient(circle at 50% 50%, #f7ead0 0 42%, #9e6d29 44% 100%);
  box-shadow: 0 0 0 6px rgba(214, 168, 81, 0.14);
}

.secondary {
  width: 96px;
}

.panel {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel section {
  display: grid;
  gap: 10px;
}

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

.file-action {
  display: inline-grid;
  place-items: center;
  position: relative;
  min-width: 96px;
}

.file-action input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

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

.frame-option {
  display: grid;
  gap: 7px;
  align-content: start;
  min-height: 132px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
}

.frame-option[aria-pressed="true"] {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--gold);
}

.frame-option img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: contain;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.09) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.09) 25%, transparent 25%),
    #111513;
  background-size: 18px 18px;
}

.frame-option span {
  font-size: 0.82rem;
  line-height: 1.2;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.control-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.latest-shot {
  min-height: 100px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #111513;
  color: var(--muted);
  text-align: center;
}

.latest-shot img {
  width: 100%;
  display: block;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  min-height: 72px;
}

.gallery button {
  min-height: auto;
  padding: 0;
  overflow: hidden;
  background: #111513;
}

.gallery img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
}

.text-button {
  border: none;
  background: transparent;
  color: var(--danger);
  min-height: 32px;
  padding: 0 4px;
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 1.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .panel {
    box-shadow: none;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .stage {
    width: 100%;
  }

  .frame-list {
    grid-template-columns: 1fr 1fr;
  }

  .secondary {
    width: 82px;
  }
}
