:root {
  /* OHAKO の看板と店内から: しっくいの白、グレージュ、ロゴの小豆色、床の焦茶 */
  --bg: #f2eee8;
  --surface: #fcfaf7;
  --ink: #2f2622;
  --muted: #6f635a;
  --line: #ddd4c9;
  --accent: #6e4238;
  --danger: #a3382a;
  --on-ink: #fcfaf7;
  --radius: 4px;
  --radius-s: 3px;
  --tap: 48px;
  --gutter: 20px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  --font-mincho: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  --font-latin: "Avenir Next", "Helvetica Neue", var(--font);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

main {
  max-width: 560px;
  margin: 0 auto;
}

p,
ul,
ol,
h1,
h2 {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

/* ---- 画面の枠: 上の帯・中身・下の操作 ---- */

.view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.view.is-entering {
  animation: view-in 0.24s ease-out backwards;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) calc(8px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.bar > :first-child {
  justify-self: start;
}

.bar > :last-child {
  justify-self: end;
}

.bar-title {
  font-family: var(--font-mincho);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.shop {
  grid-column: 1 / 3;
  display: flex;
  flex-direction: column;
  padding-left: 12px;
  color: var(--accent);
  white-space: nowrap;
}

.shop-name {
  font-family: var(--font-mincho);
  font-size: 16px;
  font-weight: 300;
  line-height: 1.3;
  letter-spacing: 0.32em;
}

.shop-sub {
  font-family: var(--font-latin);
  font-size: 8.5px;
  line-height: 1.3;
  letter-spacing: 0.24em;
}

.bar-button {
  min-height: var(--tap);
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-s);
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.bar-button.strong {
  color: var(--accent);
  font-weight: 700;
}

.bar-select {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px calc(var(--gutter) + env(safe-area-inset-right)) 28px calc(var(--gutter) + env(safe-area-inset-left));
}

.content.flush {
  padding: 0 0 20px;
  gap: 0;
}

.inset {
  margin: 14px var(--gutter) 0;
}

.dock {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px calc(var(--gutter) + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

/* ---- ボタン ---- */

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-family: var(--font-mincho);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.12s;
}

.button:active,
.bar-button:active,
.tab:active,
.choice:active {
  opacity: 0.6;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-ink);
}

.button.large {
  min-height: 60px;
  font-size: 17px;
}

.button.danger,
.text-button.danger {
  color: var(--danger);
}

.button.is-disabled,
.button:disabled,
.bar-button:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.text-button {
  min-height: var(--tap);
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.icon-button {
  width: 32px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-s);
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

.icon-button:disabled {
  color: var(--line);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

label:focus-within:has(.visually-hidden:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 10px;
}

.footer-links {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

/* ---- 文字 ---- */

.note {
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

.warn {
  color: var(--danger);
}

.disclaimer {
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

.status-line {
  min-height: 0;
  font-size: 13px;
  color: var(--muted);
}

.status-line:empty {
  display: none;
}

.section-title {
  margin-top: 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
}

/* ---- 撮影 ---- */

.home {
  justify-content: center;
  gap: 0;
  padding-top: 28px;
}

.chart {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 12px;
  margin-bottom: 36px;
  color: var(--ink);
}

.chart li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--muted);
}

.chart:empty {
  display: none;
}

.glyph {
  display: block;
  width: 100%;
  height: auto;
  fill: currentColor;
}

.chart .glyph {
  color: var(--accent);
}

.home-title {
  font-family: var(--font-mincho);
  font-size: 28px;
  font-weight: 300;
  line-height: 1.4;
  letter-spacing: 0.14em;
}

.lead {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
}

.tips {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.tips li {
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.home .note {
  margin-top: 16px;
}

.status {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.status.is-error {
  color: var(--danger);
  font-weight: 400;
  text-align: left;
}

.progress {
  position: relative;
  display: block;
  height: 2px;
  overflow: hidden;
  background: var(--line);
}

.progress::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: var(--accent);
  animation: progress 1.1s ease-in-out infinite;
}

.status.is-error .progress {
  display: none;
}

@keyframes progress {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

/* ---- 結果 ---- */

.viewer {
  position: relative;
  width: min(100%, calc(60vh * 4 / 5));
  width: min(100%, calc(60dvh * 4 / 5));
  aspect-ratio: 4 / 5;
  margin: 0 auto;
  overflow: hidden;
  background: var(--line);
}

.slides {
  display: flex;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.slides::-webkit-scrollbar {
  display: none;
}

.slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.slide img,
.original {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.original {
  position: absolute;
  inset: 0;
}

.compare {
  position: absolute;
  right: 12px;
  bottom: 12px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-s);
  background: rgba(252, 250, 247, 0.84);
  color: var(--ink);
  font: inherit;
  font-family: var(--font-mincho);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.compare[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-ink);
}

.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border-bottom: 1px solid var(--line);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 10px 4px 9px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.tab .glyph {
  width: 56px;
  max-width: 100%;
}

.tab[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.caption {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 4px 12px;
  padding: 16px var(--gutter) 0;
}

.style-name {
  font-family: var(--font-mincho);
  font-size: 22px;
  font-weight: 300;
  line-height: 1.4;
  letter-spacing: 0.1em;
}

.reason {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.style-note {
  grid-column: 1 / -1;
  font-size: 14px;
  color: var(--muted);
}

/* ---- 下から出る選択肢 ---- */

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  max-height: 80dvh;
  margin: auto auto 0;
  padding: 20px var(--gutter) calc(16px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 8px 8px 0 0;
  background: var(--bg);
  color: var(--ink);
}

.sheet[open] {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: view-in 0.24s ease-out backwards;
}

.sheet::backdrop {
  background: rgba(47, 38, 34, 0.45);
}

.sheet-title {
  font-family: var(--font-mincho);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.choice-list {
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.choice-list li + li {
  border-top: 1px solid var(--line);
}

.choice-list .note {
  padding: 16px;
}

.choice {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 0 14px;
  width: 100%;
  min-height: 64px;
  padding: 8px 16px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.choice .glyph {
  grid-row: 1 / 3;
}

.choice-name {
  font-size: 15px;
  font-weight: 600;
}

.choice-name:only-of-type {
  grid-row: 1 / 3;
}

.choice-note {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* ---- 設定 ---- */

.style-list,
.group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.style-list > .note {
  padding: 16px;
}

.style-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 12px 0 4px;
}

.style-row + .style-row {
  border-top: 1px solid var(--line);
}

.row-main {
  flex: 1;
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 0 10px;
  min-width: 0;
  min-height: 64px;
  padding: 8px 2px 8px 8px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.row-main .glyph {
  grid-row: 1 / 3;
}

.row-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.row-faces {
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

.style-row.is-off .row-main {
  color: var(--muted);
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  margin: 0 0 0 6px;
  border-radius: 14px;
  background: var(--line);
  cursor: pointer;
  transition: background-color 0.15s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.15s;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(18px);
}

/* ---- 型の編集 ---- */

.preview {
  position: sticky;
  top: calc(52px + env(safe-area-inset-top));
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.preview canvas {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 0 auto;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.group {
  margin: 0;
  padding: 0 16px;
  min-width: 0;
}

.group > legend {
  float: left;
  width: 100%;
  padding: 14px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  font-size: 13px;
  color: var(--muted);
}

.group > * + *,
#editor-sliders > * + * {
  border-top: 1px solid var(--line);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  font-size: 15px;
}

input[type="text"] {
  width: 100%;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

input[type="text"]:focus {
  outline: none;
}

.field:focus-within {
  color: var(--accent);
}

select {
  min-height: 36px;
  padding: 0 28px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface) url("icons/chevron.svg") no-repeat right 9px center / 10px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
}

.checks {
  clear: both;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  padding: 8px 0 12px;
  border-top: 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  font-size: 15px;
}

input[type="checkbox"]:not(.switch) {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

.slider-head {
  display: flex;
  justify-content: space-between;
  color: var(--ink);
  font-size: 14px;
}

.slider .value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

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

.field-color {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  font-size: 15px;
  color: var(--ink);
}

input[type="color"] {
  width: 48px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: none;
}

@media (prefers-reduced-motion: reduce) {
  .view.is-entering,
  .sheet[open],
  .progress::after {
    animation: none;
  }

  .progress::after {
    width: 100%;
  }

  .slides {
    scroll-behavior: auto;
  }
}
