: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));
  --bg: #F0F0F0;
  --blue: #6090C0;
  --blue-2: #78A8D8;
  --text: #1A1A1A;
  --muted: #6B7C93;
  --line: rgba(96, 144, 192, .22);
  --shadow: 0 20px 60px rgba(80, 118, 160, .18);
  --radius: 28px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); overflow-x: hidden; }
button { font: inherit; }

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

/* Soft pastel salon backdrop — decorative only, sits behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 255, 255, .95) 0 7px, transparent 8px),
    radial-gradient(circle at 76% 18%, rgba(255, 255, 255, .9) 0 5px, transparent 6px),
    radial-gradient(circle at 82% 72%, rgba(120, 168, 216, .22), transparent 28%),
    linear-gradient(180deg, #EAF2FF 0%, #F9FBFF 42%, #F0F0F0 100%);
  z-index: -3;
}

body::after {
  content: "";
  position: fixed;
  inset: auto -10% -8% -10%;
  height: 38%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 15% 75%, rgba(255, 255, 255, .92) 0 28%, transparent 29%),
    radial-gradient(ellipse at 46% 70%, rgba(255, 255, 255, .82) 0 33%, transparent 34%),
    radial-gradient(ellipse at 84% 82%, rgba(255, 255, 255, .86) 0 25%, transparent 26%);
  filter: blur(1px);
  z-index: -2;
}

/* The app shell owns the safe-area insets (no fixed chrome here) */
.app-container {
  width: 100%;
  min-height: 100svh;
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: var(--eazo-safe-area-bottom);
  display: flex;
  justify-content: center;
}

.shell {
  width: min(100%, 520px);
  min-width: 0;
  min-height: 0;
  padding: 10px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  flex: 0 0 auto;
}

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

.star-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: linear-gradient(145deg, #fff, #CFE6FF);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 10px 24px rgba(96, 144, 192, .18);
  position: relative;
}
.star-mark::before, .star-mark::after {
  content: ""; position: absolute; inset: 10px; background: var(--blue); opacity: .72;
  clip-path: polygon(50% 0, 61% 36%, 100% 50%, 61% 64%, 50% 100%, 39% 64%, 0 50%, 39% 36%);
}
.brand h1 {
  margin: 0; font-size: 18px; letter-spacing: .06em; font-weight: 800; color: #4E7FAA;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.lang-toggle {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 8px 24px rgba(96, 144, 192, .12);
  display: flex;
  overflow: hidden;
  flex: 0 0 auto;
  padding: 3px;
  position: relative;
}
.lang-btn {
  min-width: 48px; min-height: 36px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-weight: 800; font-size: 12px; cursor: pointer;
  transition: color .16s ease, background .16s ease;
}
.lang-btn.active { color: #fff; background: var(--blue); box-shadow: 0 5px 14px rgba(96, 144, 192, .34); }

.request-wrap {
  display: grid;
  gap: 8px;
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
}

.request-card {
  justify-self: center;
  width: min(100%, 390px);
  background: linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(255, 255, 255, .78));
  border: 1px solid rgba(168, 181, 198, .34);
  border-radius: 22px;
  padding: 11px 14px 10px;
  box-shadow: var(--shadow);
  transform: rotate(-1.2deg);
  position: relative;
}
.request-card::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 48px;
  height: 16px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: rgba(120, 168, 216, .24);
  border: 1px solid rgba(96, 144, 192, .18);
  backdrop-filter: blur(6px);
}
.request-label { margin: 0 0 3px; color: var(--blue); font-size: 11px; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
.request-main { margin: 0; font-weight: 850; font-size: clamp(17px, 4.8vw, 22px); line-height: 1.15; color: #24394E; }

.instruction {
  margin: 0 auto;
  max-width: 430px;
  color: #50657C;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.stage-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 11%, rgba(255, 255, 255, .78) 0 38px, transparent 39px),
    radial-gradient(circle at 17% 22%, rgba(255, 255, 255, .55) 0 54px, transparent 56px),
    linear-gradient(180deg, rgba(207, 230, 255, .75), rgba(255, 255, 255, .82) 48%, rgba(234, 242, 255, .56));
  border: 1px solid rgba(255, 255, 255, .86);
  box-shadow: 0 30px 80px rgba(96, 144, 192, .22), inset 0 1px 0 rgba(255, 255, 255, .8);
  touch-action: none;
  isolation: isolate;
  display: grid;
  grid-template-rows: 1fr;
}

.stage-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(96, 144, 192, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96, 144, 192, .05) 1px, transparent 1px);
  background-size: 42px 42px;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 28%, #000 76%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 28%, #000 76%, transparent);
  pointer-events: none;
  z-index: 1;
}

canvas#salonCanvas { width: 100%; height: 100%; display: block; max-width: 100%; position: relative; z-index: 2; }

.stage-status {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  display: flex;
  gap: 6px;
  align-items: center;
  background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(96, 144, 192, .18);
  border-radius: 999px;
  padding: 5px 10px;
  box-shadow: 0 8px 22px rgba(96, 144, 192, .13);
  color: #4E6E8C;
  font-weight: 800;
  font-size: 11px;
  pointer-events: none;
  max-width: calc(100% - 20px);
}

.tool-tray {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 26px;
  background: rgba(255, 255, 255, .8);
  border: 1px solid rgba(255, 255, 255, .88);
  box-shadow: var(--shadow);
  min-width: 0;
  flex: 0 0 auto;
}

.tool-group, .bottles, .actions { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bottles { overflow-x: auto; scrollbar-width: none; padding: 2px 2px; }
.bottles::-webkit-scrollbar { display: none; }

.tool-btn, .action-btn, .color-btn {
  min-height: 44px;
  min-width: 44px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.tool-btn, .action-btn {
  padding: 0 11px;
  background: #F6FAFF;
  color: #456782;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  box-shadow: inset 0 0 0 1px rgba(96, 144, 192, .16);
  white-space: nowrap;
}
.tool-btn.active { background: var(--blue); color: #fff; box-shadow: 0 10px 20px rgba(96, 144, 192, .28); }
.action-btn.primary { background: #1A1A1A; color: white; box-shadow: 0 12px 24px rgba(26, 26, 26, .18); }
.action-btn:disabled { opacity: .42; cursor: not-allowed; }
.color-btn {
  flex: 0 0 auto; border-radius: 50% 50% 16px 16px; border: 3px solid rgba(255, 255, 255, .86);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, .07), 0 6px 14px rgba(96, 144, 192, .16); position: relative;
}
.color-btn::before {
  content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  width: 18px; height: 10px; border-radius: 7px 7px 2px 2px; background: #E8F1FB; border: 1px solid rgba(96, 144, 192, .2);
}
.color-btn.active { outline: 3px solid var(--blue); outline-offset: 2px; transform: translateY(-2px); }

/* Result overlay owns its own safe-area insets */
.result-overlay {
  position: fixed;
  inset: 0;
  padding: calc(var(--eazo-safe-area-top) + 12px) 14px calc(var(--eazo-safe-area-bottom) + 12px);
  background: rgba(234, 242, 255, .72);
  backdrop-filter: blur(18px);
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.result-overlay.show { display: flex; }
.result-card {
  width: min(100%, 440px);
  max-height: 100%;
  overflow: auto;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(255, 255, 255, .86);
  border-radius: 30px;
  box-shadow: 0 30px 90px rgba(70, 105, 150, .28);
  padding: 14px;
  display: grid;
  gap: 12px;
}
.result-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.result-head h2 { margin: 0; color: #345F8B; font-size: 22px; line-height: 1.2; }
.result-head p { margin: 4px 0 0; color: #61758A; font-size: 13px; line-height: 1.35; }

.result-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.result-actions button { min-height: 48px; border: 0; border-radius: 16px; font-weight: 900; color: #fff; background: var(--blue); cursor: pointer; }
.result-actions button:nth-child(2) { background: var(--blue-2); }
.result-actions button:nth-child(3) { background: #1A1A1A; }

.mini-mirror {
  min-height: 150px;
  border-radius: 24px;
  background: linear-gradient(135deg, #DDEEFF, #FFFFFF 58%, #CFE6FF);
  border: 1px solid rgba(96, 144, 192, .16);
  position: relative;
  overflow: hidden;
}
.mini-mirror::before {
  content: ""; position: absolute; inset: 12px; border-radius: 999px 999px 50px 50px;
  border: 6px solid rgba(96, 144, 192, .23); box-shadow: inset 0 0 60px rgba(255, 255, 255, .9); pointer-events: none; z-index: 2;
}
.mini-mirror canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }

.result-request-row { display: grid; gap: 5px; }
.result-request-label { color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.result-request { background: #fff; border: 1px dashed rgba(96, 144, 192, .35); border-radius: 18px; padding: 10px 12px; font-weight: 800; color: #314C68; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.metric { background: #F6FAFF; border: 1px solid rgba(96, 144, 192, .14); border-radius: 20px; padding: 10px; min-width: 0; text-align: center; }
.metric b { display: block; font-size: 20px; color: #1F507E; }
.metric span { display: block; color: #718197; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.toast { min-height: 20px; color: #526A80; font-size: 12px; text-align: center; }

@media (min-width: 700px) {
  .shell { width: min(100%, 760px); padding-inline: 24px; }
  .instruction { font-size: 13px; }
}

@media (max-width: 380px) {
  .shell { padding-inline: 10px; gap: 8px; }
  .tool-btn, .action-btn { padding-inline: 9px; font-size: 10px; }
}

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