/* Dr.DI 복약정보 — 전남대 웹 (2026-09-10 새로 씀)
 *
 * 디자인 원본: 외부협력/전남대/04_디자인/ (DrDI 채택안 · 갤럭시폴드 · PC)
 *
 * 폭에 따라 단계가 바뀐다.
 *   ~767px     폰. 한 줄. 약 상세는 아래에서 올라오는 시트
 *   768~1199   왼쪽 처방·약 목록 + 대화. 약 상세는 오른쪽에서 밀려 나오는 서랍
 *   1200~      왼쪽 목록 | 대화 | 오른쪽 약 상세 (세 칸이 나란히)
 *   1600~      넓은 모니터. 목록 4열, 대화 본문을 조금 더 넓힌다
 *
 * 양쪽 사이드바는 끌어서 너비를 바꾼다 (--side-w · --detail-w, app.js 가 넣는다).
 *
 * 대화 본문 폭에는 상한을 둔다. 한글 16px 에서 한 줄이 50자를 넘으면
 * 눈이 다음 줄 시작을 놓친다 — 고령 사용자에게 특히 불리하다.
 *
 * 고령 사용자가 많다 — 본문 17px, 누르는 곳은 최소 56px.
 */

@font-face { font-family: 'NanumSquare'; font-weight: 400; font-display: swap;
  src: url('/static/fonts/NanumSquare-R.woff2') format('woff2'); }
@font-face { font-family: 'NanumSquare'; font-weight: 700; font-display: swap;
  src: url('/static/fonts/NanumSquare-B.woff2') format('woff2'); }
@font-face { font-family: 'NanumSquare'; font-weight: 800; font-display: swap;
  src: url('/static/fonts/NanumSquare-EB.woff2') format('woff2'); }

:root {
  /* 브랜드 — 병원이 바뀌면 이 세 개만 갈아끼운다 */
  --brand:      #4A22C9;
  --brand-tint: #EFEBFF;
  --brand-deep: #2E1178;

  /* 중립 */
  --ground:  #F4F3F8;
  --surface: #FFFFFF;
  --ink:     #17171F;
  --soft:    #61616E;
  --line:    #E5E2ED;

  /* 의미색 — 브랜드가 바뀌어도 고정. «응급» 이 병원 색을 따라가면 안 된다 */
  --caution: #B26A00;  --caution-bg: #FFF4E0;
  --emg:     #C62F2A;  --emg-bg:     #FFF1F0;

  --r-card: 16px;
  --r-btn:  14px;
  --r-chip: 8px;
  --touch:  56px;
  --pad:    20px;
  --hdr:    56px;
  --feed-max: 560px;
  --list-max: 880px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
/* 아래로 당겨 새로고침(pull to refresh) 을 막는다 — 2026-11-04
   앱 웹뷰에서 새로고침되면 환자정보 POST 가 다시 날아가고 그때까지의 대화가 사라진다.
   앱 안에서 열리는 화면이라 주소창도 없어서, 사용자가 새로고침할 길은 이 동작뿐이다.
   none 은 이 화면 자체의 새로고침·바운스를 끄고,
   아래 contain 은 안쪽에서 끝까지 스크롤했을 때 그 동작이 화면 밖으로 번지는 것을 막는다. */
html, body { height: 100%; overscroll-behavior: none; }
.v-list, .feed, .detail-body, .modal-body, .side { overscroll-behavior-y: contain; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: 'NanumSquare', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
p { margin: 0; }

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.view { flex: 1; min-height: 0; }

/* ── 헤더 ──────────────────────────────────────────────────────────────── */
.hdr {
  flex: none; height: var(--hdr);
  display: grid; grid-template-columns: 56px 1fr 56px; align-items: center;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: relative; z-index: 30;
}
.hdr-btn {
  height: var(--hdr); min-width: 56px; border: 0; background: none;
  display: grid; place-items: center; padding: 0;
}
.hdr-btn.is-hidden { visibility: hidden; }
#hdrBack { font-size: 30px; font-weight: 800; line-height: 1; }
.hdr-title { text-align: center; font-size: 16px; font-weight: 800; color: var(--brand-deep); }
.hdr-title sup { font-size: .62em; vertical-align: super; font-weight: 700; }
.hdr-info { color: var(--soft); font-size: 19px; }
.hdr-info-txt { display: none; }

/* ── 공통 부품 ─────────────────────────────────────────────────────────── */
.eyebrow { font-size: 15px; color: var(--soft); }
.h1 { margin: 4px 0 0; font-size: 23px; font-weight: 800; line-height: 1.38; text-wrap: balance; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.start-rx .chips { margin-top: 14px; }
.chip {
  border: 0; border-radius: var(--r-chip); padding: 5px 10px;
  background: var(--brand-tint); color: var(--brand-deep);
  font-size: 13px; font-weight: 700; line-height: 1.5;
}
button.chip { min-height: 36px; }
.link {
  border: 0; background: none; padding: 0 2px; min-height: 44px;
  color: var(--brand); font-size: 13px; font-weight: 800;
}
.btn-primary {
  width: 100%; min-height: 62px; border: 0; border-radius: var(--r-btn);
  background: var(--brand); color: #fff; font-size: 19px; font-weight: 800;
}
.btn-primary:active { background: var(--brand-deep); }
.btn-ghost {
  width: 100%; min-height: var(--touch); border: 1px solid var(--line); border-radius: var(--r-btn);
  background: var(--ground); color: var(--soft); font-size: 17px; font-weight: 800;
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 16px 18px;
}
.badge { flex: none; border-radius: 8px; padding: 2px 10px; font-size: 13px; font-weight: 800; }
.badge-now { background: var(--brand); color: #fff; }
.badge-chg { background: var(--caution-bg); color: var(--caution); font-size: 12px; }
.pc-only { display: none; }

/* ── ① 처방 선택 ───────────────────────────────────────────────────────── */
.v-list { overflow-y: auto; }
.list-hero { padding: 28px var(--pad) 6px; }
.list-wrap { padding: 10px var(--pad) 24px; display: flex; flex-direction: column; gap: 12px; }
.month { margin: 12px 0 -2px; font-size: 13px; font-weight: 800; color: var(--soft); }
.rx {
  position: relative; display: block; width: 100%; min-height: var(--touch);
  padding: 16px 48px 16px 18px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
}
.rx:hover { border-color: #CFC7E8; }
.rx-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rx-date { font-size: 16px; font-weight: 800; }
.rx-sub { margin-top: 4px; font-size: 13px; color: var(--soft); }
.rx-go {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  color: var(--brand); font-size: 24px; font-weight: 800; line-height: 1;
}
.rx-cta { display: none; }
.rx.is-feature { border: 2px solid var(--brand); padding: 18px 48px 18px 18px; }
.list-foot { padding: 4px var(--pad) 28px; text-align: center; font-size: 12px; color: var(--soft); }
.empty { color: var(--soft); text-align: center; padding: 40px 0; }

/* ── ② ③ 대화 ──────────────────────────────────────────────────────────── */
.v-chat { display: flex; position: relative; }
.side, .split { display: none; }
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.feed { flex: 1; overflow-y: auto; padding: 18px var(--pad) 28px; }
.feed-in { max-width: var(--feed-max); margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

.start { display: flex; flex-direction: column; gap: 16px; }
.start .h1 { margin-top: 2px; }
/* 처방 카드 — 머리(병원·처방일·진단명) 바로 아래에 제목이 붙는다.
   예전 «약 N가지» 줄을 지우면서 붙어 있던 음수 여백도 걷어냈다 */
.card-head { font-size: 13px; font-weight: 700; color: var(--soft); line-height: 1.55; }
.card-title { margin: 4px 0 0; font-size: 20px; font-weight: 800; line-height: 1.4; text-align: left; }
.suggest-label, .ask-label { margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--soft); }
.suggest, .ask-list { display: flex; flex-direction: column; gap: 8px; }
.sg, .ask-chip {
  min-height: var(--touch); padding: 12px 18px; text-align: left;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn);
  font-size: 16px; line-height: 1.4;
}
.sg::after { content: '›'; color: var(--brand); font-size: 20px; font-weight: 800; }
.ask-chip { border-color: var(--brand); color: var(--brand-deep); }
.sg:active, .ask-chip:active { background: var(--brand-tint); }
.ask { display: flex; flex-direction: column; gap: 8px; }

.msg-user {
  align-self: flex-end; max-width: 85%;
  padding: 12px 18px; border-radius: 18px 18px 6px 18px;
  background: var(--brand); color: #fff; font-size: 16px; white-space: pre-wrap;
}
.msg-ai {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px 18px 18px 6px; padding: 16px 18px;
  font-size: 16px; line-height: 1.78;
}
.msg-ai p + p { margin-top: 10px; }
.msg-ai strong { font-weight: 800; }
.md-h { margin: 14px 0 4px; font-weight: 800; color: var(--brand-deep); }
.md-h:first-child { margin-top: 0; }
.md-li { display: block; position: relative; padding-left: 14px; }
.md-li::before { content: ''; position: absolute; left: 2px; top: .8em; width: 5px; height: 5px;
  border-radius: 50%; background: var(--brand); }
.note { display: block; margin-top: 12px; font-size: 12px; color: var(--soft); }
.drug-ref {
  display: inline; border: 0; border-radius: 7px; padding: 1px 7px; margin: 0 1px;
  background: var(--brand-tint); color: var(--brand-deep);
  font-size: .94em; font-weight: 800; line-height: 1.6;
}
.drug-ref.is-on { background: var(--brand); color: #fff; }
.status { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: var(--soft); }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--brand);
  animation: pulse 1.2s ease-in-out infinite; }
.typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: #B9B4CC;
  animation: pulse 1.2s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
.err { padding: 12px 14px; border-radius: 12px; background: var(--emg-bg); color: var(--emg);
  font-size: 15px; font-weight: 700; }

.composer {
  flex: none; background: var(--surface); border-top: 1px solid var(--line);
  padding: 12px var(--pad) calc(6px + env(safe-area-inset-bottom));
}
.composer-row { max-width: var(--feed-max); margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
  flex: 1; min-width: 0; min-height: 52px; max-height: 140px; resize: none;
  padding: 14px 20px; border: 1px solid var(--line); border-radius: 26px;
  background: var(--ground); color: var(--ink);
  font: inherit; font-size: 16px; line-height: 1.45;   /* 16px 미만이면 iOS 가 확대한다 */
}
.composer textarea:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.send {
  flex: none; width: 52px; height: 52px; border: 0; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 22px; font-weight: 800;
}
.send:disabled { opacity: .35; cursor: default; }
/* 홈페이지 맨 아래 안내 줄처럼 — 읽히되 앞서지 않게. 로고는 넣지 않는다 */
.foot-note {
  margin: 8px auto 0; max-width: 640px; text-align: center;
  font-size: 11px; line-height: 1.6; letter-spacing: .01em; color: #9A98A6;
}
.foot-note sup { font-size: .8em; vertical-align: super; }
.badge-hosp { background: var(--ground); color: var(--soft); font-size: 12px; font-weight: 700; }
.nick-age { font-size: .82em; font-weight: 700; color: var(--soft); }
.side-who b .nick-age { font-size: 12px; }

/* ── ④ 약 상세 — 폰에서는 아래에서 올라오는 시트 ──────────────────────── */
.detail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  max-height: 86vh; max-height: 86dvh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 30px rgba(23, 23, 31, .12);
  transform: translateY(100%); visibility: hidden;
  transition: transform .25s ease, visibility 0s linear .25s;
}
.detail.is-open { transform: none; visibility: visible; transition: transform .25s ease; }
.detail-grip { flex: none; width: 44px; height: 5px; margin: 10px auto 0; border-radius: 3px; background: var(--line); }
.detail-top { flex: none; display: flex; justify-content: flex-end; padding: 2px 8px 0; }
.dt-x { width: 48px; height: 48px; border: 0; background: none; font-size: 18px; color: var(--soft); }
.detail-body { flex: 1; overflow-y: auto; padding: 0 var(--pad) 12px; }
.detail-foot { flex: none; padding: 10px var(--pad) calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(23, 23, 31, .45); }

.dt-head { display: flex; gap: 16px; align-items: center; }
.dt-photo {
  flex: none; width: 104px; height: 80px; overflow: hidden;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 14px; background: var(--ground);
  font-size: 11px; color: var(--soft);
}
.dt-photo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.dt-name { font-size: 20px; font-weight: 800; line-height: 1.3; }
.dt-ingr { margin-top: 4px; font-size: 13px; color: var(--soft); }
.dt-mine { margin-top: 18px; padding: 14px 16px; border-radius: 12px; background: var(--brand-tint); }
.dt-mine-label { font-size: 13px; font-weight: 800; color: var(--brand-deep); }
.dt-mine-val { margin-top: 2px; font-size: 17px; font-weight: 800; color: var(--brand-deep); }
.acc { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.acc > button {
  width: 100%; min-height: var(--touch); padding: 0 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border: 0; background: var(--surface); text-align: left; font-size: 16px; font-weight: 800;
}
.acc > button::after { content: '⌄'; color: var(--brand); font-size: 18px; line-height: 1; }
.acc.is-open > button::after { content: '⌃'; }
.acc-body {
  display: none; padding: 12px 18px 16px; background: var(--ground);
  font-size: 15px; line-height: 1.75; white-space: pre-line;
}
.acc.is-open .acc-body { display: block; }
.dt-note, .dt-none, .dt-loading { margin-top: 16px; font-size: 13px; color: var(--soft); }

/* ── ⑤ 꼭 읽어주세요 ──────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(23, 23, 31, .5);
}
.modal-box {
  width: 100%; max-width: 480px; max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 22px 22px 0 0;
}
.modal-body { overflow-y: auto; padding: 28px var(--pad) 12px; }
.modal-foot { flex: none; padding: 12px var(--pad) calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.dc { font-size: 15px; line-height: 1.78; }
.dc h2 { margin: 0; font-size: 23px; font-weight: 800; }
.dc .dc-lead { margin: 6px 0 4px; color: var(--soft); }
.dc h3 { margin: 22px 0 6px; font-size: 15px; font-weight: 800; color: var(--brand-deep); }
.dc ul { margin: 0; padding-left: 18px; }
.dc li { margin-bottom: 4px; }
.dc li::marker { color: var(--brand); }
.dc-box { margin: 18px 0 0; padding: 13px 16px; border-radius: 12px; }
.dc-warn { background: var(--brand-tint); color: var(--brand-deep); }
.dc-emg { background: var(--emg-bg); }
.dc-emg b:first-child { color: var(--emg); }
.dc-fine { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--soft); line-height: 1.65; }

/* 사이드바를 끄는 동안에는 글자가 선택되지 않게 한다 */
body.is-resizing, body.is-resizing * { cursor: col-resize !important; user-select: none !important; }

/* ══ 768px 이상 ════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  :root { --hdr: 64px; --feed-max: 760px; --list-max: 1120px; }
  .hdr { grid-template-columns: auto 1fr auto; padding: 0 12px; }
  .hdr-title { text-align: left; font-size: 19px; padding-left: 4px; }
  .hdr-btn.is-hidden { display: none; }
  .hdr-info { padding: 0 16px; font-size: 14px; font-weight: 700; gap: 6px; display: flex; align-items: center; }
  .hdr-info-txt { display: inline; }
  .pc-only { display: inline; }
  .br-m { display: none; }

  /* 처방 선택 — 양옆 32px 는 항상 남긴다 (폴드 펼침 882px 에서 화면 끝에 붙던 버그).
     맨 위 처방은 한 줄 전체, 나머지는 2열 (1200 부터 3열, 1600 부터 4열) */
  .list-hero, .list-wrap, .list-foot { width: min(var(--list-max), calc(100% - 64px)); margin: 0 auto; }
  .list-hero { padding: 40px 0 8px; }
  .v-list .h1 { font-size: 28px; }
  .list-wrap { padding: 12px 0 28px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .list-wrap > .month, .list-wrap > .rx.is-feature, .list-wrap > .empty { grid-column: 1 / -1; }
  .month { margin: 10px 0 -6px; }
  .rx { padding: 20px 52px 20px 22px; }
  .rx.is-feature {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 24px;
    padding: 24px;
  }
  .rx.is-feature .rx-go { display: none; }
  .rx-cta {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 196px; min-height: 60px; padding: 0 24px; border-radius: var(--r-btn);
    background: var(--brand); color: #fff; font-size: 18px; font-weight: 800;
  }
  .rx.is-feature:hover .rx-cta { background: var(--brand-deep); }
  .rx-date { font-size: 18px; }
  .rx.is-feature .rx-date { font-size: 20px; }
  .rx-sub { font-size: 14px; }

  /* 대화 — 왼쪽 목록 (끌어서 너비 조절) */
  .side {
    display: flex; flex-direction: column; flex: none; width: var(--side-w, 300px);
    padding: 20px 16px; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--line);
  }
  .side-label { margin: 6px 8px 8px; font-size: 13px; font-weight: 800; color: var(--soft); }
  #sideRx + .side-label { margin-top: 26px; }
  .side-rx {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 12px; background: var(--brand-tint);
  }
  .side-rx b { display: block; font-size: 16px; font-weight: 800; color: var(--brand-deep); }
  .side-rx span { font-size: 12px; color: var(--soft); }
  .med {
    width: 100%; min-height: 60px; padding: 10px 12px; margin-bottom: 4px;
    display: flex; align-items: center; gap: 12px; text-align: left;
    border: 0; border-radius: 12px; background: none;
  }
  .med:hover { background: var(--ground); }
  .med.is-on { background: var(--brand-tint); }
  .med-thumb {
    flex: none; width: 44px; height: 44px; border-radius: 10px;
    border: 1px solid var(--line); background: #fff center / contain no-repeat;
  }
  .med-txt { min-width: 0; }
  .med-txt b { display: block; font-size: 14px; font-weight: 800; line-height: 1.35; }
  .med.is-on .med-txt b { color: var(--brand-deep); }
  .med-txt span { font-size: 12px; color: var(--soft); }
  /* 카드 자체는 PC 에서도 보인다 — 제목(«받으신 약 N가지»)이 이 안에 있다.
     약 이름 칩만 감춘다. 그건 왼쪽 목록이 이미 보여준다 */
  .start-rx .chips { display: none; }
  .feed { padding: 32px; }
  .feed-in { gap: 16px; }
  .start .h1 { font-size: 26px; }
  /* 시작 화면은 PC 에서 가운데로 모은다 — 넓은 대화 칸 왼쪽에 붙어 있으면 휑하다 */
  .start { align-items: center; text-align: center; padding-top: 6vh; }
  .start .suggest { justify-content: center; }
  .start .btn-primary { max-width: 360px; }   /* 대화 폭 전체로 늘어나면 버튼이 아니라 띠처럼 보인다 */
  .suggest, .ask-list { flex-direction: row; flex-wrap: wrap; }
  .sg, .ask-chip { min-height: 48px; padding: 10px 20px; border-radius: 24px; font-size: 15px; }
  .sg::after { display: none; }
  .composer { padding: 14px 32px 10px; }

  /* 너비 조절 손잡이 — 테두리 위에 겹쳐 놓아 자리를 차지하지 않는다 */
  .split {
    display: block; flex: none; position: relative; z-index: 3;
    width: 12px; margin: 0 -6px; cursor: col-resize; touch-action: none;
  }
  .split::after {
    content: ''; position: absolute; top: 0; bottom: 0; left: 5px; width: 2px;
    background: transparent; transition: background .15s;
  }
  .split::before {                          /* 손잡이가 있다는 표시 */
    content: ''; position: absolute; left: 3px; top: 50%; width: 6px; height: 40px;
    margin-top: -20px; border-radius: 3px; background: var(--line); transition: background .15s;
  }
  .split:hover::after, .split:focus-visible::after, .split.is-drag::after { background: var(--brand); }
  .split:hover::before, .split:focus-visible::before, .split.is-drag::before { background: var(--brand); }
  .split:focus-visible { outline: none; }
  .split-detail { position: absolute; top: 0; bottom: 0; left: -6px; margin: 0; }

  /* 약 상세 — 오른쪽에서 밀려 나오는 서랍 (끌어서 너비 조절) */
  .detail {
    top: var(--hdr); left: auto; width: var(--detail-w, 380px); max-height: none;
    border-radius: 0; border-left: 1px solid var(--line);
    box-shadow: -8px 0 30px rgba(23, 23, 31, .10);
    transform: translateX(100%);
  }
  .detail-grip, .detail-foot { display: none; }
  .detail-top { padding-top: 10px; }
  .detail-body { padding: 0 24px 24px; }
  .dt-photo { width: 120px; height: 92px; }

  .modal { align-items: center; }
  .modal-box { border-radius: 22px; }
}

/* ══ 1200px 이상 — 세 칸 ════════════════════════════════════════════════ */
@media (min-width: 1200px) {
  .list-wrap { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail {
    position: relative; z-index: auto; width: var(--detail-w, 380px); flex: none;
    inset: auto;   /* 서랍용 top: 64px 이 relative 에서는 «64px 아래로 밀기» 가 된다 — 실측으로 잡은 버그 */
    transform: none; visibility: visible; box-shadow: none; transition: none;
    display: none;
  }
  .detail.is-open { display: flex; }
  .scrim { display: none !important; }
}

/* ══ 1600px 이상 — 넓은 모니터 ═════════════════════════════════════════ */
@media (min-width: 1600px) {
  :root { --feed-max: 880px; --list-max: 1360px; }
  .list-wrap { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── 샘플 환자 카드 꼬리표 ─────────────────────────────────────────────── */
.tag {
  flex: none; padding: 2px 9px; border-radius: 8px;
  background: var(--caution-bg); color: var(--caution);
  font-size: 12px; font-weight: 800;
}
.chip-more { background: var(--ground); color: var(--soft); }

/* ── 생활습관 ──────────────────────────────────────────────────────────
   명세에 없는 값이라 환자가 직접 넣는다. 자유 입력 대신 고르게 한다 —
   고령 사용자가 많고, 자유 입력은 뒤에서 쓰기도 어렵다. */
.btn-life {
  width: 100%; min-height: var(--touch); border: 1px dashed var(--brand);
  border-radius: var(--r-btn); background: var(--surface);
  color: var(--brand-deep); font-size: 16px; font-weight: 800;
}
.btn-life.is-filled { border-style: solid; background: var(--brand-tint); }
.lf-title { margin: 0; font-size: 23px; font-weight: 800; }
.lf-lead { margin: 8px 0 18px; font-size: 15px; line-height: 1.7; color: var(--soft); }
.lf { border: 0; margin: 0 0 22px; padding: 0; }
.lf-q { padding: 0; margin-bottom: 10px; font-size: 16px; font-weight: 800; }
.lf-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.lf-opt {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 24px; background: var(--surface);
  font-size: 15px; cursor: pointer;
}
.lf-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.lf-opt.is-on { border-color: var(--brand); background: var(--brand-tint);
  color: var(--brand-deep); font-weight: 800; }
.lf-opt:focus-within { outline: 3px solid var(--brand); outline-offset: 2px; }
.lf-foot { display: flex; gap: 10px; }
.lf-foot .btn-ghost { width: 40%; }

/* ── 아바타와 별명 ─────────────────────────────────────────────────────
   명세에 이름이 없다. 별명으로 부르고, 얼굴은 나이대·성별 아바타로 대신한다. */
.avatar {
  flex: none; display: grid; place-items: center; overflow: hidden;
  border-radius: 50%; background: var(--brand-tint);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* 성별을 모를 때 — 사진 대신 그린 중성 프로필. 배경이 브랜드 연보라라서
   같은 계열 색으로 올려야 기존 아바타 사진들과 따로 놀지 않는다. */
.avatar-none svg { width: 72%; height: 72%; fill: var(--brand); opacity: .34; }
.avatar-sm { width: 44px; height: 44px; }
.avatar-md { width: 56px; height: 56px; }
.avatar-lg { width: 88px; height: 88px; }
.rx-who { display: flex; align-items: center; gap: 14px; }
.rx-who .rx-main { flex: 1; min-width: 0; }
.start-who { display: flex; flex-direction: column; }
.start-who .nick { margin: 12px 0 2px; font-size: 20px; font-weight: 800; color: var(--brand-deep); }
.side-who { flex: 1; min-width: 0; }
.side-who b { display: block; font-size: 15px; font-weight: 800; color: var(--brand-deep); }
.side-who span { font-size: 12px; color: var(--soft); }

@media (min-width: 768px) {
  .start-who { align-items: center; }
}

/* 시작 화면은 PC 에서 가운데로 모으지만, 처방 카드 안의 글은 왼쪽으로 읽는다.
   병원·처방일·진단명이 한 줄을 다 쓰므로 기본 카드보다 여백을 넉넉히 준다 */
.start-rx { text-align: left; padding: 22px 22px 20px; }
.start-rx .card-head { padding-right: 4px; }

/* 앱에서 넘어와 약 정보를 받아오는 동안, 그리고 못 받았을 때 */
.boot { flex: 1; display: grid; place-content: center; gap: 8px; padding: 0 var(--pad); text-align: center; }
.boot-msg { font-size: 17px; font-weight: 800; }
.boot-sub { font-size: 15px; color: var(--soft); line-height: 1.7; }


/* ── 앱 연동 검수 (샘플 화면 아래) ──────────────────────────────────────
   검수용이라 눈에 덜 띄게 둔다. 실제 환자는 이 화면 자체를 보지 않는다. */
.apptest {
  margin: 28px auto 8px;
  max-width: 560px;
  padding: 16px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}
.apptest-lead {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--soft);
}
.apptest-row { display: flex; gap: 8px; flex-wrap: wrap; }
.apptest-row select {
  flex: 1 1 200px;
  min-width: 0;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.apptest-row .btn-ghost { flex: 0 0 auto; }
.apptest-note {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--emg);
  word-break: break-all;
}

/* 돌려받은 화면을 띄우는 자리. 앱 웹뷰처럼 전체를 덮는다 */
.apptest-frame {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--ground);
  z-index: 70;
}
.apptest-x {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 71;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  color: #fff;
  background: rgba(0, 0, 0, .62);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

/* 생활습관 팝업의 성별 칸 — 병원에서 성별이 안 왔을 때만 뜬다 */
.lf-sex { padding-bottom: 4px; }
.lf-why { margin: 2px 0 10px; font-size: 14px; line-height: 1.6; color: var(--soft); }

/* 검수용 API 키 칸 — 운영에서 키를 걸면 검수 버튼도 이 값을 들고 가야 한다 */
.apptest-row + .apptest-row { margin-top: 8px; }
#appTestKey {
  flex: 1 1 100%;
  min-width: 0;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 10px;
}
