/* Clinical Co-Pilot — モバイルファースト。カテゴリ色は journal-summary SKILL.md の確定RGBを流用 */
:root {
  --device:    rgb(0, 100, 200);
  --ep:        rgb(160, 120, 0);
  --structure: rgb(0, 150, 80);
  --ischemia:  rgb(200, 50, 50);
  --bonus:     rgb(120, 40, 160);

  --bg: #0f1216;
  --surface: #171c23;
  --surface2: #1f2630;
  --line: #2a323d;
  --text: #e7edf3;
  --muted: #9fb0c0;
  --accent: #4aa3ff;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  padding-bottom: 40px;
}

/* ── Header ─────────────────────────────────────── */
header.app {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15, 18, 22, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px 0;
}
.title-row { display: flex; align-items: center; gap: 10px; }
.title-row h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.title-row .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.title-row .gear { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }

/* ── Tabs ───────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-top: 12px; }
.tabs button {
  flex: 1; padding: 10px 6px; border: none; cursor: pointer;
  background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

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

/* ── Search controls ────────────────────────────── */
.controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.searchbar { display: flex; gap: 8px; }
input[type="text"], input[type="search"], input[type="password"], select, textarea {
  width: 100%; padding: 12px 14px; font-size: 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.btn {
  flex: 0 0 auto; padding: 12px 18px; font-size: 15px; font-weight: 700;
  background: var(--accent); color: #04121f; border: none;
  border-radius: var(--radius); cursor: pointer; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--line); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row label { font-size: 13px; color: var(--muted); }
.row select { width: auto; padding: 8px 10px; font-size: 14px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.check input { width: auto; }

/* ── Category chips ─────────────────────────────── */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
  border: 1.5px solid var(--c); color: var(--c); background: transparent;
  cursor: pointer; opacity: .55; transition: opacity .12s, background .12s;
}
.chip.on { opacity: 1; background: color-mix(in srgb, var(--c) 18%, transparent); }
.chip .n { opacity: .8; font-weight: 600; margin-left: 4px; }
.chip[data-cat="device"]    { --c: var(--device); }
.chip[data-cat="ep"]        { --c: var(--ep); }
.chip[data-cat="structure"] { --c: var(--structure); }
.chip[data-cat="ischemia"]  { --c: var(--ischemia); }
.chip[data-cat="bonus"]     { --c: var(--bonus); }

/* ── Latest category buttons ────────────────────── */
.hint { color: var(--muted); font-size: 12px; margin: 2px 0 4px; line-height: 1.5; }
.catbtn {
  padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 700;
  border: 1.5px solid var(--line); color: var(--text); background: var(--surface);
  cursor: pointer;
}
.catbtn:disabled { opacity: .5; }
.catbtn.on { border-color: var(--accent); color: #04121f; background: var(--accent); }
#latest-cats .catbtn[data-cat="device"]    { border-color: var(--device); color: var(--device); }
#latest-cats .catbtn[data-cat="ep"]        { border-color: var(--ep); color: var(--ep); }
#latest-cats .catbtn[data-cat="structure"] { border-color: var(--structure); color: var(--structure); }
#latest-cats .catbtn[data-cat="ischemia"]  { border-color: var(--ischemia); color: var(--ischemia); }
#latest-cats .catbtn.on { color: #04121f; }
#latest-cats .catbtn[data-cat="device"].on    { background: var(--device); border-color: var(--device); color:#fff; }
#latest-cats .catbtn[data-cat="ep"].on        { background: var(--ep); border-color: var(--ep); color:#fff; }
#latest-cats .catbtn[data-cat="structure"].on { background: var(--structure); border-color: var(--structure); color:#fff; }
#latest-cats .catbtn[data-cat="ischemia"].on  { background: var(--ischemia); border-color: var(--ischemia); color:#fff; }

/* ── Cards ──────────────────────────────────────── */
.meta-line { color: var(--muted); font-size: 13px; margin: 14px 2px 8px; }
.cards { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--c, var(--line));
  border-radius: var(--radius); padding: 14px;
}
.card[data-cat="device"]    { --c: var(--device); }
.card[data-cat="ep"]        { --c: var(--ep); }
.card[data-cat="structure"] { --c: var(--structure); }
.card[data-cat="ischemia"]  { --c: var(--ischemia); }
.card[data-cat="bonus"]     { --c: var(--bonus); }
.badge {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .5px;
  text-transform: uppercase; color: #fff; background: var(--c);
  padding: 2px 8px; border-radius: 6px; margin-bottom: 8px;
}
.card .title-ja { font-size: 16px; font-weight: 700; line-height: 1.45; margin: 0 0 4px; }
.card .title-en { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.card .summary { font-size: 14px; margin: 0 0 10px; }
.card .src { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.card .src a { color: var(--accent); text-decoration: none; font-weight: 600; }
.card .src a:active { text-decoration: underline; }

/* ── Ask answer ─────────────────────────────────── */
.answer {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; white-space: pre-wrap;
  line-height: 1.7; font-size: 15px;
}
.answer .pmidref { color: var(--accent); font-weight: 600; }
.sources-h { color: var(--muted); font-size: 13px; margin: 16px 2px 8px; }

/* ── States ─────────────────────────────────────── */
.note { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 14px; }
.error { color: #ff8a8a; background: rgba(255,80,80,.08); border: 1px solid rgba(255,80,80,.3);
  border-radius: var(--radius); padding: 12px 14px; font-size: 14px; margin-bottom: 12px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--muted);
  border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Token gate modal ───────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-bg.show { display: flex; }
.modal {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px; width: 100%; max-width: 380px;
}
.modal-close {
  position: absolute; top: 8px; right: 10px; width: 34px; height: 34px;
  background: none; border: none; color: var(--muted); font-size: 24px;
  line-height: 1; cursor: pointer; border-radius: 8px;
}
.modal-close:active { background: var(--surface2); }
.modal h2 { margin: 0 0 6px; font-size: 17px; }
.modal p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.modal .btn { width: 100%; margin-top: 12px; }

.hidden { display: none !important; }
