:root {
  --ink: #26302b;
  --ink-soft: #6b756f;
  --paper: #f4f0e8;
  --card: #fffdf9;
  --line: #ded7ca;
  --accent: #2f4a3a;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --sans: "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--sans); }
button { font: inherit; color: inherit; }

#app { display: flex; flex-direction: column; height: 100dvh; }
#stage {
  position: relative; flex: 1 1 auto; min-height: 0;
  background: radial-gradient(120% 90% at 50% 62%, #fbf9f4 0%, #efe9dd 55%, #e2dacb 100%);
}
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
header { position: absolute; top: calc(14px + env(safe-area-inset-top)); left: 18px; pointer-events: none; }
header h1 { margin: 0; font: 500 22px/1.2 var(--serif); letter-spacing: .12em; }
header p { margin: 4px 0 0; font-size: 11px; color: var(--ink-soft); letter-spacing: .06em; }
#size-note { position: absolute; right: 14px; bottom: 10px; margin: 0; font-size: 11px; color: var(--ink-soft); pointer-events: none; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; color: var(--ink-soft); letter-spacing: .1em; background: inherit; transition: opacity .5s; }
#loading.done { opacity: 0; pointer-events: none; }

#panel {
  flex: 0 0 auto; background: var(--card); border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: grid; gap: 10px; max-height: 58dvh; overflow-y: auto;
}
section h2 { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .14em; color: var(--ink-soft); }
.picked { font-weight: 400; letter-spacing: .04em; margin-left: 6px; color: var(--ink); }

.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 6px 4px;
  border: 1px solid var(--line); border-radius: 10px; background: transparent; cursor: pointer;
  font-size: 13px; line-height: 1.25; text-align: center;
}
.chip small { display: block; font-size: 10px; color: var(--ink-soft); }
.chip svg { flex: none; width: 18px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.4; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: #fff; }
.chip[aria-pressed="true"] small { color: #cfdad3; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 1px solid rgba(0,0,0,.14); background: var(--c);
  box-shadow: inset 0 -5px 8px rgba(0,0,0,.07);
}
.swatch[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 3px; }

#cta { display: grid; gap: 6px; margin-top: 2px; }
.ar-wrap { position: relative; }
#ar-btn {
  width: 100%; min-height: 50px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; letter-spacing: .08em;
}
#ar-btn:disabled { background: #b9c0bb; cursor: default; }
#ql { position: absolute; inset: 0; display: block; border-radius: 12px; }
#ql[hidden] { display: none; }
#ql img { width: 100%; height: 100%; display: block; opacity: 0; }
#privacy-note { margin: 0; padding: 7px 10px; border-radius: 8px; background: #eef1ec; font-size: 11px; line-height: 1.5; color: var(--ink); text-align: center; }
#privacy-note[hidden] { display: none; }
#ar-note { margin: 0; font-size: 11px; line-height: 1.5; color: var(--ink-soft); text-align: center; min-height: 1em; }

/* wide screens: panel on the right */
@media (min-width: 820px) and (min-aspect-ratio: 1/1) {
  #app { flex-direction: row; }
  #panel { width: 360px; max-height: none; border-top: 0; border-left: 1px solid var(--line); align-content: center; padding: 28px 24px; gap: 18px; }
  header { top: 28px; left: 32px; }
  header h1 { font-size: 30px; }
}

/* ---------- AR overlay (Android) ---------- */
#ar-ui { position: fixed; inset: 0; z-index: 10; background: transparent; pointer-events: none; touch-action: none; }
#ar-ui[hidden] { display: none; }
#ar-ui > * { pointer-events: auto; }
#ar-top { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; align-items: center; gap: 10px; }
#ar-hint { flex: 1; padding: 9px 12px; border-radius: 10px; background: rgba(20,24,22,.62); color: #fff; font-size: 12px; line-height: 1.4; }
#ar-top button, #ar-bottom button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: rgba(255,253,249,.94); font-size: 13px; font-weight: 600; cursor: pointer; }
#ar-bottom { position: absolute; left: 12px; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 10px; }
#ar-ui.editing #ar-bottom { bottom: auto; top: calc(64px + env(safe-area-inset-top)); justify-content: flex-end; }
#ar-slot { position: absolute; left: 0; right: 0; bottom: 0; }
#ar-slot #panel { display: none; max-height: 46dvh; border-radius: 16px 16px 0 0; background: rgba(255,253,249,.95); }
#ar-ui.editing #ar-slot #panel { display: grid; }
#ar-slot #cta { display: none; }
#ar-ui.clean > * { visibility: hidden; }            /* UI hidden for a moment so a screenshot stays clean */
#ar-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none !important; transition: opacity .35s; }
#ar-flash.on { opacity: .85; transition: none; }
