/* ============================================================
   Research Series — スマホ最優先の落ち着いたデザイン
   研究ツールとしての清潔感を優先し、装飾は抑える
   ============================================================ */

:root {
  --forest: #1f3d2b;        /* 深いフォレストグリーン（見出し・強調） */
  --forest-soft: #2f5640;
  --sage: #7d9b76;          /* セージグリーン（アクセント） */
  --sage-pale: #e6ede3;
  --cream: #faf8f3;         /* オフホワイト / クリーム背景 */
  --card: #ffffff;
  --beige: #e8e0d0;
  --ink: #2b2b28;
  --ink-soft: #5f625c;
  --ink-faint: #8b8e86;
  --line: #e4e0d6;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(31, 61, 43, .06), 0 6px 18px rgba(31, 61, 43, .05);
}

* { box-sizing: border-box; }

/* display:flex/grid を指定した要素にも hidden を効かせる
   （ブラウザ既定の [hidden]{display:none} は詳細度で負けてしまうため） */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Noto Sans JP", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  /* 横スクロールを絶対に出さない */
  overflow-x: hidden;
}

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

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--forest);
  color: #fff;
  padding-top: env(safe-area-inset-top);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
}

.brand {
  margin: 0;
  font-family: "Noto Serif JP", serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions { display: flex; gap: 4px; flex: none; }

/* アイコンは絵文字ではなくSVG。大きさと線幅をここで統一する */
.icon {
  width: 21px;
  height: 21px;
  display: block;
}

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: rgba(255, 255, 255, .92);
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.icon-btn.is-on { background: rgba(255, 255, 255, .16); color: #fff; }

/* ---- 検索バー ---- */

.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 10px;
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, .95);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}
.search-input::placeholder { color: #9b9e96; }

.search-clear {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, .92);
  cursor: pointer;
}
.search-clear:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.search-clear .icon { width: 18px; height: 18px; }

/* ---- タブ ---- */

.tabs {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
}

/* 非選択タブ: 濃緑の中で少し明るい面にし、文字は白に近づけて読みやすくする。
   選択中はクリーム面＋濃緑文字なので、明るさの差で主従は保たれる。 */
.tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 9px 6px;
  border: 0;
  border-radius: 10px;
  background: var(--forest-soft);
  color: rgba(255, 255, 255, .92);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { background: #37624a; color: #fff; }

.tab.is-active {
  background: var(--cream);
  color: var(--forest);
  font-weight: 700;
}
.tab.is-active:hover { background: var(--cream); color: var(--forest); }

/* ---- 本体 ---- */

.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.tab-desc {
  margin: 4px 0 16px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-btn {
  flex: none;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--forest);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.filter-btn:hover { border-color: var(--sage); }

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.sort-label {
  flex: none;
  color: var(--ink-faint);
  font-size: 12px;
}

.sort {
  min-width: 0;
  max-width: 100%;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
}

/* いま何で絞り込んでいるかを、一覧の上に出して分かるようにする */
.active-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--forest);
  color: #fff;
  font-size: 11.5px;
}

.chip-clear {
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.chip-clear:hover { border-color: var(--sage); }

.count {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.status {
  margin: 32px 0;
  text-align: center;
  color: var(--ink-faint);
  font-size: 14px;
}
.status-sub { font-size: 12.5px; }

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

.list { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 12px;
  cursor: pointer;
}
.card:hover { border-color: var(--sage); }
.card:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }

.card-top {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

/* 研究論文はタイトル自体が情報なので、安易に切らない。
   実データ118件で測ったところ、375px幅では
     4行clamp … 23%が途中で切れる（平均カード高さ 90px）
     5行clamp … 3%だけ（平均 96px）
   と、5行にしても平均の高さはほとんど変わらず切れる件数だけ大きく減る。
   そのため5行を採用している。詳細画面では省略しない。 */
.card-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--forest);
  font-family: "Noto Serif JP", serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.7;
  letter-spacing: .01em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
}

/* 年はタイトル1行目の右に添える。太さと色を落として読みの邪魔をしない */
.card-year {
  flex: none;
  color: var(--ink-faint);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* AI要約: DBの3行要約はそのまま保持し、カード上では見た目だけ省略する */
.summary {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--sage-pale);
  border-left: 3px solid var(--sage);
  border-radius: 0 8px 8px 0;
}

.summary-head {
  color: var(--forest-soft);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .03em;
  margin-bottom: 3px;
}

.summary-body {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.72;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.ev { margin-top: 14px; }

/* ⚠ 点数による色分け・ゲージ・赤黄緑は使わない。
   「何点でも同じ見た目」のまま、数値そのものを大きく太くして読み取りやすくする。
   高得点=良い論文という印象を与えないため、配色差は一切付けない。 */
.ev-score {
  color: var(--forest);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
}

/* 研究デザイン名は点数の下に、落ち着いた文字で置く */
.ev-label {
  margin-top: 1px;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.6;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.tag {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--beige);
  color: var(--forest-soft);
  font-size: 11.5px;
  font-weight: 500;
}

/* 誤タップしにくいよう、タップ領域を広めに取る */
.fav {
  flex: none;
  width: 44px; height: 44px;
  margin: -8px -8px -8px 0;
  display: grid; place-items: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--ink-faint);
  cursor: pointer;
}
.fav:hover { background: var(--sage-pale); color: var(--ink-soft); }
.fav.is-on, .fav.is-on:hover { color: #b8544d; }
.fav .icon { width: 20px; height: 20px; }

/* ---- さらに表示 ---- */

.more {
  margin-top: 22px;
  text-align: center;
}

.shown {
  margin: 0 0 10px;
  color: var(--ink-faint);
  font-size: 12.5px;
}

.more-btn {
  width: 100%;
  max-width: 320px;
  padding: 13px 20px;
  border: 1px solid var(--sage);
  border-radius: 10px;
  background: var(--card);
  color: var(--forest);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.more-btn:hover { background: var(--sage-pale); }

/* ---- フッター ---- */

.footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 11.5px;
  line-height: 1.8;
}

.footer p { margin: 0 0 8px; }

.footer-companion a {
  color: var(--forest-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-parent {
  margin-top: 14px;
  color: #a8aaa2;
  font-size: 10.5px;
  letter-spacing: .04em;
}

/* ============================================================
   オーバーレイ共通（絞り込みシート / 詳細）
   ============================================================ */

.no-scroll { overflow: hidden; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  background: rgba(24, 33, 27, .45);
}

/* ---- 絞り込みボトムシート ---- */

.sheet {
  margin-top: auto;
  width: 100%;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border-radius: 18px 18px 0 0;
}

.sheet-head {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 52px 10px;
  border-bottom: 1px solid var(--line);
}

.sheet-grip {
  position: absolute;
  top: 7px; left: 50%;
  transform: translateX(-50%);
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--line);
}

.sheet-title {
  margin: 0;
  color: var(--forest);
  font-size: 15px;
  font-weight: 700;
}

.sheet-close {
  position: absolute;
  top: 8px; right: 6px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.sheet-close:hover { background: var(--beige); }
.sheet-close .icon { width: 19px; height: 19px; }

/* シートの中だけをスクロールさせ、画面外へはみ出さないようにする */
.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.sheet-group { margin-bottom: 20px; }

.sheet-group-title {
  margin: 0 0 9px;
  color: var(--forest);
  font-size: 12.5px;
  font-weight: 700;
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; }

.opt {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.4;
  cursor: pointer;
}
.opt.is-on {
  background: var(--forest);
  border-color: var(--forest);
  color: #fff;
  font-weight: 500;
}

.year-row { display: flex; align-items: center; gap: 8px; }

.year-sel {
  flex: 1 1 0;
  min-width: 0;
  padding: 9px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
}

.year-sep { flex: none; color: var(--ink-faint); font-size: 13px; }

.sheet-foot {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--cream);
}

.sheet-reset {
  flex: 0 0 34%;
  padding: 13px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.sheet-apply {
  flex: 1 1 auto;
  padding: 13px 10px;
  border: 0;
  border-radius: 10px;
  background: var(--forest);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

/* ---- 論文詳細 ---- */

.detail {
  margin: auto auto 0;
  width: 100%;
  max-width: 720px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border-radius: 18px 18px 0 0;
}

.detail-head {
  flex: none;
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px 6px;
  border-bottom: 1px solid var(--line);
}

.detail-close {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 15px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.detail-close:hover { border-color: var(--sage); }
.detail-close .icon { width: 16px; height: 16px; }

.detail-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px calc(28px + env(safe-area-inset-bottom));
}

/* 詳細ではタイトルを省略しない（clampを付けない） */
.d-title {
  margin: 0 0 10px;
  color: var(--forest);
  font-family: "Noto Serif JP", serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.7;
  letter-spacing: .01em;
}

.d-original {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}

.d-meta {
  margin: 0 0 18px;
  color: var(--ink-faint);
  font-size: 12.5px;
  line-height: 1.7;
}

.d-box {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 10px;
}

.d-box-title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
}

.d-summary {
  background: var(--sage-pale);
  border-left: 3px solid var(--sage);
}
.d-summary .d-box-title { color: var(--forest-soft); }
.d-summary-body { margin: 0; font-size: 14px; line-height: 1.85; }

.d-ev {
  background: var(--card);
  border: 1px solid var(--line);
}
.d-ev .d-box-title { color: var(--forest); }
/* 一覧と同じく、点数は大きく太く。色は点数によらず一定にする */
.d-ev-score { font-size: 17.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.d-ev-label { margin: 0 0 8px; color: var(--ink-soft); font-size: 13px; }

.d-reason > summary {
  color: var(--forest-soft);
  font-size: 13px;
  cursor: pointer;
}
.d-reason > p {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.8;
}

.d-ev-note {
  margin: 10px 0 0;
  color: var(--ink-faint);
  font-size: 11.5px;
  line-height: 1.7;
}

.d-section { margin-bottom: 18px; }

.d-section-title {
  margin: 0 0 8px;
  color: var(--forest);
  font-size: 13px;
  font-weight: 700;
}

.d-abstract {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.95;
  /* 長い学名やDOIで横に広がらないようにする */
  overflow-wrap: anywhere;
}

.d-original-abstract {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.d-original-abstract > summary {
  color: var(--forest-soft);
  font-size: 13px;
  cursor: pointer;
}
.d-original-abstract > p { margin: 10px 0 0; color: var(--ink-soft); }

.d-noabstract {
  margin: 0 0 18px;
  color: var(--ink-faint);
  font-size: 13px;
}

.d-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.d-links a {
  color: var(--forest-soft);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.d-fav-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.fav-lg { width: 48px; height: 48px; margin: 0 0 0 -8px; font-size: 22px; }

.d-fav-label { color: var(--ink-soft); font-size: 13px; }

/* ---- PC ---- */

@media (min-width: 700px) {
  body { font-size: 15.5px; }
  .brand { font-size: 21px; }
  .card-title { font-size: 16.5px; }
  .tabs { padding-bottom: 12px; }
  .tab { flex: 0 1 auto; padding: 9px 22px; }

  /* PCでは中央のパネルとして出す（下からせり上がる必要がない） */
  .overlay { align-items: center; justify-content: center; padding: 24px; }
  .sheet, .detail {
    margin: 0;
    max-width: 560px;
    max-height: 82vh;
    border-radius: 16px;
  }
  .detail { max-width: 720px; }
  .sheet-foot { padding-bottom: 16px; }
  .d-title { font-size: 19px; }
}
