/* JDrugsSearch design system — academic ⇄ elite.
   Spectral (serif display) + Inter (sans body).
   Warm paper, near-black ink, a single deep-emerald accent, restrained gold highlight.
   See docs/DESIGN.md. */

:root {
  /* Palette */
  --paper:      #fbfaf7;   /* warm off-white background */
  --paper-2:    #f3f1ea;   /* sunken surface */
  --card:       #ffffff;
  --ink:        #1a1714;   /* near-black, warm */
  --ink-soft:   #4a443d;
  --muted:      #837a6e;
  --line:       #e6e1d6;   /* hairline borders */
  --accent:     #0f5132;   /* deep emerald */
  --accent-2:   #157347;
  --accent-ink: #0a3622;
  --gold:       #9a7b2e;   /* scholarly highlight */
  --danger:     #9b2226;
  --ok:         #2d6a4f;
  --warn:       #9a6700;

  /* Type */
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  /* Inter lacks Arabic glyphs → browser falls through to Noto Sans Arabic for Arabic text. */
  --sans:  "Inter", "Noto Sans Arabic", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;

  /* Geometry */
  --wrap: 1100px;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(26,23,20,.05), 0 4px 16px rgba(26,23,20,.05);
  --shadow-lg: 0 8px 40px rgba(26,23,20,.10);
  --space: 1rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  font-size: 16px;
  overflow-wrap: break-word;       /* never let a long token blow out the layout */
  display: flex;                   /* sticky footer: header/announce/main/footer stack, */
  flex-direction: column;          /* main grows to push the footer to the bottom */
  min-height: 100vh;
}

img, svg, video { max-width: 100%; height: auto; }
code { overflow-wrap: anywhere; }

/* Fluid headings so they scale from phone to desktop. */
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.2; color: var(--ink); letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); margin: 0 0 .5rem; }
h2 { font-size: clamp(1.3rem, 4vw, 1.5rem); margin: 2rem 0 .75rem; }
h3 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }

p { margin: 0 0 1rem; }
.muted { color: var(--muted); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }

/* --- Header ----------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 200;
  background: rgba(251,250,247,.97);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 1.5rem; height: 64px; }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); font-weight: 600; flex: 1; }
.brand:hover { text-decoration: none; }
.brand-mark {
  font-family: var(--serif); font-size: 1.5rem; color: var(--accent);
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1.5px solid var(--accent); border-radius: 9px; line-height: 1;
}
.brand-name { font-family: var(--serif); font-size: 1.25rem; letter-spacing: -0.01em; }
.site-nav { display: flex; align-items: center; gap: 1.5rem; flex: 0 0 auto; }
.nav-toggle { display: none; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  font-size: 1.25rem; line-height: 1; padding: .3rem .55rem; cursor: pointer; color: var(--ink); }
.site-nav a { color: var(--ink-soft); font-weight: 500; font-size: .95rem; padding: .35rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--ink); text-decoration: none; }
.site-nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; flex: 1; }

/* Nav dropdowns */
.nav-group { position: relative; display: inline-flex; align-items: center; }
.nav-top { display: inline-flex; align-items: center; gap: .28rem; line-height: 1.5;
  color: var(--ink-soft); font-weight: 500; font-size: .95rem; padding: .35rem 0; border-bottom: 2px solid transparent; }
.nav-top:hover { color: var(--ink); text-decoration: none; }
.nav-top.active { color: var(--accent); border-bottom-color: var(--accent); }
.caret { font-size: .65rem; color: var(--muted); }
.submenu { position: absolute; top: 100%; inset-inline-start: 0; min-width: 210px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: .35rem; display: none; z-index: 60; }
.nav-group:hover .submenu, .nav-group:focus-within .submenu, .nav-group.open .submenu { display: block; }
.submenu a { display: block; padding: .45rem .6rem; border-radius: 7px; color: var(--ink-soft); font-size: .92rem; border: 0; }
.submenu a:hover { background: var(--paper-2); color: var(--accent); text-decoration: none; }

/* Admin shell (left sidebar + content) */
.admin-shell { display: flex; gap: 1.5rem; align-items: flex-start; }
.admin-side { width: 210px; flex: none; position: sticky; top: 80px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: .55rem; box-shadow: var(--shadow); }
.admin-side .as-title { font-size: .9rem; font-weight: 700; letter-spacing: .01em; color: var(--ink); padding: .4rem .55rem; }
.admin-side a { display: block; padding: .45rem .6rem; border-radius: 7px; color: var(--ink-soft); font-size: .92rem; }
.admin-side a:hover { background: var(--paper-2); color: var(--ink); text-decoration: none; }
.admin-side a.active { background: var(--accent); color: #fff; }
.admin-side .sep { border-top: 1px solid var(--line); margin: .4rem 0; }
/* collapsible admin groups */
.admin-side .as-group { margin-bottom: .15rem; }
.admin-side .as-group > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .3rem;
  border-radius: 7px; user-select: none; }
.admin-side .as-group > summary::-webkit-details-marker { display: none; }
.admin-side .as-group > summary::before { content: "▸"; font-size: .7rem; color: var(--muted); transition: transform .12s; }
.admin-side .as-group[open] > summary::before { transform: rotate(90deg); }
.admin-side .as-group > summary:hover { background: var(--paper-2); }
.admin-side .as-group > a { margin-left: .55rem; }
.admin-main { flex: 1; min-width: 0; }
.script-group { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  margin: 1.1rem 0 .4rem; border-bottom: 1px solid var(--line); padding-bottom: .2rem; }
/* custom typeahead dropdown */
.suggest-wrap { position: relative; display: block; }
.suggest-box { position: absolute; left: 0; right: 0; top: 100%; z-index: 60; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 260px;
  overflow: auto; margin-top: 2px; }
.suggest-item { padding: .4rem .6rem; cursor: pointer; font-size: .9rem; white-space: normal; }
.suggest-item:hover, .suggest-item.active { background: var(--accent); color: #fff; }

/* Drug monograph: side jump-rail + content */
.mono-shell { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 1.75rem; align-items: start; }
.mono-rail { position: sticky; top: 80px; font-size: .85rem; max-height: calc(100vh - 96px); overflow-y: auto; }
.mono-rail .rail-label { text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-size: .72rem; margin-bottom: .4rem; }
.mono-rail a { display: block; padding: .22rem .55rem; color: var(--ink-soft); border-inline-start: 2px solid var(--line); }
.mono-rail a:hover { color: var(--accent); border-inline-start-color: var(--accent); text-decoration: none; }

@media (max-width: 900px) {
  .admin-shell { flex-direction: column; }
  .admin-side { width: 100%; position: static; }
  /* minmax(0,1fr) — a plain 1fr track is min-content wide, so one long/unbreakable
     child (e.g. an InChIKey) would stretch the grid past the viewport. */
  .mono-shell { grid-template-columns: minmax(0, 1fr); }
  .mono-rail { display: none; }
}


/* --- Buttons ---------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; background: var(--accent); color: #fff;
  border: 1px solid var(--accent); border-radius: 7px; padding: .5rem .9rem; font: inherit; font-weight: 500;
  cursor: pointer; transition: background .15s, transform .05s; }
.btn:hover { background: var(--accent-2); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .35rem .7rem; font-size: .88rem; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); }

/* --- Cards & layout --------------------------------------------------- */
.main { padding: 2rem 1.25rem 4rem; flex: 1 0 auto; width: 100%; }   /* grow + full width (flex auto-margins otherwise shrink it); footer sticks to bottom */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }

.entity-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: var(--shadow); color: var(--ink); transition: transform .12s, box-shadow .12s, border-color .12s; }
.entity-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); text-decoration: none; }
.entity-card .ec-icon { font-size: 1.6rem; }
.entity-card .ec-title { font-family: var(--serif); font-size: 1.2rem; margin: .35rem 0; }

/* --- Forms ------------------------------------------------------------ */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: .9rem; font-weight: 500; margin-bottom: .3rem; color: var(--ink-soft); }
input, select, textarea {
  width: 100%; font: inherit; padding: .6rem .75rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.search-input { font-size: 1.1rem; padding: .8rem 1rem; }

/* --- Tables ----------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
th, td { text-align: start; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
th { background: var(--paper-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--paper-2); }

/* Key/value tables (label | value). Excluded from the mobile horizontal-scroll
   rule below — they wrap their prose instead, so long agent names / codes never
   force the page wider than the viewport. */
.kv { width: 100%; table-layout: fixed; }
.kv th { width: 38%; background: transparent; text-transform: none; letter-spacing: 0;
  font-weight: 600; color: var(--ink-soft); vertical-align: top; }
.kv td { overflow-wrap: anywhere; }
.kv td code { overflow-wrap: anywhere; word-break: break-all; }

/* --- Badges / alerts -------------------------------------------------- */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--paper-2); color: var(--ink-soft); white-space: nowrap; overflow-wrap: normal; }
.badge-accent { background: #e7f0ea; color: var(--accent-ink); }
.badge-gold { background: #f5edd6; color: var(--gold); }
.badge-danger { background: #f6dcdc; color: var(--danger); }
.alert { padding: .85rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 1rem; }
.alert-error { background: #f9e3e3; border-color: #e7b9ba; color: var(--danger); }
.alert-success { background: #e3f1ea; border-color: #b6d8c6; color: var(--ok); }
.alert-info { background: #eef2f6; border-color: #cdd9e3; color: var(--ink-soft); }
.alert-warn { background: #fbf2dd; border-color: #ecd9a6; color: var(--warn); }

/* --- Hero ------------------------------------------------------------- */
.hero { text-align: center; padding: clamp(1.5rem, 6vw, 3rem) 0 2.5rem; }
.hero h1 { font-size: clamp(2rem, 7vw, 3rem); }
.hero .lead { font-size: clamp(1rem, 3vw, 1.2rem); color: var(--muted); max-width: 640px; margin: 0 auto 1.5rem; }
.hero-search { display: flex; gap: .5rem; max-width: 620px; margin: 0 auto; }
.hero-search input { flex: 1; min-width: 0; }

/* --- Footer ----------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--line); background: var(--paper-2); color: var(--muted); font-size: .9rem; flex-shrink: 0; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; height: 64px; }

/* --- Auth card -------------------------------------------------------- */
.auth-card { max-width: 400px; margin: 3rem auto; }

/* --- Wide-table scroll wrapper (admin/data) --------------------------- */
/* Wide tables: a fixed-height scroll box so the horizontal scrollbar is reachable
   without scrolling to the bottom of the page; sticky header stays in view. */
.table-scroll { overflow: auto; max-height: 72vh; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--radius-lg); }
.table-scroll table { border: 0; border-radius: 0; overflow: visible; }
.table-scroll thead th { position: sticky; top: 0; z-index: 2; }
.table-scroll th, .table-scroll td { white-space: nowrap; }
.table-scroll td { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; }
/* Keep the first column (row key / edit link) pinned while scrolling sideways. */
.table-scroll.sticky-1 th:first-child,
.table-scroll.sticky-1 td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); }
.table-scroll.sticky-1 thead th:first-child { z-index: 3; background: var(--paper-2); }
.table-scroll.sticky-1 tbody tr:hover td:first-child { background: var(--paper-2); }

/* --- Pager ------------------------------------------------------------ */
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1rem 0 .5rem; }
.pager .btn[disabled] { opacity: .45; pointer-events: none; }

/* --- Responsive ------------------------------------------------------- */

/* Wide DATA tables scroll horizontally rather than breaking the layout.
   Key/value tables (.kv) keep wrapping their prose normally. Applies on phones
   and small tablets, where multi-column tables would otherwise overflow. */
@media (max-width: 900px) {
  table:not(.kv) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
}

@media (max-width: 760px) {
  /* Header wraps; the nav is hidden behind the ☰ toggle to stay out of the way. */
  .header-inner { flex-wrap: wrap; height: auto; padding: .55rem 0; gap: .4rem 1rem; }
  .brand-name { font-size: 1.1rem; }
  .nav-toggle { display: inline-flex; align-items: center; order: 1; margin-inline-start: auto; }
  .header-actions { order: 2; margin-inline-start: .5rem; }
  /* Hidden by default; the toggle adds .nav-open. Vertical accordion when shown. */
  .site-nav { order: 3; display: none; flex: 1 1 100%; width: 100%; flex-direction: column;
              align-items: stretch; gap: .1rem; overflow: visible; margin-top: .3rem;
              border-top: 1px solid var(--line); padding-top: .3rem; }
  .header-inner.nav-open .site-nav { display: flex; }
  .site-nav > a, .nav-group { width: 100%; }
  .nav-top { width: 100%; justify-content: space-between; padding: .55rem 0; }
  .nav-group { display: block; }
  .submenu { position: static; box-shadow: none; border: 0; border-radius: 0; min-width: 0;
             margin: 0 0 .2rem .25rem; padding: 0 0 .15rem .7rem;
             border-inline-start: 2px solid var(--line); }
  .nav-group.open .caret { transform: rotate(180deg); }
  .main { padding: 1.25rem 1rem 3rem; }
  .wrap { padding: 0 1rem; }
  .card { padding: 1.1rem; }
  .pager { flex-wrap: wrap; gap: .5rem; }
  .footer-inner { flex-direction: column; height: auto; gap: .25rem; padding: 1rem 0; text-align: center; }
}

@media (max-width: 480px) {
  /* Single-column cards; comfortable tap targets. */
  .card-grid { grid-template-columns: minmax(0, 1fr); }
  .card-grid > * { min-width: 0; }
  .hero-search { flex-direction: column; }
  .hero-search .btn { width: 100%; justify-content: center; }
  .btn { padding: .55rem 1rem; }   /* ≥44px tap height */
}

/* --- Stacked (vertical) tables on phones ------------------------------
   Add class="r-stack" to a multi-column content table and data-label="…"
   to each <td>. On phones each row becomes a labeled card (value on the
   right, column name on the left) instead of forcing a sideways scroll.
   Comes AFTER the table:not(.kv) scroll rule so it wins at equal specificity.
   Admin data grids stay in .table-scroll (horizontal scroll) untouched. */
@media (max-width: 640px) {
  table.r-stack { display: block; border: 0; background: transparent; white-space: normal; overflow: visible; }
  table.r-stack thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); border: 0; }
  table.r-stack tbody { display: block; }
  table.r-stack tr { display: block; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--card); margin-bottom: .6rem; overflow: hidden; }
  table.r-stack tr:hover { background: var(--card); }
  /* label stacked above the value: mixed text + badges + links flow inline
     naturally (no squeezed flex column), and nothing breaks mid-pill. */
  table.r-stack td { display: block; text-align: start; white-space: normal; overflow-wrap: anywhere;
    padding: .5rem .8rem; border: 0; border-bottom: 1px solid var(--line); }
  table.r-stack tr td:last-child { border-bottom: 0; }
  table.r-stack td:empty { display: none; }
  table.r-stack td::before { content: attr(data-label); display: block; margin-bottom: .15rem;
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

  /* Collapsible: each row shows only its first cell (the summary) with a +/− toggle;
     the rest of the fields are revealed when the row gets .open (tap to expand). */
  table.r-stack td:not(:first-child) { display: none; }
  table.r-stack tr.open td:not(:first-child) { display: block; }
  table.r-stack tr.open td:empty { display: none; }
  table.r-stack td:first-child { position: relative; padding-right: 2.6rem; cursor: pointer;
    font-weight: 600; border-bottom: 0; }
  table.r-stack tr.open td:first-child { border-bottom: 1px solid var(--line); }
  table.r-stack td:first-child::before { display: none; }     /* no label on the summary line */
  table.r-stack td:first-child::after { content: "+"; position: absolute; right: .7rem; top: 50%;
    transform: translateY(-50%); width: 1.5rem; height: 1.5rem; line-height: 1.4rem; text-align: center;
    border: 1px solid var(--line); border-radius: 7px; font-weight: 700; color: var(--accent);
    background: var(--paper-2); }
  table.r-stack tr.open td:first-child::after { content: "\2212"; }   /* − */
}

/* Market search: brand groups (expandable) */
.brand-group { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .5rem; background: var(--card); }
.brand-group > summary { cursor: pointer; padding: .6rem .9rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; list-style: none; }
.brand-group > summary::-webkit-details-marker { display: none; }
.brand-group > summary::before { content: "+"; font-weight: 700; color: var(--accent); width: 1ch; display: inline-block; }
.brand-group[open] > summary::before { content: "\2212"; }
.brand-group .bg-name { font-weight: 600; }
.brand-group .bg-price { margin-inline-start: auto; white-space: nowrap; }
.brand-group table { margin: 0 .6rem .6rem; width: calc(100% - 1.2rem); }

/* --- Admin content polish ------------------------------------------------ */
.admin-main { max-width: 1040px; }
.admin-main > h1:first-child { margin-top: 0; }
.admin-main h2 { margin-top: 2rem; font-size: 1.25rem; }
.admin-main .lead { color: var(--muted); margin-top: -.25rem; }
.admin-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 1.25rem 1.4rem; }
.admin-card > h3:first-child, .admin-card > h2:first-child { margin-top: 0; }

/* Two-pane master/detail (e.g. enum types | values) */
.pane-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .pane-grid { grid-template-columns: 1fr; } }

/* Compact selectable list (enum types, etc.) */
.pick-list { display: flex; flex-direction: column; gap: 2px; }
.pick-list a { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem;
  padding: .5rem .7rem; border-radius: 8px; color: var(--ink); border: 1px solid transparent; }
.pick-list a:hover { background: var(--paper-2); text-decoration: none; }
.pick-list a.active { background: var(--paper-2); border-color: var(--line); }
.pick-list .meta { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.pick-list .key { color: var(--muted); font-weight: 400; font-size: .85rem; }

/* Inline horizontal form (fields in a row, wraps on small screens) */
.row-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; }
.row-form .form-group { margin: 0; flex: 1; min-width: 150px; }
.row-form button { flex: none; }
/* generic "query row" used by filter/condition builders — keeps the remove (✕) inline at the end */
.qrow { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.qrow > button { flex: none; align-self: center; }

/* Value chips with inline delete */
.chip-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.val-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .3rem .25rem .6rem;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; font-size: .9rem; }
.val-chip form { margin: 0; display: inline; }
.val-chip button { background: none; border: 0; color: var(--muted); cursor: pointer; line-height: 1; padding: 0 .15rem; }
.val-chip button:hover { color: var(--danger); }

/* List page-size + pager controls */
.list-controls { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center;
  justify-content: space-between; margin: .75rem 0; }
.list-controls .list-controls-spacer { flex: 1; }
.brand-group .bg-generics a { color: var(--ink-soft); }
.brand-group .bg-generics a:hover { color: var(--accent); }

/* Admin-customizable announcement bar + footer links */
.announce-bar { background: var(--accent); color: #fff; font-size: .92rem; }
.announce-bar .wrap { padding: .5rem 1.25rem; }
.announce-bar a { color: #fff; text-decoration: underline; }
.site-footer .footer-links { display: inline-flex; gap: 1rem; flex-wrap: wrap; }

/* Markdown page editor */
.md-toolbar { display: flex; gap: .3rem; margin-bottom: .4rem; }
.md-toolbar button { background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: .25rem .6rem; cursor: pointer; font: inherit; min-width: 2rem; }
.md-toolbar button:hover { background: var(--paper-2); }
.md-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: stretch; }
.md-split textarea { font-family: ui-monospace, monospace; font-size: .9rem; line-height: 1.5; }
.md-preview { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem;
  background: var(--card); overflow: auto; max-height: 32rem; }
.md-preview h1, .md-preview h2, .md-preview h3 { margin-top: .6rem; }
@media (max-width: 760px) { .md-split { grid-template-columns: 1fr; } }
/* Public page content readability */
.page-content { max-width: 760px; }
.page-content h2 { margin-top: 1.6rem; }

/* Data-editor row form: multi-column field grid */
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .25rem 1.5rem; }
.field-grid .form-group { margin: 0 0 .75rem; min-width: 0; }
.field-grid .fg-wide { grid-column: 1 / -1; }   /* long text fields span the full width */

/* Shortcodes */
.sc-error { color: var(--danger); font-size: .85rem; background: #f9e3e3; padding: 0 .35rem; border-radius: 4px; }
.sc-searchbox input { min-width: 0; }
