/* 式神 — 墨の空間に浮かぶ紙の式神。色は墨・紙・朱の3色。枠や影の箱は使わず、細い線と文字で組む。 */
@font-face {
  font-family: "Shikigami Brush";
  src: url("/fonts/brush-sub.woff2") format("woff2");
  font-display: swap;
}

:root {
  --ink: #07080a;
  --paper: #ecebe6;
  --paper-2: #c9c8c2;
  --muted: #9b9ea6;
  --line: rgba(236, 235, 230, 0.16);
  --line-2: rgba(236, 235, 230, 0.32);
  --accent: #ff5a2e;
  --accent-text: #ff8a66;
  --pad: clamp(18px, 2.6vw, 44px);
  --side: clamp(260px, 21vw, 320px);
  --gothic: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--paper); }
body { font-family: var(--gothic); font-size: 15px; line-height: 1.75; -webkit-font-smoothing: antialiased; overflow: hidden; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
button, input { font: inherit; color: inherit; }

/* 3Dの舞台（画面全体の背面） */
/* スマホのアドレスバーの出入りで大きさが変わらないよう、最大の高さで固定する */
.stage { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100lvh; display: block; }
.stage-fallback { display: none; }
.no-gl .stage { display: none; }
.no-gl .stage-fallback {
  display: grid; place-items: center; position: fixed; inset: 0;
  font-family: "Shikigami Brush", serif; font-size: min(40vw, 360px); color: rgba(236, 235, 230, 0.06);
}

/* 重ねる文字の層 */
.hud {
  position: fixed; inset: 0; pointer-events: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "talk side" "desk side";
  column-gap: clamp(24px, 4vw, 72px);
  padding: calc(var(--pad) + env(safe-area-inset-top)) calc(var(--pad) + env(safe-area-inset-right)) calc(var(--pad) * 0.8 + env(safe-area-inset-bottom)) calc(var(--pad) + env(safe-area-inset-left));
}
.hud > * { pointer-events: auto; }

/* 上 */
.top { grid-area: top; display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.brand { display: flex; align-items: baseline; gap: 18px; }
.brand__name { margin: 0; font-family: "Shikigami Brush", var(--gothic); font-weight: 400; font-size: clamp(44px, 4.2vw, 68px); line-height: 1; letter-spacing: 0.04em; }
.brand__tag { margin: 0; font-size: 13px; color: var(--paper-2); letter-spacing: 0.06em; }
.brand__demo { margin-left: 12px; padding: 1px 9px; border: 1px solid var(--accent); color: var(--accent-text); border-radius: 999px; font-size: 11px; letter-spacing: 0.1em; }
.meta { text-align: right; display: grid; gap: 2px; }
.meta p { margin: 0; }
.meta__clock { font-family: var(--mono); font-size: 13px; color: var(--paper-2); letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.meta__state { font-size: 13px; letter-spacing: 0.08em; }
.meta__dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--paper-2); margin-right: 8px; vertical-align: 1px; }
[data-state="listen"] .meta__dot, [data-state="think"] .meta__dot, [data-state="confirm"] .meta__dot { background: var(--accent); animation: blink 1s ease-in-out infinite; }
[data-state="speak"] .meta__dot { background: var(--paper); }
.meta__spec { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }
@keyframes blink { 50% { opacity: 0.25; } }

/* 受け答え（字幕の位置） */
/* 確認などで中身が増えても上の題字に重ならないよう、欄の中でスクロールさせる */
.talk { grid-area: talk; align-self: end; max-width: 34em; max-height: 100%; overflow-y: auto; padding: 12px 6px 18px 0; scrollbar-width: none; }
.talk__ask { margin: 0 0 10px; font-size: 13px; color: var(--muted); min-height: 1.6em; letter-spacing: 0.04em; }
.talk__ask:not(:empty)::before { content: "あなた"; font-family: var(--mono); font-size: 11px; color: var(--accent-text); margin-right: 12px; letter-spacing: 0.14em; }
.talk__head {
  margin: 0; font-weight: 300; font-size: clamp(26px, 2.5vw, 40px); line-height: 1.45; letter-spacing: 0.02em;
  text-wrap: balance; word-break: auto-phrase;
  text-shadow: 0 0 24px rgba(7, 8, 10, 0.9);
}
.talk__body { margin-top: 14px; font-size: 15.5px; line-height: 1.95; color: var(--paper-2); text-shadow: 0 0 18px rgba(7, 8, 10, 0.95); }
.talk__body p { margin: 0 0 0.6em; }
.talk__activity { margin: 10px 0 0; font-family: var(--mono); font-size: 12px; color: var(--muted); min-height: 1.6em; letter-spacing: 0.06em; }
.talk__activity .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: 1px; animation: blink 0.9s ease-in-out infinite; }

/* 確認 */
.confirm { margin-bottom: 26px; padding-left: 18px; border-left: 2px solid var(--accent); max-width: 34em; }
.confirm__kicker { margin: 0; font-family: var(--mono); font-size: 11px; color: var(--accent-text); letter-spacing: 0.16em; }
.confirm__label { margin: 4px 0 0; font-size: 22px; font-weight: 600; }
.confirm__summary { margin: 8px 0 0; white-space: pre-wrap; font-size: 14px; line-height: 1.85; color: var(--paper-2); max-height: 34vh; overflow: auto; }
.confirm__hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.confirm__actions { margin-top: 14px; display: flex; gap: 10px; }

/* 右の欄 */
.side { grid-area: side; overflow-y: auto; padding: 10px 2px 10px 0; display: grid; gap: 26px; align-content: start; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.panel { border-top: 1px solid var(--line); padding-top: 12px; }
.panel__head { margin: 0 0 10px; font-size: 12px; font-weight: 500; color: var(--paper-2); letter-spacing: 0.14em; display: flex; align-items: center; gap: 10px; }
.panel__more { margin-left: auto; font-size: 11.5px; letter-spacing: 0.04em; color: var(--accent-text); text-underline-offset: 3px; }
.panel__head::before { content: ""; width: 10px; height: 1px; background: var(--accent); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; line-height: 1.55; }
.list time { display: inline-block; min-width: 3.4em; font-family: var(--mono); font-size: 12.5px; color: var(--accent-text); letter-spacing: 0.04em; }
.list .sub { display: block; font-size: 12px; color: var(--muted); margin-left: 3.9em; }
#snsList li > span:first-child { display: inline-block; min-width: 6.2em; font-size: 12.5px; color: var(--accent-text); letter-spacing: 0.04em; }
#snsList .sub { margin-left: 6.6em; }
#snsList .warn { color: var(--accent-text); }
#snsList .warn .sub { margin-left: 0; }
.list--log { font-family: var(--mono); font-size: 12px; color: var(--paper-2); gap: 5px; }
.list--log .ok::after { content: " 完了"; color: var(--muted); }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.history li { display: grid; gap: 2px; }
.history .q { font-size: 12px; color: var(--muted); }
.history .a { font-size: 13.5px; }
.history .more { font-size: 12.5px; color: var(--paper-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 下（依頼と操作） */
.desk { grid-area: desk; display: grid; gap: 12px; }
.desk__note { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.7; max-width: 60em; }
.tries__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 22px; counter-reset: t; }
.tries__list li { counter-increment: t; }
.tries__list button {
  border: 0; background: none; padding: 4px 0; cursor: pointer; font-size: 14px; color: var(--paper);
  border-bottom: 1px solid var(--line-2); transition: border-color 0.2s, color 0.2s;
}
.tries__list button::before { content: counter(t, decimal-leading-zero); font-family: var(--mono); font-size: 10.5px; color: var(--accent-text); margin-right: 8px; letter-spacing: 0.06em; }
.tries__list button:hover { border-bottom-color: var(--accent); }
.tries__list button[aria-current="true"] { border-bottom-color: var(--accent); color: #fff; }
.desk__row { display: flex; align-items: center; gap: 18px; }
.ask { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; max-width: 40em; }
.ask__input { flex: 1; min-width: 0; background: transparent; border: 0; border-bottom: 1px solid var(--line-2); padding: 10px 2px; font-size: 16px; outline: none; color: var(--paper); }
.ask__input::placeholder { color: var(--muted); opacity: 1; }
.ask__input:focus { border-bottom-color: var(--paper); }

.btn { border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: 7px 18px; font-size: 13px; cursor: pointer; white-space: nowrap; transition: border-color 0.2s, background 0.2s; }
.btn:hover { border-color: var(--paper); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #140603; font-weight: 600; }
.btn--accent:hover { background: #ff7347; }
.btn--quiet { border-color: transparent; color: var(--paper-2); }
.btn:focus-visible, .mic:focus-visible, .tries__list button:focus-visible, .ask__input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* 話すボタン: 輪と朱の芯 */
.mic {
  position: relative; display: inline-grid; place-items: center; width: 74px; height: 74px; flex: none;
  border-radius: 50%; border: 1px solid var(--line-2); background: rgba(7, 8, 10, 0.6); cursor: pointer;
}
.mic::before { content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 1px dashed rgba(236, 235, 230, 0.22); animation: spin 18s linear infinite; }
.mic__core { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 18px rgba(255, 90, 46, 0.7); transition: transform 0.2s; }
.mic__label { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); font-size: 11px; letter-spacing: 0.12em; color: var(--paper-2); white-space: nowrap; }
.mic[aria-pressed="true"] { border-color: var(--accent); }
.mic[aria-pressed="true"] .mic__core { transform: scale(1.5); animation: breathe 1.1s ease-in-out infinite; }
.mic:disabled { opacity: 0.45; cursor: not-allowed; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.1); } }
.desk { padding-bottom: 18px; }

@media (prefers-reduced-motion: reduce) {
  .mic::before, .meta__dot, .talk__activity .dot, .mic__core { animation: none !important; }
}

/* 縦長の画面（スマホ）: 上に式神、下に受け答えと操作。右の欄は下へ */
@media (max-width: 900px), (max-aspect-ratio: 1/1) {
  body { overflow: auto; }
  .hud {
    position: relative; inset: auto; min-height: 100dvh;
    display: flex; flex-direction: column; gap: 18px;
    padding: calc(18px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) 24px calc(18px + env(safe-area-inset-left));
  }
  .top { flex-direction: column; gap: 6px; }
  .brand { flex-wrap: wrap; gap: 4px 12px; }
  .meta { text-align: left; }
  .meta__spec { display: none; }
  .talk { max-width: none; }
  .talk__head { font-size: 25px; }
  .desk { position: sticky; bottom: 0; background: linear-gradient(to top, var(--ink) 80%, rgba(7, 8, 10, 0)); padding: 18px 18px calc(8px + env(safe-area-inset-bottom)) 18px; margin: 0 -18px; }
  .confirm { scroll-margin-bottom: 190px; }
  .desk__note { display: none; }
  .tries { overflow-x: auto; scrollbar-width: none; }
  .tries__list { flex-wrap: nowrap; }
  .tries__list li { flex: none; }
  .side { overflow: visible; padding: 0; }
  .desk__row { gap: 8px; }
  .ask { gap: 6px; }
  .ask__input { font-size: 16px; }
  .desk__row .btn { padding: 6px 11px; font-size: 12.5px; }
  .ask .btn { display: none; } /* スマホはキーボードの「送信」で送る */
  .mic { width: 52px; height: 52px; }
  .mic::before { inset: -5px; }
  .talk { max-height: none; overflow: visible; margin-top: 40vh; }
  .mic__label { display: none; }
  .note-sp { display: block; }
}
.note-sp { display: none; margin: 0; font-size: 11px; color: var(--muted); line-height: 1.7; }

/* ---------- 本体だけの部品 ---------- */
.meta__spec strong { color: var(--paper); font-weight: 600; }
.meta__spec .on { color: var(--paper-2); }
.meta__spec .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }
.cam { width: 120px; height: 90px; object-fit: cover; border: 1px solid var(--line-2); flex: none; }
.list .x { border: 0; background: none; padding: 0 0 0 8px; color: var(--muted); cursor: pointer; font-size: 12px; }
.list .x:hover { color: var(--paper); text-decoration: underline; }
.list .err { color: var(--muted); font-size: 13px; }
.list .ng { color: var(--accent-text); }
.history .a { font-size: 13.5px; }
.talk__body pre { white-space: pre-wrap; font-size: 13px; }
.talk__body ul { margin: 0 0 0.8em; padding-left: 1.2em; }

/* 設定 */
.settings { border: 1px solid var(--line-2); padding: 0; max-width: 560px; width: calc(100% - 40px); background: #0d0e11; color: var(--paper); }
.settings::backdrop { background: rgba(7, 8, 10, 0.7); }
.settings__form { padding: 34px 38px; display: grid; gap: 26px; max-height: 86vh; overflow: auto; }
.settings__title { margin: 0; font-size: 22px; font-weight: 500; letter-spacing: 0.06em; }
.settings fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 14px 0 0; display: grid; gap: 12px; }
.settings legend { font-size: 12px; color: var(--paper-2); letter-spacing: 0.14em; padding: 0 10px 0 0; }
.settings label { display: grid; gap: 4px; font-size: 12.5px; color: var(--paper-2); }
.settings label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--paper); }
.settings input:not([type]), .settings input[type="password"], .settings select, .settings textarea {
  border: 0; border-bottom: 1px solid var(--line-2); background: transparent; padding: 8px 2px; font-size: 15px; color: var(--paper); font-family: inherit;
}
.settings select option { background: #0d0e11; }
.settings textarea { resize: vertical; }
.settings input:focus-visible, .settings select:focus-visible, .settings textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.settings p { margin: 0; font-size: 12.5px; }
.settings__actions { display: flex; gap: 12px; }
.settings__row { display: flex; gap: 10px; flex-wrap: wrap; }
.guide { font-size: 12.5px; color: var(--paper-2); }
.guide summary { cursor: pointer; color: var(--paper); }
.guide ol { margin: 8px 0 0; padding-left: 1.3em; display: grid; gap: 6px; line-height: 1.7; }
.settings input[type="number"] { border: 0; border-bottom: 1px solid var(--line-2); background: transparent; padding: 8px 2px; font-size: 15px; color: var(--paper); }

@media (max-width: 900px), (max-aspect-ratio: 1/1) {
  .cam { width: 72px; height: 54px; }
  .desk__row { flex-wrap: wrap; }
  .desk__row .ask { flex-basis: 100%; }
}

/* ---------- ログイン・招待・運営の画面 ---------- */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; position: relative; z-index: 1; }
.gate__box { width: 100%; max-width: 400px; display: grid; gap: 18px; }
.gate__brand { font-family: "Shikigami Brush", var(--gothic); font-size: 64px; line-height: 1; margin: 0; }
.gate__lead { margin: 0; color: var(--paper-2); font-size: 14px; }
.gate form { display: grid; gap: 14px; }
.gate label { display: grid; gap: 4px; font-size: 12.5px; color: var(--paper-2); }
.gate input { border: 0; border-bottom: 1px solid var(--line-2); background: transparent; padding: 10px 2px; font-size: 16px; color: var(--paper); }
.gate input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.gate .msg { min-height: 1.6em; margin: 0; font-size: 13px; color: var(--accent-text); }
.admin { max-width: 1000px; margin: 0 auto; padding: 32px 20px 80px; position: relative; z-index: 1; display: grid; gap: 28px; }
.admin h1 { margin: 0; font-size: 22px; font-weight: 500; letter-spacing: 0.06em; }
.admin form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.admin form label { display: grid; gap: 4px; font-size: 12.5px; color: var(--paper-2); flex: 1 1 220px; }
.admin form input { border: 0; border-bottom: 1px solid var(--line-2); background: transparent; padding: 8px 2px; font-size: 16px; color: var(--paper); }
.admin form select { border: 0; border-bottom: 1px solid var(--line-2); background: transparent; padding: 8px 2px; font-size: 15px; color: var(--paper); }
.admin form select option { background: #0d0e11; }
.admin table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin th, .admin td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin th { font-size: 12px; color: var(--paper-2); font-weight: 500; letter-spacing: 0.08em; }
.admin .invite { word-break: break-all; font-family: var(--mono); font-size: 12px; color: var(--accent-text); }
.admin .table-wrap { overflow-x: auto; }

/* ---------- 紹介・規約のページ（ログインなしで読める） ---------- */
body.doc-page { overflow: auto; background: var(--ink); color: var(--paper); }
.doc { max-width: 760px; margin: 0 auto; padding: 40px 22px 96px; position: relative; z-index: 1; }
.doc__top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--line-2); }
.doc__brand { font-family: "Shikigami Brush", var(--gothic); font-size: 34px; line-height: 1; color: var(--paper); text-decoration: none; white-space: nowrap; flex: 0 0 auto; }
@media (max-width: 560px) { .doc__top { flex-direction: column; align-items: flex-start; gap: 14px; } .doc__top nav { gap: 6px 16px; } }
.doc__top nav { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.doc a { color: var(--paper); text-underline-offset: 3px; }
.doc h1 { font-size: 24px; font-weight: 500; letter-spacing: 0.04em; margin: 36px 0 6px; }
.doc h2 { font-size: 17px; font-weight: 500; margin: 34px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.doc p, .doc li { color: var(--paper-2); }
.doc ul, .doc ol { padding-left: 1.3em; }
.doc .doc__meta { font-size: 13px; color: var(--muted); }
.doc .doc__draft { border: 1px solid var(--accent); padding: 10px 14px; color: var(--accent-text); font-size: 13.5px; }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 10px 8px; border-bottom: 1px solid var(--line); color: var(--paper-2); }
.doc th { width: 34%; color: var(--paper); font-weight: 500; }
.doc .doc__lead { font-size: 17px; color: var(--paper); line-height: 1.9; }
.doc .doc__cta { display: inline-block; margin-top: 8px; }
.doc__foot { margin-top: 56px; padding-top: 16px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.gate__links { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; }
.gate__links a { color: var(--paper-2); }

.admin__h2 { margin: 8px 0 0; font-size: 15px; font-weight: 500; letter-spacing: 0.08em; }
.admin__select { border: 0; border-bottom: 1px solid var(--line-2); background: transparent; color: var(--paper); font-size: 14px; padding: 4px 2px; }
.admin__select option { background: #0d0e11; }

.apply { display: grid; gap: 14px; max-width: 560px; margin-top: 8px; }
.apply label { display: grid; gap: 4px; font-size: 13px; color: var(--paper-2); }
.apply input, .apply select, .apply textarea { border: 1px solid var(--line-2); background: rgba(236, 235, 230, 0.03); color: var(--paper); font: inherit; font-size: 16px; padding: 10px 12px; }
.apply select option { background: #0d0e11; }
.apply input:focus-visible, .apply select:focus-visible, .apply textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.apply button { justify-self: start; }
.apply__trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.apply__msg { min-height: 1.6em; margin: 0; color: var(--accent-text); font-size: 13.5px; }
