/* MediMind — 연구실(2026-10-22 사용자): 고른 글 메뉴 · 손가락 단추 · 알림(research-pick.js, 앱 · 브리핑 · 소식 화면 공통)과 연구실 화면(research.js).
 * 앱 토큰(--a-*, theme-plex.css)을 쓰고, 토큰이 없는 브리핑 · 소식 화면에서는 같은 색의 기본값을 씁니다.
 * CSP: style 속성은 쓰지 않습니다(위치 · 높이만 CSSOM). 출처 칩은 무채색 + 아이콘(rules.mjs UI). */

/* ── 고른 글 메뉴 · 손가락 단추 · 알림 ─────────────────────────────── */
.rs-menu {
  position: fixed; z-index: 2147483000; min-width: 188px; padding: 4px;
  background: var(--a-surface, #fff); border: 1px solid var(--a-line, #d5dfdd); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 31, 38, 0.16); font-family: inherit; font-size: 14px; line-height: 1.4;
}
.rs-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 12px;
  border: 0; border-radius: 6px; background: transparent; color: var(--a-ink, #0f1f26);
  font: inherit; text-align: left; cursor: pointer;
}
.rs-menu button:hover, .rs-menu button:focus-visible { background: var(--a-accent-soft, #dbeeea); outline: none; }
.rs-menu button:first-child { font-weight: 600; }
.rs-menu svg, .rs-chip svg { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rs-menu button:first-child svg { color: var(--a-accent, #0b7a72); }

.rs-chip {
  position: fixed; z-index: 2147483000; display: inline-flex; align-items: stretch; padding: 3px; border-radius: 999px;
  background: var(--a-ink, #0f1f26); box-shadow: 0 6px 18px rgba(15, 31, 38, 0.24);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.rs-chip button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px;
  background: transparent; color: #fff; font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1; cursor: pointer;
}
.rs-chip button + button { border-left: 1px solid rgba(255, 255, 255, 0.22); border-radius: 0 999px 999px 0; }

.rs-toast {
  position: fixed; z-index: 2147483001; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 9px 16px; border-radius: 999px;
  background: var(--a-ink, #0f1f26); color: #fff; font-family: inherit; font-size: 13.5px; line-height: 1.4;
  box-shadow: 0 6px 18px rgba(15, 31, 38, 0.24); pointer-events: none; word-break: keep-all; overflow-wrap: anywhere;
}
.rs-toast[data-tone="error"] { background: var(--a-warn, #bf3438); }
.rs-toast[hidden] { display: none; }
.rs-offscreen { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; }

/* ── 바로 설명 창(research-explain.js) ─────────────────────────────────
 * 의견 보내기 아이콘(.a-fab)에서 커지며 열리고(rx-from → 제자리), 다음 창은 ㅁ 순서로 조금 맞물려 겹칩니다.
 * 첫 창만 위쪽에 청록 띠(어느 창이 처음인지). 창 안의 글은 다시 고를 수 있습니다(user-select). */
.rx-win {
  position: fixed; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: var(--a-surface, #fff); color: var(--a-ink, #0f1f26); border: 1px solid var(--a-line-strong, #a3bcb8); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 31, 38, 0.22); font-family: inherit; font-size: 14px; line-height: 1.55;
  transform-origin: 0 0; transition: left 0.24s ease, top 0.24s ease, height 0.24s ease, transform 0.24s ease, opacity 0.24s ease;
  -webkit-user-select: text; user-select: text;
}
.rx-win.rx-still { transition: none; }
.rx-win.rx-first { border-top: 4px solid var(--a-accent, #0b7a72); }
.rx-q {
  flex: none; margin: 0; padding: 10px 14px 8px; border-bottom: 1px solid var(--a-line-soft, #e6edeb); background: var(--a-sunken, #edf2f0);
  color: var(--a-ink-2, #3f5259); font-size: 13px; font-weight: 600;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere;
}
.rx-a { flex: 1; min-height: 0; overflow: auto; padding: 10px 14px 12px; overscroll-behavior: contain; }
.rx-core { margin: 0 0 6px; font-size: 15px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.rx-points { margin: 0; padding-left: 18px; }
.rx-points li { margin: 2px 0; overflow-wrap: anywhere; }
.rx-err { margin: 0; color: var(--a-warn, #bf3438); }
.rx-mark { background: var(--a-accent-soft, #dbeeea); color: inherit; border-radius: 3px; box-shadow: 0 0 0 2px var(--a-accent-soft, #dbeeea); }
.rx-load { margin: 0; color: var(--a-muted, #56686e); }
.a-fab.rx-hide { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .rx-win { transition: none; } }

/* ── 연구실 화면 ──────────────────────────────────────────────────── */
.rs-panel {
  container-type: inline-size; margin: 16px 20px 20px;
  background: var(--a-surface, #fff); border: 1px solid var(--a-line, #d5dfdd); border-radius: 10px;
}
.rs-item {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 36%); gap: 10px 20px;
  padding: 14px 16px; border-top: 1px solid var(--a-line-soft, #e6edeb);
}
.rs-item:first-child { border-top: 0; }
@container (max-width: 760px) { .rs-item { grid-template-columns: minmax(0, 1fr); } }

.rs-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; min-width: 0; }
/* 출처 칩 + (바로 설명이면) 작은 태그. 칩은 브리핑의 출처 태그(무채색 칩 + 아이콘)와 같은 모양, 누를 수 없으므로 테두리 없음(테두리 = 누를 수 있음). */
.rs-srcs { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.rs-src {
  display: inline-flex; align-items: center; gap: 3px; flex: none; padding: 2px 6px; border-radius: 4px;
  background: #e9eef0; color: #334047; font-size: 11.5px; font-weight: 700; line-height: 1.5; white-space: nowrap;
}
.rs-src svg, .rs-ext, .rs-del svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rs-src svg { width: 12px; height: 12px; stroke-width: 2.2; }
.rs-title {
  min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13.5px; font-weight: 600; color: var(--a-ink, #0f1f26);
}
a.rs-title { text-decoration: none; }
a.rs-title:hover { color: var(--a-accent, #0b7a72); text-decoration: underline; }
.rs-ext { width: 12px; height: 12px; margin-left: 3px; vertical-align: -1px; }
button.rs-title {
  padding: 1px 8px; border: 1px solid var(--a-line-input, #7c8f8d); border-radius: 6px;
  background: var(--a-surface, #fff); font-family: inherit; cursor: pointer;
}
button.rs-title:hover { border-color: var(--a-accent, #0b7a72); color: var(--a-accent, #0b7a72); }
.rs-title .mono, .rs-at { font-family: var(--a-mono, "IBM Plex Mono", ui-monospace, monospace); font-variant-numeric: tabular-nums; font-weight: 400; }
.rs-at { margin-left: auto; flex: none; font-size: 12px; color: var(--a-muted, #56686e); }
.rs-del {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; margin: -4px -6px -4px 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--a-muted, #56686e); cursor: pointer;
}
.rs-del svg { width: 16px; height: 16px; }
.rs-del:hover { background: var(--a-warn-soft, #fbefeb); color: var(--a-warn, #bf3438); }

.rs-quote { position: relative; margin-top: 8px; padding-left: 12px; border-left: 2px solid var(--a-line, #d5dfdd); }
.rs-text { font-size: 15px; line-height: 1.6; color: var(--a-ink, #0f1f26); white-space: pre-wrap; overflow-wrap: anywhere; }
.rs-text[data-clamp="on"] { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.rs-more {
  display: inline-grid; place-items: center; width: 28px; height: 24px; margin-top: 2px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--a-muted, #56686e); cursor: pointer;
}
.rs-more svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.15s; }
.rs-more[aria-expanded="true"] svg { transform: rotate(180deg); }
.rs-more:hover { background: var(--a-sunken, #edf2f0); color: var(--a-ink, #0f1f26); }

.rs-memo {
  display: block; width: 100%; min-height: 64px; height: 100%; padding: 8px 10px; resize: none; overflow: hidden;
  border: 1px solid var(--a-line, #d5dfdd); border-radius: 8px; background: var(--a-sunken, #edf2f0);
  color: var(--a-ink, #0f1f26); font-family: inherit; font-size: 14px; line-height: 1.55;
}
.rs-memo::placeholder { color: var(--a-placeholder, #66777c); }
.rs-memo:focus { outline: 2px solid var(--a-accent, #0b7a72); outline-offset: -1px; background: var(--a-surface, #fff); }

/* 바로 설명 기록: 창마다 한 줄(고른 말 → 설명), 다음 창은 들여서. */
.rs-steps { margin-top: 8px; display: grid; gap: 8px; }
.rs-step { padding-left: 12px; border-left: 2px solid var(--a-line, #d5dfdd); }
.rs-step[data-depth="0"] { border-left-color: var(--a-accent, #0b7a72); }
.rs-step[data-depth="1"] { margin-left: 16px; } .rs-step[data-depth="2"] { margin-left: 32px; } .rs-step[data-depth="3"] { margin-left: 48px; }
.rs-step[data-deep] { margin-left: 64px; }
.rs-step-q { font-size: 13px; font-weight: 600; color: var(--a-ink-2, #3f5259); overflow-wrap: anywhere; }
.rs-step-core { font-size: 14.5px; font-weight: 700; overflow-wrap: anywhere; }
.rs-step ul { margin: 2px 0 0; padding-left: 18px; font-size: 14px; }
.rs-tag { flex: none; padding: 1px 7px; border-radius: 4px; background: var(--a-accent-soft, #dbeeea); color: var(--a-accent-hover, #09625c); font-size: 11.5px; font-weight: 700; }

/* 연구실 정리(recap, research-recap.mjs): 코드가 센 숫자만. 묶음이 없으면 상자도 없음. */
.rs-recap { margin: 16px 20px 0; padding: 12px 16px; background: var(--a-surface, #fff); border: 1px solid var(--a-line, #d5dfdd); border-radius: 10px; }
.rs-recap h2 { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.rs-recap-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 8px; padding: 6px 0; border-top: 1px solid var(--a-line-soft, #e6edeb); }
.rs-recap-row:first-of-type { border-top: 0; }
.rs-recap-row > b { flex: 0 0 auto; min-width: 200px; font-size: 13px; color: var(--a-ink-2, #3f5259); }
.rs-recap-row span { padding: 2px 8px; border-radius: 6px; background: var(--a-sunken, #edf2f0); font-size: 13px; }
.rs-recap-row small { color: var(--a-muted, #56686e); font-family: var(--a-mono, "IBM Plex Mono", ui-monospace, monospace); font-size: 12px; }

.rs-empty { padding: 28px 16px; text-align: center; font-size: 14px; color: var(--a-muted, #56686e); word-break: keep-all; overflow-wrap: anywhere; }
.rs-empty b { display: block; margin-bottom: 4px; font-size: 16px; color: var(--a-ink, #0f1f26); }

/* 휴대폰: 첫 줄 = 출처 칩 · 시각 · 지우기, 둘째 줄 = 제목(빈 줄이 생기지 않게). */
@container (max-width: 520px) {
  .rs-meta { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
  .rs-srcs { grid-area: 1 / 1; justify-self: start; }
  .rs-at { grid-area: 1 / 2; justify-self: end; margin-left: 0; }
  .rs-del { grid-area: 1 / 3; }
  .rs-title { grid-area: 2 / 1 / 3 / 4; justify-self: start; }
}
@media (max-width: 860px) {
  .rs-recap { margin: 12px 12px 0; }
  .rs-recap-row > b { min-width: 0; flex-basis: 100%; }
  .rs-panel { margin: 12px; }
  .rs-item { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) { .rs-more svg { transition: none; } }
