/* 推しレポ — 紙UI（paper-ui）
 * トークンは :root に1組だけ。画面ごとにパレットを分けない。
 * 役割差（読む画面 / 操作する画面）は装飾の量だけで付ける。
 */

:root {
  /* 面 */
  --paper-bg: #e9e6df;
  --paper: #fcfbf8;
  --card: #fff;

  /* 文字 */
  --ink: #22252b;
  --ink-strong: #1b1d24;
  --ink-soft: #6f6a60;
  --ink-faint: #8a8577;

  /* 線 */
  --line: #e3ded2;
  --line-strong: #cbc4b4;
  --line-row: #eae4d7;

  /* 差し色 */
  --accent: #d9006c;
  --accent-dark: #a80058;
  --marker: #ffe94d;

  /* 意味を持つ色 */
  --ok: #1b7f9e;
  --ng: #b31f34;
  --ng-soft: #d7b3ba;
  --focus: #1b7f9e;

  --nav-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

:where(button, a, input, textarea, select):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

body {
  min-height: 100svh;
  background: var(--paper-bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.5;
  font-family: "Hiragino Sans", "Noto Sans JP", -apple-system, BlinkMacSystemFont, sans-serif;
}

.shell {
  width: 100%;
  max-width: 480px;
  min-height: 100svh;
  margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
  background: var(--paper);
  box-shadow: 0 0 26px rgba(30, 25, 15, .10);
}

/* ---- ヘッダー ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 0 8px;
}
.topbar h1 {
  flex: 1;
  margin: 0;
  color: var(--ink-strong);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: .02em;
}
.topbar .back {
  min-height: 44px;
  min-width: 44px;
  padding: 0 10px;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 800;
}

/* ---- カード ---- */

.card {
  margin: 0 0 18px;
  padding: 17px 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(40, 32, 15, .04), 0 6px 18px rgba(40, 32, 15, .06);
}

/* 読む画面の見出し — マスキングテープ */
.card h2 {
  display: inline-block;
  margin: 0 0 12px;
  padding: 5px 12px 4px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .06em;
  border-radius: 3px;
  transform: rotate(-1.2deg);
}

/* 操作する画面の見出し — アクセントバー + 下線。回転しない */
.card.op h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 15px;
  padding: 0 0 10px;
  background: none;
  border-radius: 0;
  transform: none;
  color: var(--ink-strong);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--ink-strong);
}
.card.op h2::before {
  content: "";
  width: 8px;
  height: 16px;
  background: var(--accent);
  border-radius: 1px;
}

.marked { background: linear-gradient(transparent 66%, var(--marker) 66%); padding: 0 3px; }

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

button {
  min-height: 44px;
  padding: 9px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink-strong);
  font-weight: 800;
  transition: transform .04s;
}
button:active { transform: translateY(1px); }

button.primary { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
button.active { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
button.danger { color: var(--ng); border-color: var(--ng-soft); }
button.danger.active { background: var(--ng); border-color: var(--ng); color: #fff; }
button.block { width: 100%; }
button.big { min-height: 58px; font-size: 18px; }
button[disabled] {
  background: #f1eee6;
  border-color: var(--line);
  color: var(--ink-faint);
  cursor: not-allowed;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 9px; }
.btn-row > button { flex: 1 1 0; min-width: 120px; }

/* ---- 入力欄 ---- */

input, textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 2px solid var(--line-strong);
  border-radius: 9px;
  background: #fdfcf9;
  color: var(--ink);
  font-weight: 700;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); opacity: 1; }
textarea { min-height: 132px; resize: vertical; line-height: 1.65; }

.field { margin: 0 0 13px; }
.field > label {
  display: block;
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* チェックボックスは既定サイズだと13px程度しかない。行ごと44pxの操作領域にする */
.check {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  color: var(--ink-strong);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.check input[type="checkbox"] {
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}
.hint { margin: 6px 0 0; color: var(--ink-soft); font-size: 13px; font-weight: 600; }

.plain-list { margin: 0; padding: 0 0 0 1.1em; }
.plain-list li { margin: 0 0 7px; font-size: 15px; font-weight: 600; }
.plain-list li:last-child { margin-bottom: 0; }

.num { font-variant-numeric: tabular-nums; }

/* ---- 空の状態 ---- */

.empty {
  padding: 30px 18px;
  border: 2px dashed var(--line-strong);
  border-radius: 12px;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
}

/* ---- 一覧 ---- */

.read-row {
  display: block;
  width: 100%;
  padding: 13px 2px;
  border: 0;
  border-top: 1px dashed #d8d2c4;
  border-radius: 0;
  background: none;
  text-align: left;
  min-height: 44px;
}
.read-row:first-of-type { border-top: 0; }
.read-row .row-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.read-row .row-name { color: var(--ink-strong); font-size: 15px; }
.read-row .row-body {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 推しのアイコン。未登録なら頭文字を色付きの丸で出す（空欄を作らない） */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex: none;
  object-fit: cover;
  border: 1.5px solid var(--line);
  background: var(--card);
}
.avatar.initial {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  border-color: rgba(0, 0, 0, .12);
}
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }

/* 推しの点。色だけでなく名前も必ず併記する */
.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: none;
  border: 1px solid rgba(0, 0, 0, .12);
}

/* ---- 推しの選択（塗って示す） ---- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  font-size: 15px;
}
.chips button.active .dot { border-color: rgba(255, 255, 255, .7); }

/* ---- 会話カード ---- */

.dialogue { display: flex; flex-direction: column; gap: 11px; }

.line { display: flex; flex-direction: column; gap: 5px; }
/* アイコン + 吹き出しを1行に並べる。アイコン未登録でも位置が揃うようにする */
.line .line-main { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.line.self .line-main { justify-content: flex-end; }
.line .who {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .05em;
}
.line .bubble {
  max-width: 84%;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.line.self { align-items: flex-end; }
.line.self .bubble { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
.line.heart .bubble { background: var(--marker); border-color: #e2ce35; }
.line.staff .bubble { background: #f2efe6; }
.line.note { align-items: center; }
.line.note .bubble {
  max-width: 100%;
  border: 0;
  background: none;
  padding: 2px 0;
  color: var(--ink-soft);
  font-size: 14.5px;
  text-align: center;
}
/* 話者を判別できなかった行。色を薄くせず、下線で「要確認」と示す */
.line.unsure .bubble { border-bottom-style: dashed; border-bottom-color: var(--ng-soft); }

/* ---- 編集モードの会話行（操作する画面） ---- */

.edit-line {
  padding: 11px 0;
  border-bottom: 1px solid var(--line-row);
}
.edit-line:last-child { border-bottom: 0; }
.edit-line .speakers {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin: 0 0 8px;
}
.edit-line .speakers button {
  min-height: 44px;
  padding: 6px 2px;
  font-size: 12.5px;
  letter-spacing: -.02em;
}
.edit-line textarea { min-height: 62px; }
.edit-line .tools { display: flex; gap: 7px; margin: 8px 0 0; }
.edit-line .tools button { flex: 1; min-height: 44px; font-size: 13px; }

@media (max-width: 380px) {
  .edit-line .speakers { gap: 4px; }
  .edit-line .speakers button { font-size: 11.5px; padding: 6px 0; }
}

/* ---- 録音ボタン ---- */

.mic {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  font-size: 18px;
}
.mic .pulse {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.mic.on { background: var(--ng); border-color: var(--ng); color: #fff; }
.mic.on .pulse { animation: blink 1s steps(1, end) infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---- 信頼度の帯 ---- */

.notice {
  margin: 0 0 14px;
  padding: 11px 13px;
  border: 2px solid var(--line-strong);
  border-radius: 10px;
  background: #fffdf3;
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}
.notice.warn { border-color: var(--ng-soft); }

/* ---- タグ ---- */

.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
  padding: 5px 11px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: #f7f4ec;
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 800;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}
button.tag { min-height: 40px; }
button.tag.active { background: var(--accent); border-color: var(--accent-dark); color: #fff; }

/* ---- メタ情報行 ---- */

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---- 下部ナビ ---- */

.nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  width: 100%;
  max-width: 480px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line-strong);
}
.nav button {
  min-height: var(--nav-h);
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}
.nav button.active {
  background: var(--accent);
  color: #fff;
}

/* ---- トースト ---- */

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
  transform: translate(-50%, 20px);
  opacity: 0;
  max-width: 92vw;
  padding: 11px 18px;
  border-radius: 11px;
  background: #2b2e35;
  color: #fff;
  font-weight: 800;
  text-align: center;
  transition: .18s;
  pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- 共有プレビュー ---- */

.preview {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: block;
  background: var(--card);
}

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