/* アンチ帯 — 静かな書斎のような佇まい */
:root {
  --bg: #f5f1e8;
  --bg-deep: #efe9dc;
  --card: #fffdf8;
  --ink: #2b2622;
  --sub: #7d7368;
  --accent: #a65a3e;
  --accent-dark: #8a4a33;
  --accent-soft: #f3e4dc;
  --border: #e3dccd;
  --shadow: 0 1px 2px rgba(43, 38, 34, 0.05), 0 10px 30px rgba(43, 38, 34, 0.06);
}

* { box-sizing: border-box; }

/* display指定を持つ要素(button.primary等)でもhidden属性を必ず効かせる */
[hidden] { display: none !important; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 400px at 50% -100px, rgba(166, 90, 62, 0.05), transparent),
    var(--bg);
  color: var(--ink);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  line-height: 1.85;
}

a { color: var(--accent); }

/* ---- ヘッダー ---- */
.site-header {
  text-align: center;
  padding: 56px 16px 10px;
}
.brand {
  font-size: 2.3rem;
  letter-spacing: 0.34em;
  text-indent: 0.34em; /* 字間ぶんのセンター補正 */
  margin: 0;
  font-weight: 600;
}
.brand a { color: var(--ink); text-decoration: none; }
.tagline {
  color: var(--sub);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  margin: 10px 0 0;
}
.site-header::after {
  content: "";
  display: block;
  width: 56px;
  height: 1px;
  margin: 22px auto 0;
  background: linear-gradient(to right, transparent, var(--accent), transparent);
}

.container {
  max-width: 680px;
  margin: 28px auto 56px;
  padding: 0 16px;
}

/* ---- カード ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 26px 28px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.card h2 { margin-top: 0; font-size: 1.2rem; }

.hint { color: var(--sub); font-size: 0.88rem; }
.error { color: #a33; }

/* ---- 好み分析(主役) ---- */
.analysis-card {
  position: relative;
  background: linear-gradient(160deg, #fffdf6, #fbf4e7);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 10px;
  padding: 34px 34px 30px;
  margin-bottom: 34px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.analysis-card::before {
  content: "“";
  position: absolute;
  top: -18px;
  right: 14px;
  font-size: 9rem;
  line-height: 1;
  color: rgba(166, 90, 62, 0.10);
  font-family: Georgia, serif;
  pointer-events: none;
}
.analysis-label {
  margin: 0 0 14px;
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  color: var(--accent);
}
.analysis {
  margin: 0;
  font-size: 1.08rem;
  line-height: 2.1;
  letter-spacing: 0.02em;
}

.mode-badge {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  border: 1px solid rgba(166, 90, 62, 0.45);
  border-radius: 3px;
  padding: 2px 9px;
  vertical-align: 1px;
  margin-left: 10px;
  background: #fff;
}

/* ---- セクション見出し ---- */
.section-title {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 1.15rem;
  letter-spacing: 0.14em;
  margin: 38px 0 18px;
}
.section-title::before,
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---- 検索(入力ページ) ---- */
.search-box { position: relative; }
#search-input {
  width: 100%;
  padding: 13px 15px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
  transition: border-color 0.15s;
}
#search-input:focus { outline: none; border-color: var(--accent); }
.search-results {
  position: absolute;
  z-index: 10;
  left: 0; right: 0;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(43, 38, 34, 0.12);
  max-height: 280px;
  overflow-y: auto;
}
.search-results li {
  padding: 10px 15px;
  cursor: pointer;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
}
.search-results li:last-child { border-bottom: 0; }
.search-results li:hover { background: var(--bg); }

/* ---- 選択済み ---- */
.selected-books {
  list-style: none;
  padding: 0;
  margin: 16px 0 4px;
}
.selected-books li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px dashed var(--border);
}
.book-label { flex: 1; font-size: 0.95rem; }
.star {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: #cfc09a;
  padding: 0 4px;
  transition: transform 0.12s;
}
.star:hover { transform: scale(1.15); }
.star.active { color: #d4a017; }
.remove {
  background: none;
  border: none;
  color: var(--sub);
  font-size: 1.1rem;
  cursor: pointer;
}

/* ---- ヒントを足して再診断(結果ページ・分析ブロック下) ---- */
.hint-card {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin: -16px 0 34px;
}
.hint-title {
  margin: 0 0 10px;
  font-size: 0.86rem;
  color: var(--sub);
}
.hint-card textarea {
  width: 100%;
  padding: 10px 13px;
  font-size: 0.92rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  resize: vertical;
  transition: border-color 0.15s;
}
.hint-card textarea:focus { outline: none; border-color: var(--accent); }
button.secondary {
  margin-top: 10px;
  font-family: inherit;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  padding: 8px 20px;
  color: var(--accent);
  background: #fff;
  border: 1px solid rgba(166, 90, 62, 0.45);
  border-radius: 18px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
button.secondary:hover:not(:disabled) { background: var(--accent); color: #fff; }
button.secondary:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- モード ---- */
.mode-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 20px 0;
  padding: 12px 18px 14px;
}
.mode-select legend { font-size: 0.88rem; color: var(--sub); padding: 0 8px; }
.mode-select label { display: block; margin: 7px 0; cursor: pointer; }
.mode-desc { display: block; margin-left: 24px; color: var(--sub); font-size: 0.85rem; }

/* ---- ボタン・ローディング ---- */
button.primary {
  display: block;
  width: 100%;
  padding: 15px;
  font-size: 1.05rem;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0.14em;
  transition: background 0.15s, transform 0.1s;
}
button.primary:hover:not(:disabled) { background: var(--accent-dark); }
button.primary:active:not(:disabled) { transform: translateY(1px); }
button.primary:disabled { background: #cdc5b7; cursor: not-allowed; }

/* ---- 診断中のライブ表示(ストリーミング) ---- */
.live-status {
  text-align: center;
  color: var(--sub);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  margin: 0 0 18px;
}
#live .analysis.streaming::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--accent);
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.skel-line {
  height: 12px;
  border-radius: 6px;
  margin: 10px 0;
  background: linear-gradient(90deg, var(--border), #f2ede1, var(--border));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.w40 { width: 40%; }
.w60 { width: 60%; }
.w80 { width: 80%; }
.w90 { width: 90%; }
.skel-status { margin: 12px 0 0; }

.loading { text-align: center; color: var(--sub); margin-top: 16px; }
.spinner {
  width: 28px; height: 28px;
  margin: 0 auto 8px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 提案カード ---- */
.book-card {
  padding: 24px 26px 18px;
  transition: box-shadow 0.2s;
}
.book-card:hover {
  box-shadow: 0 2px 4px rgba(43, 38, 34, 0.06), 0 14px 36px rgba(43, 38, 34, 0.09);
}
.book-layout {
  display: flex;
  gap: 22px;
  align-items: flex-start;
}
.book-cover {
  flex: 0 0 96px;
  width: 96px;
  aspect-ratio: 10 / 14.2;
  border-radius: 3px;
  overflow: hidden;
  background: linear-gradient(150deg, var(--bg-deep), #e5dcc9);
  border: 1px solid var(--border);
  box-shadow: 3px 4px 10px rgba(43, 38, 34, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}
.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-fallback {
  writing-mode: vertical-rl;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: var(--sub);
  padding: 10px 0;
  text-align: center;
}
.book-body { flex: 1; min-width: 0; }

.book-no {
  margin: 0 0 2px;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  color: rgba(166, 90, 62, 0.75);
}
.book-title { margin: 0 0 4px; font-size: 1.18rem; line-height: 1.5; }
.book-meta { color: var(--sub); font-size: 0.87rem; margin: 0 0 12px; }
.book-reason { margin: 0 0 14px; font-size: 0.97rem; }

.formats { margin: 0 0 12px; }
.chip {
  display: inline-block;
  font-size: 0.76rem;
  color: var(--sub);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1px 10px;
  margin: 0 6px 4px 0;
  background: var(--bg);
}

.links { margin: 0; }
.links a {
  display: inline-block;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--accent);
  border: 1px solid rgba(166, 90, 62, 0.35);
  border-radius: 16px;
  padding: 4px 14px;
  margin: 0 8px 6px 0;
  transition: background 0.15s, color 0.15s;
}
.links a:hover { background: var(--accent); color: #fff; }

/* ---- 反応(読みたい/読んだ/惹かれない) ---- */
.rating { margin-top: 16px; border-top: 1px dashed var(--border); padding-top: 13px; }
.reaction-btn, .rating-buttons button {
  font-family: inherit;
  font-size: 0.84rem;
  padding: 6px 15px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  color: var(--sub);
  cursor: pointer;
  margin: 0 8px 6px 0;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.reaction-btn:hover { border-color: var(--accent); color: var(--accent); }
.reaction-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.rating-buttons { margin-top: 8px; }
.rating-buttons button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.reason-box { margin-top: 8px; }
.reason-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.reason-input:focus { outline: none; border-color: var(--accent); }

.actions { text-align: center; }
.actions p { margin: 16px 0 0; }
.share-x { margin-right: 16px; }

/* ---- ポリシー ---- */
.policy-list { padding-left: 1.2em; }
.policy-list li { margin-bottom: 10px; }
.closing { margin-top: 20px; }

/* ---- フッター ---- */
.site-footer {
  text-align: center;
  color: var(--sub);
  font-size: 0.85rem;
  padding: 28px 16px 44px;
}
.site-footer p { margin: 8px 0 0; }
.site-footer .credit {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #a89d90;
  margin-top: 14px;
}

/* ---- 狭い画面 ---- */
@media (max-width: 480px) {
  .card, .analysis-card { padding: 20px 18px; }
  .analysis { font-size: 1.02rem; line-height: 2; }
  .book-layout { gap: 14px; }
  .book-cover { flex-basis: 76px; width: 76px; }
  .brand { font-size: 1.9rem; }
}
