/* ============================================
   Reasoning GP — Ready Prescription Tool styles
   ============================================ */

.rx{
  background: transparent;
  margin: 4px 0 18px;
}

/* Toolbar — sits transparently on the page (matches the Casebook controls) */
.rx-toolbar{
  padding: 0 0 4px;
  background: transparent;
  border-bottom: none;
  display: flex; flex-direction: column; gap: 10px;
}
/* GPatlas-style toolbar row: filters toggle + search + sort */
.rx-toolbar.dir-toolbar{
  flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap;
}
.rx-toolbar.dir-toolbar .rx-search-wrap{ flex: 1; min-width: 220px; margin: 0; }
.rx-toolbar.dir-toolbar .dir-sort{ flex-shrink: 0; }
.rx-search-wrap{
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px;
  transition: border-color .15s ease;
}
.rx-search-wrap:focus-within{ border-color: var(--teal-3); }
.rx-search-ic{ width: 16px; height: 16px; color: var(--muted-2); flex-shrink: 0; }
.rx-search{
  flex: 1; font-family: inherit; font-size: 14px; color: var(--ink);
  background: transparent; border: none; outline: none;
}
.rx-search::placeholder{ color: var(--muted-2); }
.rx-count{ font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.rx-count b{ color: var(--ink); }

.rx-cats{ display: flex; flex-wrap: wrap; gap: 6px; }
.rx-cat{
  font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 11px; border-radius: 99px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
  cursor: pointer; transition: .15s ease;
}
.rx-cat:hover{ border-color: var(--rust); color: var(--rust); }
.rx-cat.active{ background: var(--rust); color: #fff; border-color: var(--rust); }

/* Card grid */
.rx-grid{
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px; padding: 0;
}

/* ---- FLIP CARD ---- */
.rx-flip{
  perspective: 1200px;
  height: 215px;
}
.rx-flip-inner{
  position: relative; width: 100%; height: 100%;
  transition: transform .55s cubic-bezier(.4,.2,.2,1);
  transform-style: preserve-3d;
}
.rx-flip.is-flipped .rx-flip-inner{ transform: rotateY(180deg); }
.rx-face{
  position: absolute; inset: 0;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); overflow: hidden;
  display: flex; flex-direction: column;
}

/* Front */
.rx-face-front{
  width: 100%; text-align: center; cursor: pointer;
  font-family: inherit; color: inherit;
  align-items: center; justify-content: center; gap: 4px;
  padding: 20px 18px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.rx-face-front:hover{ border-color: var(--rust); box-shadow: var(--shadow-2); }
.rx-front-ic{
  line-height: 1; margin-bottom: 8px;
  width: 56px; height: 56px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c, var(--teal)) 14%, #fff);
  border-radius: 50%; color: var(--c, var(--teal));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, var(--teal)) 22%, transparent);
}
.rx-front-ic svg{ width: 32px; height: 32px; }
.rx-front-hint{
  margin-top: auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; color: var(--rust);
}
.rx-front-hint svg{ width: 13px; height: 13px; }

/* Back */
.rx-face-back{
  transform: rotateY(180deg);
  background: var(--surface-2);
  padding: 13px 14px; gap: 8px;
}
.rx-back-head{ display: flex; align-items: center; justify-content: space-between; }
.rx-back-label{
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--teal);
}
.rx-back-flip{
  width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--muted); cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0; transition: .15s ease;
}
.rx-back-flip:hover{ border-color: var(--rust); color: var(--rust); }
.rx-back-flip svg{ width: 13px; height: 13px; }
.rx-back-drugs{
  list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 5px;
}
.rx-back-drugs li{
  font-size: 12px; color: var(--ink-2); line-height: 1.35;
  display: flex; flex-direction: column;
  border-left: 2px solid var(--teal-3); padding: 1px 0 1px 8px;
}
.rx-back-drugs li b{ color: var(--ink); font-weight: 700; font-size: 12.5px; }
.rx-back-drugs li span{ color: var(--muted); }
.rx-back-drugs li.rx-more{ border-left-color: transparent; font-style: italic; color: var(--muted); }
.rx-back-course{
  font-size: 11.5px; color: var(--ink-2); background: var(--bg-soft);
  padding: 4px 8px; border-radius: 6px;
}
.rx-back-course b{ color: var(--teal); font-weight: 700; }
.rx-back-more{
  font-family: inherit; font-size: 12.5px; font-weight: 700;
  background: var(--rust); color: #fff; border: none; border-radius: 8px;
  padding: 8px; cursor: pointer; transition: background .15s ease;
}
.rx-back-more:hover{ background: var(--rust-2, var(--teal)); }

/* ---- OPEN (expanded) CARD ---- */
.rx-card{
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.rx-card.is-open{
  grid-column: 1 / -1;
  border-color: var(--rust);
  box-shadow: var(--shadow-2);
}
.rx-open-head{
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 12px;
}
.rx-open-ic{
  line-height: 1; flex-shrink: 0;
  width: 44px; height: 44px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c, var(--teal)) 14%, #fff);
  border-radius: 50%; color: var(--c, var(--teal));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, var(--teal)) 22%, transparent);
}
.rx-open-ic svg{ width: 25px; height: 25px; }
.rx-open-titles{ min-width: 0; }
.rx-card-title{
  font-family: 'Source Serif 4', serif; font-weight: 500;
  font-size: 17px; line-height: 1.2; color: var(--ink); margin: 0 0 3px 0;
}
.rx-card-eyebrow{
  font-size: 12px; color: var(--teal); font-weight: 600;
}

/* Detail panel */
.rx-detail{
  padding: 0 16px 18px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.rx-section{ padding: 14px 0; border-bottom: 1px solid var(--line); }
.rx-section:last-of-type{ border-bottom: none; }
.rx-section h4{
  font-size: 11.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-2);
  margin: 0 0 8px 0; display: flex; align-items: center; gap: 6px;
}
.rx-section p{ font-size: 13.5px; color: var(--ink-2); line-height: 1.55; margin: 0; }
.rx-section-warn h4{ color: #b45309; }
.rx-section-warn p{ background: #fffbeb; border-left: 3px solid #fde68a; padding: 8px 12px; border-radius: 6px; }
.rx-section-red h4{ color: var(--rust-2); }
.rx-section-red .rx-list li{ background: #fef4f2; border-left: 3px solid #fecaca; }

/* Drug table */
.rx-drugs-wrap{ overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.rx-drugs{
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.rx-drugs thead th{
  background: var(--bg-soft); color: var(--muted);
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line);
}
.rx-drugs td{
  padding: 8px 10px; border-bottom: 1px solid var(--line);
  vertical-align: top; line-height: 1.4; color: var(--ink-2);
}
.rx-drugs tr:last-child td{ border-bottom: none; }
.rx-drugs td b{ color: var(--ink); font-weight: 700; }
.rx-duration{
  margin-top: 8px; font-size: 12.5px; color: var(--ink-2);
  background: var(--bg-soft); padding: 6px 10px; border-radius: 6px;
}
.rx-duration b{ color: var(--teal); font-weight: 700; }

/* Alt regimens */
.rx-alts{ display: flex; flex-direction: column; gap: 6px; }
.rx-alt{
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px;
}
.rx-alt-l{
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--teal); margin-bottom: 3px;
}
.rx-alt-r{ font-size: 13px; color: var(--ink-2); line-height: 1.5; }

/* Lists */
.rx-list{
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 5px;
}
.rx-list li{
  font-size: 13px; color: var(--ink-2); line-height: 1.5;
  padding: 7px 10px; border-radius: 6px;
  background: var(--bg-soft); border-left: 3px solid var(--teal-3);
}

/* EMIS text */
.rx-section-emis h4{ color: var(--teal); }
.rx-emis-wrap{ position: relative; }
.rx-emis-text{
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.55; color: var(--ink);
  background: #1f2937; color: #f1f5f9;
  border-radius: 8px; padding: 12px 14px; padding-right: 80px;
  white-space: pre-wrap; word-break: break-word;
  margin: 0;
}
.rx-copy-btn{
  position: absolute; top: 8px; right: 8px;
  font-family: inherit; font-size: 11.5px; font-weight: 600;
  background: var(--teal); color: #f6f2e9; border: none;
  padding: 5px 10px; border-radius: 6px; cursor: pointer;
  transition: background .15s ease;
}
.rx-copy-btn:hover{ background: var(--teal-2); }

/* Sources */
.rx-sources{ display: flex; flex-wrap: wrap; gap: 8px; }
.rx-sources a{
  font-size: 12px; color: var(--teal-2); font-weight: 600; text-decoration: none;
}
.rx-sources a:hover{ color: var(--rust); text-decoration: underline; }

/* Foot */
.rx-detail-foot{ padding-top: 12px; text-align: right; }
.rx-close-btn{
  font-family: inherit; font-size: 12px; font-weight: 600;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 12px; cursor: pointer; transition: .15s ease;
}
.rx-close-btn:hover{ background: var(--bg-soft); color: var(--ink); }

/* Empty state */
.rx-empty{
  padding: 40px 20px; text-align: center; color: var(--muted);
  font-size: 13.5px; line-height: 1.55;
}
.rx-empty[hidden]{ display: none; }
.rx-empty-ic{ font-size: 32px; display: block; margin-bottom: 10px; opacity: .6; }
.rx-empty b{ color: var(--ink-2); }
