:root {
  --bg: #ffffff;
  --bg-soft: #f6f4f2;
  --ink: #222222;
  --ink-soft: #6b6560;
  --line: #e6e1dc;
  --accent: #222222;       /* secondary button outline */
  --accent-grad: linear-gradient(90deg, #f01ef0 0%, #5b4bff 52%, #00d8f5 100%); /* primary buttons + title */
  --accent-ink: #ffffff;
  --warn-bg: #fff6e5;
  --warn-ink: #7a5200;
  --radius: 14px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.7 var(--font);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.top {
  display: flex; justify-content: center; align-items: center;
  height: 56px; border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.brand-text { margin: 0; display: flex; flex-direction: column; align-items: center; line-height: 1.2; color: var(--ink); }
.brand-sub { font-size: 11px; letter-spacing: .12em; color: var(--ink-soft); }
.brand-name { font-size: 20px; font-weight: 600; letter-spacing: .14em; }
.foot-logo { display: block; height: 22px; width: auto; margin: 32px auto 0; }

main {
  max-width: 520px; margin: 0 auto;
  /* extra room at the bottom so the last button can scroll above the browser's floating toolbar */
  padding: 20px 16px calc(88px + env(safe-area-inset-bottom));
}

h1 { font-size: 24px; letter-spacing: .04em; text-align: center; margin: 12px 0 4px; }
#start h1 {
  width: fit-content; margin-inline: auto; /* gradient spans the text only, so both ends show */
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
h2 { font-size: 15px; margin: 0 0 8px; }
.lead { text-align: center; color: var(--ink-soft); margin: 0 0 24px; }
.lead b { color: var(--ink); }

/* buttons */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 52px; margin: 12px 0;
  border-radius: 999px; border: 1px solid var(--accent);
  font: 600 16px/1.3 var(--font); text-decoration: none; cursor: pointer;
  padding: 12px 20px; text-align: center;
}
.btn.primary { background: var(--accent-grad) border-box; color: var(--accent-ink); border-color: transparent; }
.btn.secondary { background: var(--bg); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); font-weight: 500; }
.btn:active { transform: scale(.98); }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.btn.file:focus-within { outline: 3px solid #9ec5ff; outline-offset: 2px; }

.card {
  background: var(--bg-soft); border-radius: var(--radius);
  padding: 16px 18px; margin: 20px 0;
}
.tips ul { margin: 0; padding-left: 1.2em; }
.tips li { margin: 2px 0; }

.privacy {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 13px; color: var(--ink-soft); margin: 16px 4px;
}
.lock {
  flex: none; width: 14px; height: 12px; margin-top: 6px; border-radius: 2px;
  background: var(--ink-soft); position: relative;
}
.lock::before {
  content: ""; position: absolute; left: 3px; top: -6px; width: 8px; height: 8px;
  border: 2px solid var(--ink-soft); border-bottom: 0; border-radius: 5px 5px 0 0; box-sizing: border-box;
}

.notice {
  background: var(--warn-bg); color: var(--warn-ink);
  border-radius: 10px; padding: 10px 14px; font-size: 13px; margin: 0 0 16px;
}

/* processing */
#busy { text-align: center; padding: 80px 0; color: var(--ink-soft); }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--ink);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

#error { text-align: center; padding-top: 40px; }
.err-title { font-size: 18px; }
#errorText { white-space: pre-line; color: var(--ink-soft); }

/* result viewer */
.swipe-hint { text-align: center; font-size: 13px; color: var(--ink-soft); margin: 0 0 8px; }
.viewer { position: relative; margin: 0 -16px; }
.track {
  display: flex; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none;
  outline: none;
}
.track::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%; margin: 0; scroll-snap-align: center; scroll-snap-stop: always;
  position: relative; background: var(--bg-soft);
}
.slide img {
  display: block; width: 100%; height: auto; object-fit: contain;
  /* keep the tabs under the photo above the browser's bottom toolbar on first view */
  max-height: 72vh; max-height: min(72vh, calc(100svh - 270px));
  -webkit-touch-callout: default; user-select: none;
}
.slide figcaption {
  position: absolute; top: 12px; left: 12px;
  background: rgba(255,255,255,.92); color: var(--ink);
  font-weight: 700; font-size: 14px; padding: 4px 12px; border-radius: 999px;
}
.edge {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.85); color: var(--ink);
  font-size: 26px; line-height: 1; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.edge span { display: block; margin-top: -3px; }
.edge.left { left: 10px; }
.edge.right { right: 10px; }

.seg {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--bg-soft); border-radius: 999px; padding: 4px; margin: 14px 0 4px;
}
.seg button {
  border: 0; background: transparent; border-radius: 999px;
  font: 600 14px/1 var(--font); color: var(--ink-soft); padding: 10px 0; cursor: pointer;
}
.seg button[aria-selected="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* comparison */
.layout { display: flex; gap: 8px; margin-bottom: 12px; }
.layout button {
  flex: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 999px;
  font: 500 14px/1 var(--font); padding: 9px 0; color: var(--ink-soft); cursor: pointer;
}
.layout button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); font-weight: 700; }
#compareImg { display: block; width: 100%; height: auto; border-radius: 8px; background: var(--bg); -webkit-touch-callout: default; }
.compare .btn { margin-bottom: 0; }

.disclaimer { font-size: 12px; color: var(--ink-soft); text-align: center; margin: 8px 0 4px; }

/* long-press sheet */
.sheet {
  position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-body {
  background: var(--bg); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(12px + env(safe-area-inset-bottom));
  text-align: center;
}
.sheet-body img { display: block; max-width: 100%; max-height: 62vh; margin: 8px auto; -webkit-touch-callout: default; }
