/* Editorial layer for the homepage (/browse) and drug library (/library).
   Loaded after styles.css and theme.css; brings both pages in line with the adverse-effects
   reference: hairline rules instead of boxed cards, serif display, quiet sans body. */

:root {
  --ed-bg: #131314;
  --ed-raise: #1b1b1d;
  --ed-sunk: #0f0f10;
  --ed-lift: #232326;
  --ed-hover: #2c2c30;
  --ed-ink: #ebe8e3;
  --ed-soft: #c9c6c1;
  --ed-muted: #9d9a95;
  --ed-faint: #85827d;
  --ed-rule: rgb(var(--ink-rgb) / 0.1);
  --ed-rule-strong: rgb(var(--ink-rgb) / 0.2);
  --ed-accent: #d9a46c;
  --ed-accent-ink: #1a120a;
  --ed-accent-wash: rgb(var(--accent-rgb) / 0.09);
  --ed-link: #e6b886;
  --ed-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --ed-sans: "Atkinson Hyperlegible Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ================= Homepage ================= */
/* Calm cards: no outlines; areas are separated by tone (bg < sidebar/cards < hover).
   Type sizes come from typography.css tokens; running text kept to ~65ch. */
body.dashboard-page {
  --dashboard-bg: var(--ed-bg);
  --dashboard-surface: var(--ed-raise);
  --dashboard-surface-2: var(--ed-lift);
  --dashboard-border: var(--ed-rule);
  --dashboard-text: var(--ed-ink);
  --dashboard-muted: var(--ed-muted);
  --dashboard-accent: var(--ed-accent);
  --dashboard-accent-soft: var(--ed-accent-wash);
  --dashboard-teal: var(--ed-accent);
  background: var(--ed-bg);
  font-family: var(--ed-sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Sidebar: tonal panel, filled pill for the active item */
body.dashboard-page .dashboard-sidebar { background: var(--ed-raise); border-right: 0; padding: 20px 14px; min-height: 100vh; }
body.dashboard-page .dashboard-sidebar__brand { padding: 4px 8px 20px; border-bottom: 0; margin-bottom: 8px; }
body.browse-page .dashboard-sidebar__brand { text-decoration: none; }
body.dashboard-page .dashboard-brand-name { font-family: var(--ed-serif); font-weight: 500; line-height: 1.15; color: var(--ed-ink); letter-spacing: -0.005em; }
body.dashboard-page .dashboard-brand-name em { color: var(--ed-accent); font-style: italic; }
body.dashboard-page .dashboard-nav-item {
  font-family: var(--ed-sans); font-weight: 500; line-height: 1.3; color: var(--ed-muted);
  border-radius: 8px; background: transparent; padding: 9px 12px; transition: color .15s, background .15s;
}
body.dashboard-page .dashboard-nav-item:hover { color: var(--ed-ink); background: var(--ed-lift); }
body.dashboard-page .dashboard-nav-item.is-active { color: var(--ed-ink); background: var(--ed-lift); }
body.dashboard-page .dashboard-nav-subgroup a { color: var(--ed-muted); }
body.dashboard-page .dashboard-nav-subgroup a:hover { color: var(--ed-ink); }
body.dashboard-page .dashboard-sidebar__footer { border-top: 0; }
body.dashboard-page .dashboard-nav-item--muted { color: var(--ed-faint); }

/* Top bar: only brand (narrow screens) and account; search lives in the hero */
body.dashboard-page .dashboard-topbar { background: rgb(var(--bg-rgb) / 0.88); backdrop-filter: saturate(140%) blur(10px); border-bottom: 0; }
body.browse-page .dashboard-topbar__auth { margin-left: auto; }
body.dashboard-page .dashboard-btn { border-radius: 999px; font-family: var(--ed-sans); font-weight: 600; line-height: 1; }
body.dashboard-page .dashboard-btn--ghost { border: 0; background: var(--ed-lift); color: var(--ed-ink); }
body.dashboard-page .dashboard-btn--ghost:hover { background: var(--ed-hover); }
body.dashboard-page .dashboard-btn--primary { background: var(--ed-accent); color: var(--ed-accent-ink); border: 1px solid var(--ed-accent); }

/* Main column */
body.dashboard-page .dashboard-main { padding-top: calc(var(--dashboard-topbar-height) + clamp(24px, 4vw, 48px)); padding-bottom: 64px; }
body.browse-page .dashboard-main { display: flex; flex-direction: column; gap: clamp(48px, 6vw, 72px); }
body.dashboard-page .home-eyebrow { margin: 0 0 12px; font-family: var(--ed-sans); font-weight: 600; line-height: 1.2; letter-spacing: .14em; text-transform: uppercase; color: var(--ed-muted); }

/* Hero: one headline, one line of intro, one big search */
body.dashboard-page .library-browse { padding: 0; border: 0; max-width: 46rem; }
body.dashboard-page .library-browse h1 { font-family: var(--ed-serif); font-size: var(--fs-display); font-weight: 400; line-height: 1.05; letter-spacing: -0.02em; margin: 0; color: var(--ed-ink); text-wrap: balance; }
body.dashboard-page .library-browse > p:not(.home-eyebrow) { color: var(--ed-soft); margin: 14px 0 0; max-width: 60ch; text-wrap: pretty; }
body.browse-page .browse-search { max-width: none; margin: 28px 0 0; }
body.browse-page .browse-search input {
  min-height: 60px; padding: 0 20px 0 50px; border: 0; border-radius: 14px;
  background: var(--ed-raise); color: var(--ed-ink); font-family: var(--ed-sans); font-size: var(--fs-lead);
}
body.browse-page .browse-search input::placeholder { color: var(--ed-faint); }
body.browse-page .browse-search input:focus { outline: none; box-shadow: 0 0 0 3px var(--ed-accent-wash), 0 0 0 1px var(--ed-accent); }
body.browse-page .browse-search .dashboard-search__icon { left: 20px; width: 17px; height: 17px; }
body.dashboard-page .dashboard-search__results { background: var(--ed-raise); border: 0; border-radius: 14px; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45); }
body.dashboard-page .dashboard-search__results a:hover { background: var(--ed-lift); }
body.dashboard-page .dashboard-result-class { color: var(--ed-faint); }

/* Sections: heading on the left, "All ..." link on the right */
body.browse-page .browse-section { display: flex; flex-direction: column; gap: 20px; }
body.browse-page .browse-section__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; }
body.browse-page .browse-section__head h2 { font-family: var(--ed-serif); font-size: var(--fs-h2); font-weight: 400; line-height: var(--lh-heading); letter-spacing: -0.01em; margin: 0; color: var(--ed-ink); text-wrap: balance; }
body.browse-page .browse-section__head p { margin: 6px 0 0; color: var(--ed-muted); font-size: var(--fs-sm); }
body.browse-page .browse-all { color: var(--ed-accent); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
body.browse-page .browse-all:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Card grid */
body.browse-page .browse-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
body.browse-page .browse-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
body.browse-page .browse-card {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 18px 20px 20px; border-radius: 14px; background: var(--ed-raise);
  transition: background .15s;
}
body.browse-page .browse-card:hover { background: var(--ed-lift); }
body.browse-page .browse-card:hover .browse-card__title { color: var(--ed-accent); }
body.browse-page .browse-card__title { font-family: var(--ed-serif); font-size: var(--fs-h3); font-weight: 400; line-height: 1.3; color: var(--ed-ink); text-wrap: balance; transition: color .15s; }
body.browse-page .browse-card__sub { color: var(--ed-muted); font-size: var(--fs-sm); line-height: 1.5; text-wrap: pretty; }
body.browse-page .browse-card__count { margin-top: auto; padding-top: 6px; color: var(--ed-faint); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-variant-numeric: tabular-nums; }

/* About and footer: quiet text, no boxes */
body.dashboard-page .dashboard-about { margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; }
body.dashboard-page .dashboard-about h2 { font-family: var(--ed-serif); font-weight: 400; color: var(--ed-ink); margin: 0 0 8px; }
body.dashboard-page .dashboard-about p { color: var(--ed-muted); max-width: 62ch; }
body.dashboard-page .dashboard-footer { border-top: 0; color: var(--ed-faint); }
body.dashboard-page .dashboard-footer p { max-width: 75ch; }

@media (max-width: 1100px) {
  body.browse-page .browse-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  body.browse-page .browse-grid,
  body.browse-page .browse-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  body.browse-page .browse-grid,
  body.browse-page .browse-grid--4 { grid-template-columns: minmax(0, 1fr); }
  body.browse-page .browse-search input { min-height: 52px; }
}

/* ================= Drug library ================= */
body.library-page {
  background: var(--ed-bg);
  color: var(--ed-ink);
  font-family: var(--ed-sans);
  font-size: 16px;
}

body.library-page .topbar {
  padding: 0 clamp(16px, 4vw, 48px); height: 60px; gap: 24px;
  background: rgb(var(--bg-rgb) / 0.88); backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--ed-rule);
}
body.library-page .brand { gap: 10px; }
body.library-page .brand-logo { width: 30px; height: 30px; }
body.library-page .brand-name { font: 500 18px/1 var(--ed-serif); color: var(--ed-ink); letter-spacing: -0.005em; white-space: nowrap; }
body.library-page .brand-name em { color: var(--ed-accent); font-style: italic; }
body.library-page .topbar-nav { display: flex; gap: 4px; margin-right: auto; margin-left: 12px; overflow-x: auto; scrollbar-width: none; }
body.library-page .topbar-nav::-webkit-scrollbar { display: none; }
body.library-page .topbar-nav a { color: var(--ed-muted); text-decoration: none; font-size: 14px; padding: 8px 12px; border-radius: 999px; white-space: nowrap; transition: color .15s; }
body.library-page .topbar-nav a:hover { color: var(--ed-ink); }
body.library-page .topbar-nav a[aria-current="page"] { color: var(--ed-ink); background: var(--ed-raise); box-shadow: inset 0 0 0 1px var(--ed-rule); }
body.library-page .topbar-actions { display: flex; align-items: center; gap: 14px; }
body.library-page .session-identity { color: var(--ed-muted); font-size: 13.5px; text-decoration: none; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.library-page .session-identity:hover { color: var(--ed-ink); }
body.library-page .secondary-button {
  min-height: 0; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--ed-rule-strong);
  background: transparent; color: var(--ed-ink); font: 600 13.5px/1 var(--ed-sans); box-shadow: none;
}
body.library-page .secondary-button:hover { border-color: var(--ed-accent); }

body.library-page main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 40px clamp(16px, 4vw, 48px) 80px; }
body.library-page .workspace { grid-template-columns: 240px minmax(0, 1fr); gap: 56px; }

/* Selector rail: no card, labelled fields */
body.library-page .library-panel { position: sticky; top: 88px; border: 0; background: transparent; box-shadow: none; overflow: visible; }
body.library-page .toolbar { padding: 0; background: none; display: grid; gap: 20px; }
body.library-page .select-block { margin: 0; }
body.library-page .select-block span { font: 600 11px/1 var(--ed-sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ed-faint); margin-bottom: 9px; }
body.library-page select,
body.library-page textarea {
  background: var(--ed-raise); border: 1px solid var(--ed-rule-strong); border-radius: 10px;
  color: var(--ed-ink); font: 400 15px/1.4 var(--ed-sans);
}
body.library-page select:focus,
body.library-page textarea:focus { outline: none; border-color: var(--ed-accent); box-shadow: 0 0 0 4px var(--ed-accent-wash); }

/* Drug detail */
body.library-page .detail-panel { min-height: 0; border: 0; background: transparent; box-shadow: none; overflow: visible; }
body.library-page .detail-hero { padding: 0 0 8px; background: none; border: 0; display: block; }
body.library-page .eyebrow { font: 600 12px/1.2 var(--ed-sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ed-muted); margin: 0 0 12px; }
body.library-page .detail-title { font: 400 clamp(40px, 6vw, 72px)/1.02 var(--ed-serif); letter-spacing: -0.025em; margin: 0; color: var(--ed-ink); }
body.library-page .dose-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 26px 0 0; border-top: 1px solid var(--ed-rule-strong); border-bottom: 1px solid var(--ed-rule-strong); }
body.library-page .dose-strip > div { padding: 14px 20px 14px 0; }
body.library-page .dose-strip > div + div { padding-left: 20px; border-left: 1px solid var(--ed-rule); }
body.library-page .dose-strip dt { font: 600 11px/1 var(--ed-sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ed-faint); margin-bottom: 8px; }
body.library-page .dose-strip dd { margin: 0; font-size: 15px; color: var(--ed-soft); line-height: 1.5; }

body.library-page .detail-grid { display: block; padding: 0; }
body.library-page .info-section {
  min-height: 0; padding: 40px 0; border: 0; border-bottom: 1px solid var(--ed-rule);
  border-radius: 0; background: transparent; box-shadow: none; scroll-margin-top: 84px;
}
body.library-page .info-section h2 { font: 400 clamp(26px, 2.8vw, 32px)/1.15 var(--ed-serif); letter-spacing: -0.012em; color: var(--ed-ink); margin: 0 0 18px; }
body.library-page .section-subheading { font: 600 15px/1.35 var(--ed-sans); color: var(--ed-ink); margin: 26px 0 10px; letter-spacing: 0; }
body.library-page .info-section p,
body.library-page .info-section li { color: var(--ed-soft); font-size: 16px; line-height: 1.65; max-width: 74ch; }
body.library-page .info-section strong { color: var(--ed-ink); }
body.library-page .section-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 4px; }
body.library-page .section-list li { position: relative; padding-left: 20px; }
body.library-page .section-list li::before { content: ""; position: absolute; left: 3px; top: .72em; width: 5px; height: 5px; border-radius: 50%; background: var(--ed-faint); }
body.library-page .section-list li.indent-1 { margin-left: 22px; }
body.library-page .section-list li.indent-2 { margin-left: 44px; }
body.library-page .section-list li.indent-3 { margin-left: 66px; }
body.library-page .section-list li.indent-1::before,
body.library-page .section-list li.indent-2::before,
body.library-page .section-list li.indent-3::before { background: transparent; box-shadow: inset 0 0 0 1px var(--ed-muted); }
body.library-page .dose-grid { gap: 0; margin: 0 0 18px; border-top: 1px solid var(--ed-rule-strong); border-bottom: 1px solid var(--ed-rule-strong); }
body.library-page .dose-grid div { padding: 14px 20px 14px 0; border: 0; border-radius: 0; background: transparent; }
body.library-page .dose-grid div + div { padding-left: 20px; border-left: 1px solid var(--ed-rule); }
body.library-page .dose-grid strong { font: 600 11px/1 var(--ed-sans); letter-spacing: .14em; color: var(--ed-faint); margin-bottom: 8px; }
body.library-page .empty-state { padding: 48px 0; color: var(--ed-muted); font: 300 20px/1.5 var(--ed-serif); border: 0; background: none; }

/* Ask My Notes */
body.library-page .notebook-search-panel { margin-top: 64px; padding: 40px 0 0; border: 0; border-top: 1px solid var(--ed-rule-strong); border-radius: 0; background: transparent; box-shadow: none; }
body.library-page .notebook-search-header h2 { font: 400 30px/1.15 var(--ed-serif); color: var(--ed-ink); margin: 0; }
body.library-page .notebook-search-header p { color: var(--ed-muted); }
body.library-page .primary-button { border-radius: 999px; background: var(--ed-accent); color: var(--ed-accent-ink); border: 1px solid var(--ed-accent); font: 600 14px/1 var(--ed-sans); padding: 13px 22px; box-shadow: none; }
body.library-page .notebook-answer { border: 0; border-left: 2px solid var(--ed-rule-strong); border-radius: 0; background: var(--ed-raise); }
body.library-page .site-footer { border-top: 1px solid var(--ed-rule); color: var(--ed-faint); font-size: 13px; text-align: center; padding: 28px 16px 40px; background: transparent; }

@media (max-width: 1023px) {
  body.browse-page .dashboard-sidebar {
    position: relative;
    inset: auto;
    width: 100%;
    min-height: 0;
    margin-top: var(--dashboard-topbar-height);
    transform: none;
    border-right: 0;
  }
  body.browse-page .dashboard-sidebar__brand { display: none; }
  body.browse-page .dashboard-sidebar__nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
  body.browse-page .dashboard-sidebar__footer {
    flex-direction: row;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 8px;
  }
  body.browse-page .dashboard-main { padding-top: 32px; }
}

@media (max-width: 900px) {
  body.library-page .workspace { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  body.library-page .library-panel { position: static; }
  body.library-page .toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  body.library-page .session-identity { display: none; }
}
@media (max-width: 640px) {
  body.library-page .topbar { height: auto; padding-top: 10px; padding-bottom: 10px; flex-direction: row; align-items: center; flex-wrap: wrap; row-gap: 6px; }
  body.library-page .topbar-nav { order: 3; width: 100%; margin: 0; }
  body.library-page .brand { width: auto; }
  body.library-page .topbar-actions { width: auto; margin-left: auto; }
  body.library-page .topbar-actions > * { flex: 0 0 auto; }
  body.library-page .toolbar { grid-template-columns: minmax(0, 1fr); }
  body.library-page .dose-strip { grid-template-columns: minmax(0, 1fr); }
  body.library-page .dose-strip > div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--ed-rule); }
  body.library-page .info-section { padding: 30px 0; }
  body.library-page .section-list li.indent-2,
  body.library-page .section-list li.indent-3 { margin-left: 34px; }
}
