/* ヒヤッとシミュラクラ ── 暗い画面前提。写真の暗部を見せる用途なので背景は沈める */

:root {
  --bg: #0c0e13;
  --panel: #151922;
  --line: #232a36;
  --text: #eef1f6;
  --muted: #8b95a7;
  --tone: #ff5a5a;
  --radius: 14px;
  --font: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/*
 * hidden 属性を確実に効かせる。
 *
 * ブラウザ標準の [hidden]{display:none} は「作者が書いたCSS」に負ける。
 * .error{display:flex} を書いたせいで hidden が無視され、
 * 中身が空のエラー枠が公開版で出っぱなしになっていた。
 *
 * el.hidden はずっと true を返していたので、プロパティを見る検査では気づけない。
 * 個別に直すと同じ事故を繰り返すので、まとめて封じる。
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

body {
  /* 端がわずかに温かい暗さ。真っ黒より写真が沈んで見える */
  background:
    radial-gradient(1200px 600px at 50% -10%, #161a24 0%, var(--bg) 60%),
    var(--bg);
  min-height: 100dvh;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 20px calc(40px + env(safe-area-inset-bottom));
}

/* ---------- ヘッダ ---------- */

.head { text-align: center; margin-bottom: 26px; }

.head h1 {
  font-size: clamp(26px, 7vw, 34px);
  letter-spacing: .06em;
  margin: 0 0 8px;
  font-weight: 800;
}

.head h1::before {
  /* 3点そのものをロゴにする */
  content: "";
  display: block;
  width: 46px; height: 34px;
  margin: 0 auto 12px;
  background:
    radial-gradient(circle at 20% 30%, #9c968c 0 5px, transparent 6.5px),
    radial-gradient(circle at 80% 30%, #9c968c 0 5px, transparent 6.5px),
    radial-gradient(ellipse 7px 4px at 50% 85%, #9c968c 0 100%, transparent 100%);
  opacity: .85;
}

.head p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- 入口 ---------- */

.lead {
  text-align: center;
  line-height: 1.85;
  font-size: 15px;
  color: #c9d1de;
  margin: 0 0 22px;
}

.cta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 15px 18px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { border-color: #3a465a; background: #1a1f2a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }

.btn.primary {
  background: var(--tone);
  border-color: var(--tone);
  color: #0c0e13;
  font-weight: 800;
}
.btn.primary:hover { filter: brightness(1.08); background: var(--tone); }

.btn.ghost {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  padding: 11px 15px;
  font-size: 14px;
}
.btn.ghost:hover { color: var(--text); }

.privacy {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  margin: 16px 0 0;
}

.error {
  margin-top: 16px;
  padding: 13px 15px;
  border: 1px solid #57323c;
  background: #1e1418;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.link {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.samples {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.samples > span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 11px; }
.samples > div { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }

.about {
  margin-top: 26px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  overflow: hidden;
}
.about summary {
  padding: 15px 17px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14.5px;
  list-style: none;
}
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: " ＋"; color: var(--muted); float: right; }
.about[open] summary::after { content: " －"; }
.about p {
  margin: 0 17px 15px;
  font-size: 13.5px;
  line-height: 1.95;
  color: #b4bdcc;
}
.about .xref { padding-top: 12px; border-top: 1px solid var(--line); }
.about a { color: var(--tone); }

/* ---------- 処理中 ---------- */

#busy { text-align: center; padding: 70px 0; }
#busy p { color: var(--muted); font-size: 14px; margin-top: 26px; }

.scanner {
  position: relative;
  width: 100px; height: 84px;
  margin: 0 auto;
}
.scanner span {
  position: absolute;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--tone);
  animation: pulse 1.5s ease-in-out infinite;
}
.scanner span:nth-child(1) { left: 8px;  top: 8px; }
.scanner span:nth-child(2) { right: 8px; top: 8px; animation-delay: .18s; }
.scanner span:nth-child(3) { left: 50%; margin-left: -10px; bottom: 4px; width: 20px; height: 20px; animation-delay: .36s; }

@keyframes pulse {
  0%, 100% { opacity: .18; transform: scale(.82); }
  45%      { opacity: 1;   transform: scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  .scanner span { animation: none; opacity: .8; }
}

/* ---------- 編集 ---------- */

/* 写真とつまみを2枚重ねる。つまみを動かすたびに写真を作り直さずに済む */
.stage {
  position: relative;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  touch-action: none;
}
#photo { display: block; max-width: 100%; }
#overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
}
#overlay:active { cursor: grabbing; }

.hint {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

/* 置きどころの助言。出るのは問題があるときだけ */
.advice {
  margin: 12px 0 0;
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.75;
  text-align: center;
}
.advice.fair { background: #241f14; border: 1px solid #4b3f22; color: #d9c893; }
.advice.poor { background: #241619; border: 1px solid #55323c; color: #e2b3bb; }
.advice button {
  display: inline-block;
  margin-left: 8px;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.advice button:hover { background: rgba(255,255,255,.08); }

.peek {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.sliders {
  margin-top: 22px;
  display: grid;
  gap: 18px;
}

.slider { display: block; }
.slider > span {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.slider > span b {
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.slider small {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: #6b7688;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #2b3342;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--tone);
  border: 3px solid var(--bg);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--tone);
  border: 3px solid var(--bg);
  cursor: pointer;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 26px;
}
.actions .btn.primary { grid-column: 1 / -1; }

.tip {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--muted);
  text-align: center;
}

/* ---------- フッタ・トースト ---------- */

.foot {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.foot a { color: var(--muted); text-decoration: none; font-weight: 700; letter-spacing: .08em; }
.foot a:hover { color: var(--text); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #232a36;
  color: var(--text);
  padding: 13px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  max-width: min(92vw, 420px);
  text-align: center;
  line-height: 1.6;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .5);
  z-index: 50;
}

/* ---------- 狭い画面 ---------- */

@media (max-width: 380px) {
  .cta, .actions { grid-template-columns: 1fr; }
  .verdictbox { gap: 14px; padding: 16px; }
}
