:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));
  --ground: #f0f0f0;
  --paper: #fffaf2;
  --white: #ffffff;
  --ink: #1a1a1a;
  --muted: #74706a;
  --line: rgba(26, 26, 26, .12);
  --accent: #f03018;
  --accent-soft: #fff1ed;
  --metal: #d8d6d1;
  --glass: rgba(255, 255, 255, .72);
  --shadow: 0 24px 70px rgba(26, 26, 26, .13);
  --small-shadow: 0 10px 30px rgba(26, 26, 26, .10);
  --radius: 26px;
  --display: "Oswald", "Arial Narrow", Impact, sans-serif;
  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(--ground); color: var(--ink); }
body { overflow-x: hidden; }
button, input, select { font: inherit; }
button { min-height: 44px; cursor: pointer; border: 0; }
img { -webkit-user-drag: none; user-select: none; }

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

.app {
  min-height: 100svh;
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: var(--eazo-safe-area-bottom);
  position: relative;
  isolation: isolate;
  overflow-x: clip;
}

.app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 76% 8%, rgba(255, 255, 255, .95), transparent 24%),
    radial-gradient(circle at 68% 11%, transparent 0 64px, rgba(240, 48, 24, .08) 65px, transparent 67px),
    linear-gradient(90deg, rgba(240, 48, 24, .95) 0 5px, transparent 5px),
    linear-gradient(180deg, #f7f6f2 0%, #eeeeec 100%);
}

.app::after {
  content: "";
  position: fixed;
  inset: auto 14px calc(var(--eazo-safe-area-bottom) - 18px) 14px;
  height: 40px;
  border-radius: 999px;
  z-index: -1;
  background: linear-gradient(180deg, rgba(255, 255, 255, .82), rgba(206, 202, 194, .28));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .95), 0 -18px 60px rgba(255, 255, 255, .46);
  pointer-events: none;
}

.shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 14px clamp(12px, 3vw, 34px) 16px;
  display: grid;
  gap: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-text { min-width: 0; }

.brand-mark {
  width: 42px; height: 42px;
  border-radius: 15px;
  background: linear-gradient(145deg, #fff, #e6e2dc);
  box-shadow: inset 0 1px 0 #fff, 0 8px 18px rgba(26, 26, 26, .12);
  position: relative;
  flex: 0 0 auto;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 5px rgba(240, 48, 24, .08);
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(24px, 7.4vw, 60px);
  line-height: .92;
  letter-spacing: .01em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.lang {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
  flex: 0 0 auto;
}
.lang button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .05em;
}
.lang button.active { background: var(--ink); color: var(--white); }

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.primary-pane { min-width: 0; display: grid; gap: 9px; order: 1; }
.supporting-pane { min-width: 0; order: 2; display: grid; gap: 10px; }

.status-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.meter {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .95), var(--small-shadow);
  backdrop-filter: blur(14px);
}
.meter-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.meter-track {
  margin-top: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(26, 26, 26, .09);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f03018, #f0c030);
  transition: width .35s ease;
}

.reveal-button {
  border-radius: 999px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  box-shadow: 0 12px 24px rgba(240, 48, 24, .24);
}
.reveal-button:disabled { background: #d6d2cc; color: #918b84; box-shadow: none; cursor: not-allowed; }

.portrait-card {
  border-radius: var(--radius);
  padding: 9px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .86), rgba(255, 250, 242, .62)),
    linear-gradient(90deg, transparent 0, rgba(255, 255, 255, .72) 50%, transparent 100%);
  border: 1px solid rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.portrait-stage {
  height: min(56svh, 560px);
  min-height: 340px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background: #e9e8e5;
}

.face-frame {
  height: 100%;
  width: auto;
  max-width: 100%;
  aspect-ratio: 2 / 3;
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #eee 0%, #d8d8d6 100%);
  box-shadow: inset 0 0 0 1px rgba(26, 26, 26, .09), 0 18px 45px rgba(26, 26, 26, .12);
  touch-action: none;
}

.face-photo {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
  object-fit: cover;
  z-index: 1;
  opacity: 0;
  transition: opacity .3s ease;
}
.face-photo.loaded { opacity: 1; }

.face-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  background:
    radial-gradient(ellipse at 50% 40%, #cbb6a6 0 22%, transparent 22.4%),
    radial-gradient(ellipse at 50% 66%, #cbb6a6 0 17%, transparent 17.4%),
    linear-gradient(180deg, #eeeae4, #d6d2cc);
}

canvas.paint-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  touch-action: none;
}

.ring-light {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 84px;
  height: 84px;
  z-index: 4;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .55);
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, .18), 0 0 26px rgba(255, 255, 255, .32);
  opacity: .55;
  pointer-events: none;
}

.mirror-line {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 1px;
  z-index: 5;
  background: linear-gradient(180deg, transparent, rgba(240, 48, 24, .6), transparent);
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}
.mirror-on .mirror-line { opacity: 1; }

.brush-cursor {
  position: fixed;
  width: var(--cursor, 28px);
  height: var(--cursor, 28px);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .9);
  background: radial-gradient(circle, var(--cursor-color, rgba(211, 51, 58, .28)), transparent 68%);
  box-shadow: 0 0 22px var(--cursor-color, rgba(211, 51, 58, .24));
  pointer-events: none;
  z-index: 60;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  transition: transform .12s ease, opacity .12s ease;
}
.brush-cursor.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }

.instruction {
  margin: 0;
  padding: 10px 12px;
  color: #59534d;
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(255, 255, 255, .88);
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9);
}

.tray {
  display: grid;
  gap: 10px;
  padding: 10px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .82), rgba(255, 255, 255, .55));
  border: 1px solid rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.brushes {
  display: grid;
  grid-template-columns: repeat(6, minmax(64px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.brushes::-webkit-scrollbar { display: none; }
.brush {
  min-width: 64px;
  height: 60px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 7px 5px 6px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(238, 234, 226, .84));
  color: var(--muted);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .92), 0 5px 12px rgba(26, 26, 26, .06);
  border: 1px solid rgba(26, 26, 26, .06);
  font-size: 11px;
  font-weight: 850;
  transition: transform .16s ease, background .16s ease, color .16s ease;
}
.brush::before {
  content: "";
  display: block;
  width: 28px;
  height: 18px;
  border-radius: 999px 999px 9px 9px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .85), var(--brush-color, #c93d48));
  box-shadow: inset 0 -4px 8px rgba(26, 26, 26, .08), 0 3px 9px rgba(26, 26, 26, .08);
}
.brush.active { background: var(--ink); color: white; transform: translateY(-2px); }

.swatches {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}
.swatches::-webkit-scrollbar { display: none; }
.swatch {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 14px;
  border: 1px solid rgba(26, 26, 26, .12);
  background: var(--swatch);
  box-shadow: inset 0 2px 9px rgba(255, 255, 255, .35), inset 0 -8px 12px rgba(26, 26, 26, .12), 0 6px 14px rgba(26, 26, 26, .09);
}
.swatch.active { outline: 3px solid var(--ink); outline-offset: 2px; }

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  align-items: center;
}
.range-group { display: grid; gap: 5px; min-width: 0; }
.range-group label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 850;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
.actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.action, .toggle {
  border-radius: 999px;
  background: rgba(255, 255, 255, .86);
  color: var(--ink);
  border: 1px solid rgba(26, 26, 26, .09);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .94);
}
.toggle.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(240, 48, 24, .25); }

.contact-sheet {
  padding: 10px;
  border-radius: 24px;
  background: rgba(255, 255, 255, .74);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: var(--small-shadow);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.sheet-title { font-size: 12px; font-weight: 950; letter-spacing: .08em; text-transform: uppercase; }
.sheet-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  max-height: 182px;
  overflow: auto;
  padding: 1px;
}
.thumb {
  aspect-ratio: 2 / 3;
  min-height: 58px;
  border-radius: 12px;
  border: 1px solid rgba(26, 26, 26, .08);
  overflow: hidden;
  padding: 0;
  background: linear-gradient(180deg, #f1f1ef, #d7d7d4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: transform .18s ease, box-shadow .18s ease, outline-color .18s ease;
  position: relative;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb.selected {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
  transform: translateY(-3px);
  box-shadow: 0 10px 18px rgba(240, 48, 24, .18);
}

.result {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  padding: var(--eazo-safe-area-top) 14px var(--eazo-safe-area-bottom);
  background: rgba(240, 240, 240, .88);
  backdrop-filter: blur(18px);
  overflow: auto;
}
.result.open { display: grid; place-items: center; }
.result-card {
  width: min(520px, 100%);
  display: grid;
  gap: 12px;
  border-radius: 30px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(255, 250, 242, .9));
  box-shadow: 0 34px 90px rgba(26, 26, 26, .22);
  border: 1px solid rgba(255, 255, 255, .95);
}
.compare {
  aspect-ratio: 2 / 3;
  max-height: 52svh;
  border-radius: 22px;
  overflow: hidden;
  position: relative;
  background: #ddd;
  touch-action: none;
  margin: 0 auto;
  width: auto;
}
.compare-pane { position: absolute; inset: 0; overflow: hidden; }
.compare-before { width: 50%; border-right: 1px solid rgba(255, 255, 255, .7); }
.compare-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.compare-before .compare-img { width: var(--compare-w, 100%); }
.pane-tag {
  position: absolute;
  top: 10px;
  z-index: 6;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: rgba(26, 26, 26, .68);
  color: #fff;
}
.pane-tag-before { left: 10px; }
.pane-tag-after { right: 10px; background: rgba(240, 48, 24, .82); }
.slider-handle {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 1px;
  z-index: 7;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 0 0 1px rgba(26, 26, 26, .28), 0 0 24px rgba(255, 255, 255, .8);
}
.handle-grip {
  position: absolute;
  left: 50%; top: 50%;
  width: 40px; height: 40px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(26, 26, 26, .12);
  box-shadow: 0 12px 30px rgba(26, 26, 26, .16);
}
.handle-grip::before, .handle-grip::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.handle-grip::before { left: 9px; transform: translateY(-50%); border-right: 6px solid var(--ink); }
.handle-grip::after { right: 9px; transform: translateY(-50%); border-left: 6px solid var(--ink); }

.result-meta { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.result-titles { min-width: 0; }
.look-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(24px, 8vw, 34px);
  line-height: .98;
  letter-spacing: .01em;
  text-transform: uppercase;
}
.look-detail { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.result-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-actions button {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.primary { background: var(--accent); color: #fff; box-shadow: 0 12px 24px rgba(240, 48, 24, .22); }
.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.result-close {
  justify-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  min-height: 36px;
}
.saved-note { min-height: 18px; color: var(--accent); font-size: 12px; font-weight: 800; text-align: right; }

@media (min-width: 760px) {
  .shell { gap: 16px; padding-top: 18px; }
  .studio {
    grid-template-columns: minmax(420px, 1.35fr) minmax(260px, .65fr);
    gap: 16px;
  }
  .supporting-pane { order: 1; }
  .primary-pane { order: 2; }
  .portrait-stage { height: min(66svh, 720px); min-height: 520px; }
  .thumb-grid { max-height: none; grid-template-columns: repeat(5, 1fr); }
  .contact-sheet { position: sticky; top: calc(var(--eazo-safe-area-top) + 14px); }
  .compare { max-height: 60svh; }
}

@media (max-width: 430px) {
  .shell { padding-left: 10px; padding-right: 10px; gap: 9px; }
  .subtitle { display: none; }
  .portrait-stage { height: min(46svh, 420px); min-height: 300px; }
  .instruction { font-size: 12px; padding: 8px 10px; }
  .tray { gap: 8px; padding: 8px; border-radius: 20px; }
  .brushes { grid-template-columns: repeat(6, 62px); gap: 7px; }
  .brush { min-width: 62px; height: 52px; font-size: 10px; border-radius: 15px; }
  .brush::before { width: 23px; height: 14px; }
  .swatch { width: 40px; height: 40px; border-radius: 13px; }
  .thumb-grid { display: flex; overflow-x: auto; max-height: unset; }
  .thumb { width: 48px; min-width: 48px; }
  .contact-sheet { padding: 8px; border-radius: 18px; }
  .controls { grid-template-columns: 1fr 1fr; gap: 6px 9px; }
  .actions { gap: 6px; }
  .action, .toggle { font-size: 11px; }
  .meter { padding: 8px 10px; }
  .reveal-button { padding: 0 12px; font-size: 11px; }
  .compare { max-height: 46svh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
