:root {
  --ink: #202b42;
  --muted: #697184;
  --paper: #fffaf4;
  --sakura-deep: #9d3454;
  --line: rgba(32, 43, 66, 0.14);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  background: #eee9e2;
}

button, input { font: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.lite-app {
  width: min(1320px, calc(100% - 28px));
  height: 100svh;
  margin: 0 auto;
  padding: 12px 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.lite-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  min-height: 104px;
  padding: 18px 24px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 244, 0.94);
}

.lite-header p,
.lite-header h1,
.lite-header span { margin: 0; }

.lite-header p {
  color: var(--sakura-deep);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.lite-header h1 {
  margin-top: 4px;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(1.65rem, 4vw, 2.45rem);
  font-weight: 500;
}

.lite-header span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
}

.lite-header > a {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  background: #fff;
}

.lite-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: 0;
  margin-top: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.model-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #d7d7d7;
}

.viewer { position: absolute; inset: 0; }
.viewer canvas { display: block; width: 100%; height: 100%; }

.model-stage-note,
.model-loading {
  position: absolute;
  z-index: 2;
  padding: 9px 12px;
  color: #fff;
  font-size: 0.72rem;
  background: rgba(25, 31, 43, 0.72);
  backdrop-filter: blur(8px);
}

.model-stage-note {
  left: 16px;
  bottom: 16px;
  display: grid;
  gap: 2px;
}

.model-loading {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.lite-controls {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--paper);
}

.editor-tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.editor-tab {
  min-height: 52px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
  background: #fff;
}

.editor-tab:last-child { border-right: 0; }

.editor-tab.is-active {
  color: #fff;
  background: var(--sakura-deep);
}

.editor-panel {
  flex: 1 1 auto;
  min-height: 0;
  padding: 22px 24px 28px;
  overflow: auto;
  overscroll-behavior: contain;
}

.editor-panel[hidden] { display: none; }

.step-label {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 0 0 12px;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 1rem;
  font-weight: 700;
}

.step-label:not(:first-child) { margin-top: 28px; }

.step-label > span {
  display: grid;
  place-items: center;
  width: 28px;
  aspect-ratio: 1;
  border-radius: 50%;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.66rem;
  background: var(--sakura-deep);
}

.photo-button {
  display: grid;
  place-items: center;
  min-height: 66px;
  padding: 12px;
  color: #fff;
  cursor: pointer;
  background: var(--sakura-deep);
  transition: filter 0.18s ease, transform 0.18s ease;
}

.photo-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.photo-button small { margin-top: 2px; opacity: 0.76; }

.texture-preview {
  position: relative;
  width: min(100%, 230px);
  aspect-ratio: 1;
  margin: 18px auto 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #eee;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.texture-preview.is-dragging { cursor: grabbing; }

.texture-preview canvas { display: block; width: 100%; height: 100%; }

.texture-preview::before,
.texture-preview::after {
  content: "";
  position: absolute;
  z-index: 1;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 0 0 1px rgba(32, 43, 66, 0.18);
}

.texture-preview::before {
  top: 50%;
  left: calc(50% - 11px);
  width: 22px;
  height: 1px;
}

.texture-preview::after {
  top: calc(50% - 11px);
  left: 50%;
  width: 1px;
  height: 22px;
}

.status-text {
  min-height: 2.8em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.55;
  text-align: center;
}

.position-control {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.position-control > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.position-control strong { color: var(--ink); }
.position-control input { width: 100%; accent-color: var(--sakura-deep); }

.repeat-control {
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.repeat-control legend {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.repeat-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.repeat-options label { position: relative; cursor: pointer; }

.repeat-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.repeat-options span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  background: #fff;
}

.repeat-options input:checked + span {
  border-color: var(--sakura-deep);
  color: var(--sakura-deep);
  box-shadow: inset 0 0 0 1px var(--sakura-deep);
  background: #fff4f6;
}

.mirror-option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  cursor: pointer;
  background: #fff;
}

.mirror-option > input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--sakura-deep);
}

.mirror-option span,
.mirror-option strong,
.mirror-option small { display: block; }

.mirror-option strong { color: var(--ink); font-size: 0.76rem; }
.mirror-option small { margin-top: 2px; color: var(--muted); font-size: 0.68rem; }

.reset-button {
  width: 100%;
  min-height: 42px;
  margin-top: 18px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  background: #fff;
}

.lite-help {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.7;
}

.lite-help strong { color: var(--ink); }

.accessory-note {
  margin: -4px 0 13px;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.6;
}

.accessory-controls { display: grid; gap: 10px; }

.accessory-row {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 8px 10px 11px;
  border: 1px solid var(--line);
  background: #fff;
}

.accessory-row legend {
  padding: 0 5px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.accessory-modes { display: flex; gap: 6px; }

.accessory-modes label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.69rem;
  font-weight: 700;
  background: #fff;
}

.accessory-modes label:has(input:checked) {
  border-color: var(--ink);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.accessory-modes input,
.color-gauge input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.color-gauge {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  height: 30px;
  padding: 3px;
  border: 1px solid #20232a;
  background: #3b3d43;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
}

.color-gauge label {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.color-gauge i {
  position: absolute;
  inset: 0;
  display: block;
  background: var(--color);
}

.color-gauge label:has(input:checked) {
  z-index: 1;
}

.color-gauge label:has(input:checked) i {
  inset: -3px -2px;
  border: 2px solid #20232a;
  box-shadow: inset 0 0 0 2px #fff, 0 0 0 1px #fff;
}

.save-section {
  min-height: 100%;
}

.save-section > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.7;
}

.save-button {
  width: 100%;
  min-height: 54px;
  margin-top: 16px;
  border: 0;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  background: var(--sakura-deep);
  box-shadow: 0 10px 22px rgba(157, 52, 84, 0.22);
}

.save-button:hover { filter: brightness(1.08); }
.save-button:disabled { cursor: wait; opacity: 0.62; }

.save-status {
  min-height: 1.6em;
  margin-top: 10px !important;
  color: var(--sakura-deep) !important;
  font-weight: 700;
  text-align: center;
}

.qr-result {
  display: grid;
  justify-items: center;
  gap: 9px;
  margin-top: 14px;
  padding: 16px 12px;
  border: 1px solid var(--line);
  background: #fff;
  text-align: center;
}

.qr-result[hidden] { display: none; }
.qr-result img { display: block; width: min(100%, 280px); height: auto; image-rendering: pixelated; }
.qr-result strong { font-size: 0.84rem; }
.qr-result span { color: var(--muted); font-size: 0.72rem; line-height: 1.55; }
.qr-result a {
  padding: 9px 12px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
}

.experience-paths {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.experience-paths[hidden] { display: none; }

.experience-paths-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.experience-paths-heading > span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  background: var(--sakura-deep);
  font-size: 0.68rem;
  font-weight: 800;
}

.experience-paths-heading div { display: grid; gap: 2px; }
.experience-paths-heading strong { font-size: 0.96rem; }
.experience-paths-heading small { color: var(--muted); font-size: 0.68rem; }

.experience-path-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.experience-path-grid a {
  display: grid;
  gap: 4px;
  min-height: 78px;
  padding: 13px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.experience-path-grid a:hover {
  border-color: var(--sakura-deep);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(90, 45, 58, 0.1);
}

.experience-path-grid b { color: var(--sakura-deep); font-size: 0.82rem; }
.experience-path-grid span { color: var(--muted); font-size: 0.68rem; line-height: 1.45; }

@media (max-width: 820px) {
  .lite-app { width: min(100%, 680px); height: 100svh; padding: 0; }
  .lite-header { align-items: flex-start; padding: 16px; }
  .lite-header span { max-width: 250px; }
  .lite-workspace { grid-template-columns: 1fr; grid-template-rows: minmax(220px, 42svh) minmax(0, 1fr); margin-top: 0; border-inline: 0; }
  .model-stage { min-height: 0; }
  .lite-controls { border-top: 1px solid var(--line); border-left: 0; }
  .editor-panel { padding: 20px max(18px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
  .texture-preview { width: min(100%, 280px); }
  .position-control input { min-height: 28px; }
  .photo-button, .reset-button, .save-button { min-height: 52px; }
}

.editor-tabs { grid-template-columns:repeat(4,minmax(0,1fr)); }
#stampPanel label { display:flex;align-items:center;justify-content:space-between;gap:8px;margin:9px 0;font-size:12px; }
#stampPanel p { font-size:11px;line-height:1.6;color:#68616a; }
#stampCanvas { display:block;width:100%;height:auto;aspect-ratio:2 / 3;touch-action:none;border:1px solid #cbbec3;border-radius:8px;cursor:crosshair; }
.stamp-colors,.stamp-palette,.stamp-actions { display:flex;gap:6px;margin:10px 0;flex-wrap:wrap; }
.stamp-colors button { width:30px;height:30px;border:1px solid #aaa;border-radius:50%; }
.stamp-palette { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:0;border-top:1px solid #d4c9cd;border-left:1px solid #d4c9cd; }
.stamp-palette button { min-width:0;aspect-ratio:1;padding:7px;border:0;border-right:1px solid #d4c9cd;border-bottom:1px solid #d4c9cd;background:transparent;border-radius:0;cursor:pointer;overflow:hidden; }
.stamp-palette button[hidden] { display:none; }
.stamp-palette button[aria-pressed=true] { background:transparent;box-shadow:inset 0 0 0 2px #963453; }
.stamp-palette button:focus-visible { outline:2px solid #29394d;outline-offset:-4px; }
.stamp-palette canvas { display:block;width:100%;height:auto;pointer-events:none; }
.stamp-current { min-height:24px;font-size:13px;font-weight:700;color:#963453;margin:0 0 8px; }
.stamp-edit-tools { padding:4px 0 12px;border-bottom:1px solid #d4c9cd; }
.stamp-edit-tools .stamp-actions { display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px; }
.stamp-edit-tools .stamp-actions button { min-height:38px;padding:5px 2px;background:transparent;border-radius:3px; }
.stamp-edit-tools .stamp-actions button:disabled { opacity:.35;cursor:default; }
.stamp-edit-tools .stamp-actions button[aria-pressed=true] { border-color:#963453;color:#963453;background:#fff1f5; }
.stamp-placement { padding:12px 0;border-bottom:1px solid #d4c9cd; }
.stamp-placement summary { font-size:12px;cursor:pointer; }
.stamp-actions button { padding:8px;border:1px solid #cbbec3;background:#fff8f0;border-radius:5px;font-size:11px; }
.design-options { position:relative; display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:3px; padding-bottom:26px; }
.design-option { position:relative; display:flex; flex-direction:column; min-width:0; padding:4px; border:2px solid transparent; border-radius:6px; background:#f5f0e9; cursor:pointer; }
.design-option:has(input:checked) { border-color:#963453; background:#fff5f7; }
.design-option:focus-within { outline:2px solid #253a50; outline-offset:2px; }
.design-option input { position:absolute; top:7px; left:7px; margin:0; accent-color:#963453; }
.design-option canvas,.design-original { display:block; width:100%; height:48px; border-radius:3px; object-fit:cover; }
.design-original { display:grid; place-items:center; background:#e9e1d6; color:#75695c; font-size:11px; }
.design-option { position:static; padding:2px; }
.design-option input { width:1px; height:1px; opacity:0; clip-path:inset(50%); pointer-events:none; }
.design-option canvas,.design-original { height:44px; }
.design-option span { display:none; }
.design-option:has(input:checked) span { display:block; position:absolute; bottom:0; left:0; right:0; font-size:12px; line-height:22px; color:var(--sakura-deep); font-weight:700; }
.design-option:has(input:disabled) { opacity:.4; cursor:not-allowed; }

@media (max-width: 520px) {
  .lite-header { flex-direction: column; gap: 12px; }
  .lite-header > a { align-self: flex-start; }
  .lite-header { min-height: 0; }
  .lite-header span { display: none; }
  .lite-header > a { padding: 7px 10px; }
  .lite-workspace { grid-template-rows: minmax(210px, 38svh) minmax(0, 1fr); }
  .editor-tab { min-height: 46px; }
  .editor-panel { padding-top: 18px; }
  .color-gauge { height: 38px; }
  .accessory-modes label { min-height: 38px; }
  .qr-result { margin-inline: -4px; }
  .experience-path-grid { grid-template-columns: 1fr; }
}
