:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --panel: #ffffff;
  --page: #f4f7fa;
  --accent: #0f766e;
  --accent-strong: #0b5d57;
  --accent-soft: #d9f3ef;
  --sky: #e4f3ff;
  --warning: #b45309;
  --shadow: 0 18px 40px rgba(22, 35, 54, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(228, 243, 255, 0.7), rgba(244, 247, 250, 0) 360px),
    var(--page);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 18px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.98;
}

h2 {
  margin-bottom: 3px;
  font-size: 1.08rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.format-pill {
  display: grid;
  gap: 2px;
  min-width: 132px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 20px rgba(31, 50, 73, 0.06);
  text-align: right;
}

.format-pill span {
  color: var(--ink);
  font-weight: 800;
}

.format-pill strong {
  color: var(--muted);
  font-size: 0.84rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(235px, 300px) minmax(280px, 1fr) minmax(255px, 320px);
  gap: 16px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 32px;
  align-items: start;
}

.tool-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tool-panel {
  padding: 18px;
}

.preview-panel {
  min-width: 0;
  padding: 18px;
}

.panel-heading,
.preview-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading {
  justify-content: flex-start;
}

.panel-heading p,
.preview-heading p,
.rules-box li,
.helper-text,
.status-line {
  color: var(--muted);
}

.panel-heading p,
.preview-heading p {
  margin-bottom: 0;
  font-size: 0.9rem;
  line-height: 1.35;
}

.step-dot {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.action-grid,
.download-grid,
.camera-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.primary-action,
.secondary-action,
.ghost-action {
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 13px;
  font-weight: 800;
  text-align: center;
}

.primary-action {
  background: var(--accent);
  color: #ffffff;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action {
  border: 1px solid #9fb6ce;
  background: #eef7ff;
  color: #164468;
}

.secondary-action:hover {
  background: #dff0ff;
}

.ghost-action {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.compact {
  min-height: 36px;
  padding: 7px 12px;
}

.camera-box {
  margin-top: 14px;
}

.camera-box video {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-actions {
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.helper-text {
  margin: 10px 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.rules-box {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.rule-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rule-list li {
  position: relative;
  padding-left: 22px;
  font-size: 0.88rem;
  line-height: 1.35;
}

.rule-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.42em;
  width: 9px;
  height: 9px;
  border: 2px solid var(--accent);
  border-radius: 50%;
}

.stage-wrap {
  display: grid;
  place-items: center;
  min-height: 560px;
  padding: 18px;
  border: 1px dashed #b6c6d7;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    #fbfdff;
  background-size: 28px 28px;
}

.photo-stage {
  position: relative;
  width: min(100%, 390px);
  aspect-ratio: 35 / 45;
  border: 1px solid #98a9bc;
  border-radius: 4px;
  background: #eef2f6;
  box-shadow: 0 16px 34px rgba(25, 42, 65, 0.18);
  overflow: hidden;
  touch-action: none;
}

#photoCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.guide-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.guide-overlay[hidden] {
  display: none;
}

.guide-face {
  position: absolute;
  left: 18%;
  top: 13%;
  width: 64%;
  height: 60%;
  border: 2px solid rgba(15, 118, 110, 0.78);
  border-radius: 50%;
}

.guide-eyes,
.guide-shoulders {
  position: absolute;
  left: 0;
  width: 100%;
  border-top: 1px dashed rgba(180, 83, 9, 0.84);
}

.guide-eyes {
  top: 42%;
}

.guide-shoulders {
  top: 76%;
  border-color: rgba(15, 118, 110, 0.58);
}

.status-line {
  min-height: 22px;
  margin: 12px 0 0;
  font-size: 0.92rem;
  text-align: center;
}

.control-group {
  display: grid;
  gap: 8px;
  margin-bottom: 15px;
}

.control-group label {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
}

output {
  color: var(--muted);
  font-weight: 800;
}

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

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 750;
}

.switch-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

.background-controls {
  display: grid;
  gap: 12px;
}

.swatch-row {
  display: flex;
  gap: 10px;
}

.swatch {
  width: 38px;
  height: 38px;
  border: 2px solid #a9b7c7;
  border-radius: 50%;
  background: var(--swatch);
}

.swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.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: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .controls-panel {
    order: 2;
  }

  .preview-panel {
    order: 1;
  }

  .stage-wrap {
    min-height: 0;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    width: min(100% - 22px, 1180px);
    padding-top: 18px;
  }

  .format-pill {
    width: 100%;
    text-align: left;
  }

  .app-shell {
    width: min(100% - 22px, 1180px);
    gap: 12px;
  }

  .tool-panel,
  .preview-panel {
    padding: 14px;
  }

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

  .stage-wrap {
    padding: 10px;
  }

  .photo-stage {
    width: min(100%, 320px);
  }

  .camera-actions,
  .download-grid {
    grid-template-columns: 1fr;
  }
}
