/* ============================================================
   B-Life · Plano de Ação — Editor
   Built on the B-Life Design System (Figma v2):
   DM Sans (Light default) + Space Grotesk eyebrows,
   forest/cream palette, soft 32px card radii, pill buttons.
============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,100;9..40,200;9..40,300;9..40,400;9..40,500;9..40,600&family=Space+Grotesk:wght@400;500;600&display=swap');

:root {
  /* ---- B-Life palette (Figma ground truth) ----------------- */
  --forest:        #04261E;
  --forest-2:      #024036;
  --forest-3:      #0B3D31;            /* mid forest, used for hover-on-forest */
  --forest-tint:   #E6EDEA;            /* soft forest fill */
  --forest-tint-2: #DCEBEA;            /* success-tint, doubles as soft brand */
  --sage:          #74B0A8;
  --sage-2:        #5C9A93;

  --paper:         #FEFCF9;
  --paper-2:       #F6F2F0;
  --paper-3:       #EFEAE5;            /* deeper cream wash for app bg */
  --paper-shell:   #EFE9E1;            /* outer canvas around the editor */

  --ink:           #2F2E2C;
  --ink-2:         #5E5E67;
  --ink-3:         #72706E;
  --ink-4:         #A8A6A2;
  --ink-disabled:  #AAAAB8;

  --line:          #E5DFDC;
  --line-2:        #ECE7E2;
  --line-3:        #F1ECE7;

  /* ---- Status (B-Life success/warning/error) --------------- */
  --ok:            #14CBA1;
  --ok-bg:         #DCEBEA;
  --ok-ink:        #04261E;

  --warn:          #F4B845;
  --warn-bg:       #FAE0AF;
  --warn-ink:      #5A3E0B;

  --risk:          #F84D47;
  --risk-bg:       #FBD6D4;
  --risk-ink:      #5C0E0B;

  --info:          #14ACCB;
  --info-bg:       #DCEBEE;
  --info-ink:      #0B3C46;

  /* ---- Brand aliases the JSX expects ----------------------- */
  --brand:         var(--forest);
  --brand-2:       var(--forest-2);
  --brand-3:       var(--forest-3);
  --brand-tint:    var(--forest-tint);
  --brand-leaf:    var(--sage);

  --bg:            var(--paper-shell);
  --surface:       var(--paper);
  --surface-2:     var(--paper-2);
  --surface-3:     var(--paper-3);

  /* ---- Type ----------------------------------------------- */
  --ff-sans:      "DM Sans", "Söhne", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --ff-brand:     "Space Grotesk", "DM Sans", sans-serif;
  --ff-display:   "DM Sans", "Söhne", sans-serif;
  --ff-mono:      ui-monospace, "SF Mono", Menlo, monospace;

  --fw-thin:      100;
  --fw-xlight:    200;
  --fw-light:     300;
  --fw-regular:   400;
  --fw-medium:    500;
  --fw-semi:      600;

  /* ---- Radius -------------------------------------------- */
  --r-xs:    6px;
  --r-sm:    10px;
  --r-md:   14px;
  --r-lg:   20px;
  --r-xl:   28px;
  --r-card: 24px;
  --r-pill: 9999px;

  /* ---- Shadow -------------------------------------------- */
  --sh-1:  0 1px 0 rgba(4,38,30,0.03), 0 1px 2px rgba(4,38,30,0.04);
  --sh-2:  0 1px 2px rgba(4,38,30,0.04), 0 8px 24px rgba(4,38,30,0.05);
  --sh-3:  0 2px 4px rgba(4,38,30,0.04), 0 16px 48px rgba(4,38,30,0.08);

  /* ---- Motion -------------------------------------------- */
  --ease-soft:  cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-io:    cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper-shell);
  color: var(--ink);
  font-family: var(--ff-sans);
  font-weight: var(--fw-light);
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: "lnum", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; font-weight: var(--fw-light); }
input, textarea, select { font-family: inherit; color: inherit; font-weight: var(--fw-light); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }

/* Eyebrows used everywhere */
.eyebrow {
  font-family: var(--ff-brand);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ============================================================
   App shell
============================================================ */
.app {
  display: grid;
  grid-template-columns: 64px 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--paper-shell);
}

/* ---------- Left rail ---------- */
.rail {
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  gap: 4px;
}
.rail .logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  margin-bottom: 16px;
}
.rail .logo svg { width: 32px; height: 32px; }
.rail .ricon {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  display: grid; place-items: center;
  color: var(--ink-3);
  cursor: pointer;
  transition: all 160ms var(--ease-soft);
}
.rail .ricon:hover { background: var(--paper); color: var(--ink); }
.rail .ricon.active {
  background: var(--forest);
  color: var(--paper);
}
.rail .spacer { flex: 1; }

/* ---------- Main column ---------- */
.main {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 0;
  overflow: hidden;
  background: var(--paper-shell);
}

/* ---------- Top tabs ---------- */
.topbar {
  background: transparent;
  display: flex;
  align-items: center;
  padding: 0 28px;
  height: 60px;
  gap: 4px;
  position: relative;
}
.topbar .tabs { display: flex; gap: 6px; height: 100%; align-items: center; }
.topbar .tab {
  display: flex; align-items: center;
  padding: 0 16px;
  height: 36px;
  font-size: 14px;
  font-weight: var(--fw-light);
  color: var(--ink-3);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all 160ms var(--ease-soft);
  letter-spacing: -0.005em;
}
.topbar .tab:hover { color: var(--ink); background: var(--paper-2); }
.topbar .tab.active {
  color: var(--forest);
  background: var(--paper);
  font-weight: var(--fw-medium);
  box-shadow: var(--sh-1);
}
.topbar .env-pill {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--ff-sans);
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  color: var(--ink);
  padding: 5px 14px 5px 6px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--paper);
  letter-spacing: -0.005em;
}
.topbar .env-logo {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: var(--forest-tint);
  border-radius: 50%;
}
.topbar .env-logo img { width: 16px; height: 16px; display: block; }

/* ---------- Status bar (patient + actions) ---------- */
.statusbar {
  background: transparent;
  padding: 8px 28px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.statusbar .patient {
  display: flex; align-items: center; gap: 12px;
}
.statusbar .patient-name {
  font-weight: var(--fw-medium);
  font-size: 16px;
  letter-spacing: -0.01em;
}
.statusbar .patient-meta {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 1px;
}
.statusbar .divider {
  width: 1px; height: 32px;
  background: var(--line);
}
.statusbar .crumbs {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
}
.statusbar .crumbs strong { color: var(--ink); font-weight: var(--fw-medium); }
.statusbar .actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
}
.review-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: var(--fw-medium);
}
.review-pill .dot {
  width: 6px; height: 6px;
  background: var(--warn);
  border-radius: 50%;
}
.review-pill strong { font-weight: var(--fw-medium); }
.review-pill.ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
}
.review-pill.ok svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Disabled publish button — reads as locked, not greyed-out, to keep the
   forest button visible in the layout while signalling it isn’t actionable. */
.btn.primary.is-disabled {
  background: var(--forest-3);
  border-color: var(--forest-3);
  color: rgba(254,252,249,0.65);
  cursor: not-allowed;
}
.btn.primary.is-disabled:hover {
  background: var(--forest-3);
  border-color: var(--forest-3);
}
.completion {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 14px 5px 6px;
  background: var(--paper);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-1);
}
.completion .ring {
  width: 28px; height: 28px;
  display: grid; place-items: center;
}
.completion .label {
  font-size: 12.5px;
  color: var(--ink-3);
}
.completion .label strong { color: var(--ink); font-weight: var(--fw-medium); }

/* ---------- Buttons (B-Life pill style) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: var(--r-pill);
  padding: 9px 16px;
  height: 38px;
  font-size: 13px;
  font-weight: var(--fw-light);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: all 180ms var(--ease-soft);
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.btn:hover { background: var(--paper-2); border-color: var(--neutral-30, #C8C1B9); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--forest);
  color: var(--paper);
  border-color: var(--forest);
  font-weight: var(--fw-light);
}
.btn.primary:hover { background: var(--forest-2); border-color: var(--forest-2); }
.btn.ghost {
  border-color: transparent;
  background: transparent;
}
.btn.ghost:hover { background: var(--paper-2); }
.btn.danger {
  color: var(--risk);
  border-color: transparent;
  background: transparent;
}
.btn.danger:hover { background: var(--risk-bg); }
.btn.sm { padding: 6px 12px; height: 32px; font-size: 12.5px; }
.btn.xs { padding: 4px 11px; height: 28px; font-size: 12px; }

/* ---------- Body: split editor + preview ---------- */
.body {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 0;
  overflow: hidden;
  padding: 0 14px 14px;
  gap: 14px;
}
.body.with-preview {
  grid-template-columns: 240px minmax(0, 3fr) minmax(0, 2fr);
}

/* ---------- Sidebar — Etapas ---------- */
.sidebar {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 22px 14px;
  overflow-y: auto;
  box-shadow: var(--sh-1);
}
.sidebar .group-label {
  font-family: var(--ff-brand);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  padding: 0 12px 12px;
}
.step-tree {
  display: flex; flex-direction: column;
  gap: 1px;
}
.step {
  display: flex; align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13.5px;
  position: relative;
  user-select: none;
  transition: all 140ms var(--ease-soft);
}
.step:hover { background: var(--paper-2); }
.step.active {
  background: var(--forest-tint);
  color: var(--forest);
  font-weight: var(--fw-medium);
}
.step .step-icon {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.step-status {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--neutral-10, #E5DFDC);
  flex-shrink: 0;
}
.step-status.done { background: var(--ok); }
.step-status.partial { background: var(--warn); }

/* Newer review-context status icon — sage molecule for AI / green check for reviewed */
.step-status-ic {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background-color 180ms var(--ease-soft), color 180ms var(--ease-soft);
}
.step-status-ic.ai {
  background: var(--forest-tint);
  color: var(--sage-2);
}
.step-status-ic.ok {
  background: var(--ok);
  color: var(--paper);
}
.step.active .step-status-ic.ai {
  background: var(--paper);
  color: var(--forest);
}
.step-count {
  margin-left: auto;
  font-size: 11px;
  background: var(--paper-2);
  padding: 1px 8px;
  border-radius: var(--r-pill);
  color: var(--ink-3);
  min-width: 22px;
  text-align: center;
}
.step.active .step-count { background: var(--paper); color: var(--forest); }
.sidebar .divider { height: 1px; background: var(--line); margin: 18px 8px; }

/* ---------- Editor canvas ---------- */
.editor {
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 28px 32px 80px;
  box-shadow: var(--sh-1);
}
.editor-inner { max-width: 920px; margin: 0 auto; }

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 26px;
  gap: 24px;
}
.section-header h1 {
  font-family: var(--ff-display);
  font-size: 32px;
  font-weight: var(--fw-xlight);
  margin: 0 0 6px;
  letter-spacing: -0.019em;
  line-height: 1.05;
  color: var(--ink);
}
.section-header .crumb {
  font-family: var(--ff-brand);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.section-header .crumb-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 7px;
  border-radius: var(--r-pill);
  font-family: var(--ff-brand);
  font-size: 10px;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.section-header .crumb-tag svg { width: 11px; height: 11px; stroke-width: 2; }
.section-header .crumb-tag.ai {
  background: var(--forest-tint);
  color: var(--forest);
}
.section-header .crumb-tag.ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
}
.section-header .crumb-tag.ok svg { stroke: var(--ok-ink); fill: none; }
.section-header .sub {
  color: var(--ink-3);
  font-size: 13.5px;
  max-width: 440px;
}
.section-header .responsavel {
  display: flex; align-items: center; gap: 12px;
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 0;
  font-size: 13px;
}
.section-header .responsavel .av {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sage), var(--forest));
  color: var(--paper);
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: var(--fw-medium);
}
.section-header .responsavel .lbl {
  font-family: var(--ff-brand);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 2px;
}

/* ---------- Card ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: none;
  transition: border-color 160ms var(--ease-soft);
}
.card:hover { border-color: var(--line-2); }
.card + .card { margin-top: 14px; }
.card .card-head {
  display: flex; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-2);
  gap: 14px;
}
.card .card-head .title {
  font-weight: var(--fw-medium);
  font-size: 14.5px;
  letter-spacing: -0.005em;
}
.card .card-head .pill {
  font-size: 11px; color: var(--ink-3);
  background: var(--paper-2);
  padding: 2px 9px;
  border-radius: var(--r-pill);
}
.card .card-head .grip {
  width: 16px; color: var(--ink-4); cursor: grab;
}
.card .card-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card .card-body { padding: 20px; }

/* ---------- Form atoms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label, .field .lbl {
  font-family: var(--ff-brand);
  font-size: 10.5px;
  color: var(--ink-3);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 14px;
  font-weight: var(--fw-light);
  color: var(--ink);
  transition: all 160ms var(--ease-soft);
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--neutral-30, #C8C1B9); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(4,38,30,0.06);
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.55; font-family: var(--ff-sans); }
.input.lg { padding: 13px 16px; font-size: 15px; }
.input.transparent {
  border-color: transparent;
  background: transparent;
  padding: 4px 6px;
  margin-left: -6px;
}
.input.transparent:hover { background: var(--paper-2); }
.input.transparent:focus { background: var(--paper); border-color: var(--forest); }

select.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2372706E' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--paper-2);
  font-size: 12.5px;
  font-weight: var(--fw-light);
  color: var(--ink-2);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 140ms var(--ease-soft);
}
.chip:hover { border-color: var(--neutral-30, #C8C1B9); }
.chip.danger {
  background: var(--risk-bg);
  color: var(--risk-ink);
  border-color: transparent;
}
.chip.danger:hover { border-color: var(--risk); }
.chip.danger .x { color: var(--risk); opacity: 0.7; }
.chip.selected {
  background: var(--forest-tint);
  color: var(--forest);
  border-color: transparent;
}
.chip.selected:hover { background: var(--forest-tint-2); }
.chip.removable .x {
  margin-right: -4px;
  margin-left: 2px;
  opacity: 0.55;
  width: 12px; height: 12px;
}
.chip.removable:hover .x { opacity: 1; }
.chip.add {
  background: transparent;
  border: 1px dashed var(--neutral-30, #C8C1B9);
  color: var(--ink-3);
}
.chip.add:hover { color: var(--forest); border-color: var(--sage); background: var(--forest-tint); }

/* ---------- Status pill (B-Life) ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: var(--fw-medium);
  white-space: nowrap;
}
.status .d { width: 7px; height: 7px; border-radius: 50%; }
.status.ok { background: var(--ok-bg); color: var(--ok-ink); }
.status.ok .d { background: var(--ok); }
.status.warn { background: var(--warn-bg); color: var(--warn-ink); }
.status.warn .d { background: var(--warn); }
.status.risk { background: var(--risk-bg); color: var(--risk-ink); }
.status.risk .d { background: var(--risk); }

/* ---------- Rich text ---------- */
.rt-toolbar {
  display: flex; gap: 2px;
  padding: 8px 10px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.rt-toolbar button {
  width: 28px; height: 28px;
  border: 0; background: transparent;
  color: var(--ink-3);
  border-radius: 8px;
  display: grid; place-items: center;
  transition: all 140ms;
}
.rt-toolbar button:hover { background: var(--paper); color: var(--ink); }
.rt-area {
  border: 1px solid var(--line);
  border-radius: 0 0 var(--r-md) var(--r-md);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: var(--fw-light);
  line-height: 1.6;
  min-height: 130px;
  background: var(--paper);
  outline: none;
  transition: border-color 160ms;
}
.rt-area:focus { border-color: var(--forest); }
.rt-area ul { margin: 4px 0; padding-left: 20px; }
.rt-area li { margin: 4px 0; }
.rt-area p { margin: 0 0 10px; }
.rt-area em, .rt-area i { color: var(--ink-2); }

/* ---------- Add-section affordance ---------- */
.add-section {
  margin-top: 14px;
  border: 1.5px dashed var(--neutral-30, #C8C1B9);
  background: transparent;
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: var(--fw-light);
  cursor: pointer;
  transition: all 180ms var(--ease-soft);
}
.add-section:hover {
  border-color: var(--sage);
  background: var(--forest-tint);
  color: var(--forest);
}
.add-section svg { width: 16px; height: 16px; }

/* ---------- Two-cta empty ---------- */
.empty-ctas { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.empty-cta {
  border: 1.5px dashed var(--line);
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 180ms var(--ease-soft);
}
.empty-cta:hover { border-color: var(--sage); background: var(--forest-tint); }
.empty-cta svg { width: 22px; height: 22px; color: var(--ink-3); margin-bottom: 8px; }
.empty-cta:hover svg { color: var(--forest); }
.empty-cta .ttl { font-weight: var(--fw-medium); font-size: 14px; }
.empty-cta .desc { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }

/* ---------- Banner ---------- */
.banner {
  background: var(--info-bg);
  color: var(--info-ink);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: var(--fw-light);
  display: flex; align-items: center; gap: 10px;
}
.banner.muted {
  background: var(--paper-2);
  color: var(--ink-3);
  text-align: center;
  justify-content: center;
  border: 0;
  font-size: 12.5px;
}

/* ---------- Period tabs (Manhã/Almoço/Noite) ---------- */
.period-tabs {
  display: inline-flex;
  padding: 3px;
  background: var(--paper-2);
  border-radius: var(--r-pill);
  gap: 2px;
}
.period-tabs button {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: var(--fw-light);
  color: var(--ink-3);
  transition: all 160ms;
}
.period-tabs button:hover { color: var(--ink); }
.period-tabs button.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--sh-1);
  font-weight: var(--fw-medium);
}

/* ---------- Bio row ---------- */
.bio-row {
  display: grid;
  grid-template-columns: 18px 1fr 90px 100px 110px 90px 30px;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 13.5px;
}
.bio-row + .bio-row { border-top: 1px solid var(--line-2); }
.bio-row:hover { background: var(--paper-2); }
.bio-row .grip { color: var(--ink-4); cursor: grab; width: 14px; }
.bio-row .nm { font-weight: var(--fw-medium); }
.bio-row .val { font-variant-numeric: tabular-nums; }
.bio-row .unit { color: var(--ink-3); font-size: 12px; }
.bio-row .trend { font-size: 11.5px; color: var(--ink-3); display: flex; align-items: center; gap: 4px; }
.bio-row .x { color: var(--ink-4); }
.bio-row .x:hover { color: var(--risk); }

.bio-header {
  display: grid;
  grid-template-columns: 18px 1fr 90px 100px 110px 90px 30px;
  gap: 10px;
  padding: 0 14px 10px;
  font-family: var(--ff-brand);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}

/* ---------- Suplemento card ---------- */
.supp-card {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 10px;
}
.supp-card .top {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.supp-card .nm {
  font-weight: var(--fw-medium);
  font-size: 14px;
  flex: 1;
}
.supp-card .meta {
  display: flex; gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.supp-card .meta span + span::before {
  content: '·'; margin-right: 8px; color: var(--ink-4);
}
.supp-card .desc { font-size: 13px; color: var(--ink-2); line-height: 1.55; }
.supp-card .moment {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px;
  color: var(--ink-3);
  background: var(--paper-2);
  padding: 2px 9px;
  border-radius: var(--r-pill);
}

/* ---------- Próximos passos card ---------- */
.task-card {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 10px;
  background: var(--paper);
  transition: all 140ms var(--ease-soft);
}
.task-card:hover { border-color: var(--neutral-30, #C8C1B9); }
.task-card .date-tag {
  background: var(--paper-2);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  text-align: center;
}
.task-card .date-tag .m {
  font-family: var(--ff-brand);
  display: block; font-size: 10px;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 500;
}
.task-card .date-tag .y {
  display: block; font-weight: var(--fw-medium);
  font-size: 15px; color: var(--ink); margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.task-card .ttl { font-weight: var(--fw-medium); font-size: 14px; letter-spacing: -0.005em; }
.task-card .typ {
  font-family: var(--ff-brand);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  margin-bottom: 4px;
}
.task-card .actions { display: flex; gap: 4px; }

/* ---------- Team ---------- */
.team-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.team-card {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex; align-items: center; gap: 14px;
}
.team-card .av {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sage), var(--forest));
  color: var(--paper);
  display: grid; place-items: center;
  font-weight: var(--fw-medium);
  font-size: 14px;
}
.team-card .nm { font-weight: var(--fw-medium); font-size: 14px; }
.team-card .ro { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

/* ---------- Score card (Carta ao paciente) ---------- */
.score-wrap {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--forest);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  color: var(--paper);
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.score-wrap::before {
  content: "";
  position: absolute;
  top: -30%; right: -10%;
  width: 280px; height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(116,176,168,0.32), transparent 65%);
  pointer-events: none;
}
.score-wrap .scol {
  text-align: left;
  padding: 0 14px;
  border-right: 1px solid rgba(254,252,249,0.10);
  position: relative;
  z-index: 1;
}
.score-wrap .scol:last-child { border: 0; }
.score-wrap .scol .num {
  font-family: var(--ff-display);
  font-size: 56px;
  font-weight: var(--fw-thin);
  line-height: 1;
  letter-spacing: -0.019em;
}
.score-wrap .scol .lbl {
  font-family: var(--ff-brand);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.72;
  margin-top: 10px;
  font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.score-wrap .scol .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
}
.scol.risk .dot { background: var(--risk); }
.scol.warn .dot { background: var(--warn); }
.scol.ok .dot   { background: var(--ok); }

/* ---------- Preview panel ---------- */
.preview {
  background: linear-gradient(180deg, var(--paper-shell) 0%, #E3D9CC 100%);
  padding: 22px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.preview .phone {
  background: #0B1311;
  border-radius: 44px;
  padding: 6px;
  box-shadow: var(--sh-3), 0 0 0 1px rgba(0,0,0,0.4) inset;
  margin: 0 auto;
  width: 320px;
  height: calc(100vh - 220px);
  min-height: 540px;
  max-height: 780px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.phone-notch {
  position: absolute;
  top: 6px; left: 6px; right: 6px;
  height: 34px;
  background: #0B1311;
  border-radius: 38px 38px 8px 8px;
  display: flex;
  align-items: center;
  padding: 0 22px;
  color: white;
  font-size: 12px;
  z-index: 3;
}
.phone-time {
  font-family: var(--ff-brand);
  font-weight: 500;
  font-size: 13px;
}
.phone-pill {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  width: 92px; height: 24px;
  background: #000;
  border-radius: 14px;
  top: 6px;
}
.phone-status {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  color: white;
}
.phone-scroll {
  flex: 1;
  background: var(--paper);
  border-radius: 32px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 34px;
  padding-bottom: 60px;
  -webkit-overflow-scrolling: touch;
  position: relative;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}
.phone-scroll::-webkit-scrollbar { width: 4px; }
.phone-scroll::-webkit-scrollbar-thumb { background: rgba(4,38,30,0.20); border-radius: 2px; }
.phone-scroll img {
  display: block;
  width: 100%;
  height: auto;
}
.phone-tabbar {
  position: absolute;
  bottom: 6px; left: 6px; right: 6px;
  height: 62px;
  background: rgba(254,252,249,0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  border-radius: 0 0 38px 38px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 4px 12px;
  z-index: 3;
}
.phone-tabbar .ptab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: var(--ff-brand);
  font-size: 9.5px;
  color: var(--ink-3);
  font-weight: 500;
  letter-spacing: 0.05em;
}
.phone-tabbar .ptab svg { width: 20px; height: 20px; }
.phone-tabbar .ptab.active { color: var(--forest); }

.preview-head {
  font-family: var(--ff-brand);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.preview-head .dot { width: 6px; height: 6px; background: var(--ok); border-radius: 50%; }
.preview-meta {
  font-size: 11px; color: var(--ink-3);
  margin-top: 16px; text-align: center;
  font-weight: var(--fw-light);
}

/* ============================================================
   Modal
============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 38, 30, 0.36);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  z-index: 1000;
  padding: 40px;
  animation: fadeIn 200ms var(--ease-soft);
}
.modal {
  background: var(--paper);
  border-radius: var(--r-card);
  box-shadow: 0 24px 80px rgba(4,38,30,0.20), 0 4px 16px rgba(4,38,30,0.10);
  width: 720px;
  max-width: 100%;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 260ms var(--ease-soft);
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: translateY(0) } }

.modal-head {
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; gap: 12px;
}
.modal-head > div:first-child { flex: 1; }
.modal-steps {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 26px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-3);
}
.mstep { display: flex; align-items: center; gap: 8px; }
.mstep .dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink-3);
  display: grid; place-items: center;
  font-size: 11px; font-weight: var(--fw-medium);
}
.mstep.on { color: var(--ink); font-weight: var(--fw-medium); }
.mstep.on .dot { background: var(--forest); border-color: var(--forest); color: var(--paper); }
.mstep-line { flex: 1; height: 1px; background: var(--line); }

.modal-body {
  padding: 22px 26px;
  overflow-y: auto;
  flex: 1;
}
.modal-foot {
  padding: 16px 26px;
  border-top: 1px solid var(--line);
  display: flex; gap: 10px;
  background: var(--paper-2);
}

.exam-list {
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.exam-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 120ms;
  background: var(--paper);
}
.exam-row + .exam-row { border-top: 1px solid var(--line-2); }
.exam-row:hover { background: var(--paper-2); }
.exam-row.picked { background: var(--forest-tint); }
.exam-radio {
  width: 18px; height: 18px;
  border: 1.5px solid var(--neutral-30, #C8C1B9);
  border-radius: 50%;
  flex-shrink: 0;
  display: grid; place-items: center;
}
.exam-row.picked .exam-radio { border-color: var(--forest); }
.exam-row.picked .exam-radio span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--forest);
}

/* ---------- Draggable rows ---------- */
.task-card.draggable .grip { cursor: grab; }
.task-card.draggable .grip:active { cursor: grabbing; }
.task-card.draggable.dragging {
  opacity: 0.6;
  background: var(--forest-tint);
}
.task-card.draggable { transition: transform 120ms, opacity 120ms; }

/* ---------- Helpers ---------- */
.muted { color: var(--ink-3); }
.tiny { font-size: 11.5px; }
.spacer-12 { height: 12px; }
.spacer-16 { height: 16px; }
.spacer-24 { height: 24px; }
.flex { display: flex; }
.between { justify-content: space-between; align-items: center; }
.center { align-items: center; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-1 { flex: 1; }

/* SVG icon defaults */
.ico { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ico-sm { width: 14px; height: 14px; }
.ico-xs { width: 12px; height: 12px; }
.ico-lg { width: 22px; height: 22px; }

/* ---------- Subsection accordion (Estilo de vida) ---------- */
.sub-accordion { display: flex; flex-direction: column; gap: 12px; }
.sub-acc {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
  overflow: hidden;
  transition: border-color 140ms;
}
.sub-acc:hover { border-color: var(--line-2); }
.sub-acc-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
}
.sub-acc-head .lbl { font-weight: var(--fw-medium); font-size: 14px; flex: 1; letter-spacing: -0.005em; }
.sub-acc-head .badge {
  font-size: 11px; padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--paper-2); color: var(--ink-3);
  font-weight: var(--fw-light);
}
.sub-acc-head .chev { color: var(--ink-3); transition: transform 220ms var(--ease-soft); }
.sub-acc.open .chev { transform: rotate(180deg); }
.sub-acc-body { padding: 4px 18px 18px; border-top: 1px solid var(--line-2); }
.sub-acc.collapsed .sub-acc-body { display: none; }

/* ---------- Tweaks panel — keep clean B-Life look ---------- */
.tweaks-panel,
[data-tweaks-panel],
#tweaks-panel {
  font-family: var(--ff-sans);
  font-weight: var(--fw-light);
}

/* ============================================================
   AI generation + medical review
   ─ ChapterReviewBanner  (per-chapter strip above SectionHeader)
   ─ WelcomeToast         (first-load explainer, bottom-right)
============================================================ */

.chapter-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--r-lg);
  margin-bottom: 24px;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  flex-wrap: wrap;
}
.chapter-banner.ai {
  background:
    radial-gradient(circle at 0% 50%, rgba(116,176,168,0.18), transparent 55%),
    var(--paper-2);
  border-color: rgba(116,176,168,0.28);
}
.chapter-banner.reviewed {
  background: var(--ok-bg);
  border-color: rgba(20,203,161,0.20);
}

.cb-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  position: relative;
}
.cb-icon.ai {
  background: var(--paper);
  box-shadow: var(--sh-1);
}
.cb-icon.ai img {
  width: 26px; height: 26px;
  display: block;
}
.cb-icon.ai .ai-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--sage);
  opacity: 0.4;
  animation: cb-pulse 2.4s cubic-bezier(0.22,0.61,0.36,1) infinite;
  pointer-events: none;
}
@keyframes cb-pulse {
  0%   { transform: scale(0.92); opacity: 0.55; }
  70%  { transform: scale(1.12); opacity: 0; }
  100% { transform: scale(1.12); opacity: 0; }
}
.cb-icon.ok {
  background: var(--ok);
  color: var(--paper);
}
.cb-icon.ok svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.2; }

.cb-text { flex: 1; min-width: 0; }
.cb-eyebrow {
  font-family: var(--ff-brand);
  font-size: 10.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--forest);
  font-weight: 500;
  margin-bottom: 4px;
}
.chapter-banner.reviewed .cb-eyebrow { color: var(--ok-ink); opacity: 0.78; }
.cb-title {
  font-weight: var(--fw-medium);
  font-size: 14.5px;
  color: var(--ink);
  letter-spacing: -0.005em;
  margin-bottom: 3px;
}
.chapter-banner.reviewed .cb-title { color: var(--ok-ink); }
.cb-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.5;
  max-width: 560px;
}
.chapter-banner.reviewed .cb-sub { color: var(--ok-ink); opacity: 0.74; }
.chapter-banner .btn { flex-shrink: 0; }

/* ---------- WelcomeToast ---------- */
.welcome-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 360px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 48px rgba(4,38,30,0.12), 0 2px 6px rgba(4,38,30,0.06);
  padding: 16px 18px 18px;
  display: flex;
  gap: 12px;
  z-index: 900;
  animation: toast-in 360ms var(--ease-soft);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.welcome-toast .wt-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--forest-tint);
  display: grid; place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.welcome-toast .wt-icon img { width: 26px; height: 26px; display: block; }
.welcome-toast .wt-body { flex: 1; min-width: 0; }
.welcome-toast .wt-eyebrow {
  font-family: var(--ff-brand);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--forest);
  font-weight: 500;
  margin-bottom: 4px;
}
.welcome-toast .wt-title {
  font-weight: var(--fw-medium);
  font-size: 14px;
  color: var(--ink);
  letter-spacing: -0.005em;
  margin-bottom: 5px;
  line-height: 1.3;
}
.welcome-toast .wt-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.5;
}
.welcome-toast .wt-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  display: grid; place-items: center;
  transition: all 140ms;
}
.welcome-toast .wt-close:hover { background: var(--paper-2); color: var(--ink); }
.welcome-toast .wt-close svg { width: 12px; height: 12px; stroke-width: 2; }

/* ============================================================
   AI Rationale card — sits below the ChapterReviewBanner and
   above the editor body on AI-generated chapters. Explains
   which data sources the AI consulted and a short rationale.
============================================================ */

.ai-rationale {
  background: var(--paper);
  border: 1px solid rgba(116,176,168,0.30);
  border-radius: var(--r-lg);
  margin-bottom: 22px;
  overflow: hidden;
  position: relative;
}
.ai-rationale::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 0% 0%, rgba(116,176,168,0.10), transparent 50%);
  pointer-events: none;
}
.air-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  position: relative;
  z-index: 1;
}
.air-mark {
  width: 28px; height: 28px;
  display: block;
  flex-shrink: 0;
}
.air-head-text { flex: 1; min-width: 0; }
.air-eyebrow {
  font-family: var(--ff-brand);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--forest);
  font-weight: 500;
  margin-bottom: 2px;
}
.air-title {
  font-weight: var(--fw-medium);
  font-size: 13.5px;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.air-chev {
  color: var(--ink-3);
  transition: transform 220ms var(--ease-soft);
}
.ai-rationale.collapsed .air-chev { transform: rotate(-90deg); }
.air-body {
  padding: 4px 18px 18px;
  border-top: 1px solid var(--line-2);
  position: relative;
  z-index: 1;
}
.air-text {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.6;
  padding: 14px 0 12px;
}
.air-text strong {
  color: var(--ink);
  font-weight: var(--fw-medium);
  background: var(--forest-tint);
  padding: 0 5px;
  border-radius: 4px;
}
.air-sources {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.air-sources-lbl {
  font-family: var(--ff-brand);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  margin-bottom: 10px;
}
.air-source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.air-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 9px;
  background: var(--paper-2);
  border-radius: var(--r-pill);
  font-size: 12px;
  color: var(--ink-2);
  font-weight: var(--fw-light);
}
.air-source svg { width: 13px; height: 13px; color: var(--ink-3); stroke-width: 1.6; }

/* Inline AI-suggested hint (small sparkles + text) */
.ai-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--forest);
  background: var(--forest-tint);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-weight: var(--fw-medium);
  letter-spacing: -0.005em;
}
.ai-hint svg { width: 11px; height: 11px; stroke-width: 1.6; }


/* ============================================================
   PDF preview pane — replaces phone mockup. Iframe-based, scaled
   to fit the right column, with zoom controls and Export button.
============================================================ */
.preview.pdf-preview {
  background: linear-gradient(180deg, var(--paper-shell) 0%, #E3D9CC 100%);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.preview.pdf-preview .preview-head { margin-bottom: 0; }

.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pdf-zoom {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
  box-shadow: var(--sh-1);
}
.pdf-zoom-btn {
  border: 0;
  background: transparent;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: var(--fw-light);
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: -0.005em;
  transition: all 140ms var(--ease-soft);
  font-family: var(--ff-sans);
}
.pdf-zoom-btn svg { width: 11px; height: 11px; }
.pdf-zoom-btn:hover { color: var(--ink); }
.pdf-zoom-btn.active {
  background: var(--forest);
  color: var(--paper);
  font-weight: var(--fw-medium);
}
.pdf-toolbar .btn { margin-left: auto; }

.pdf-stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--paper-2);
  border: 1px solid var(--line);
  position: relative;
}
.pdf-stage-scale {
  transform-origin: top left;
  overflow: hidden;
}
.pdf-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: transparent;
}
.preview.pdf-preview .preview-meta {
  margin-top: 0;
  text-align: center;
}


/* ============================================================
   Slim shell — single column, no rail / no top tabs.
   This page exists only to fill the plan and export as PDF.
============================================================ */
.app.slim { grid-template-columns: 1fr; }
.app.slim .rail,
.app.slim .topbar { display: none; }
.app.slim .main { grid-template-rows: auto 1fr; }
.app.slim .statusbar { padding-top: 22px; }

/* Numbered step circle for the sidebar (replaces AI status dot) */
.step-status-ic.step-num {
  font-family: var(--ff-brand);
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  background: var(--paper-2);
  color: var(--ink-3);
  border: 1px solid var(--line);
}
.step:hover .step-status-ic.step-num {
  background: var(--paper);
  color: var(--ink);
}
.step.active .step-status-ic.step-num,
.step-status-ic.step-num.active {
  background: var(--forest);
  color: var(--paper);
  border-color: var(--forest);
}


/* ============================================================
   History modal — list of saved plans (localStorage-backed)
============================================================ */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-row {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
  transition: all 140ms var(--ease-soft);
}
.history-row:hover { border-color: var(--neutral-30, #C8C1B9); background: var(--paper-2); }
.history-row.current {
  border-color: var(--forest);
  background: var(--forest-tint);
}
.history-row.current:hover { background: var(--forest-tint-2); }
.history-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sage), var(--forest));
  color: var(--paper);
  display: grid; place-items: center;
  font-weight: var(--fw-medium);
  font-size: 14px;
  letter-spacing: 0.02em;
}
.history-body { min-width: 0; }
.history-name {
  font-weight: var(--fw-medium);
  font-size: 14.5px;
  letter-spacing: -0.005em;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta .muted { opacity: 0.72; }
.history-current-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--ff-brand);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--forest);
  background: var(--paper);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-weight: 500;
}
.history-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}


/* ============================================================
   Toast (global "Capítulo salvo localmente") + saved indicators
============================================================ */
.blife-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--forest);
  color: var(--paper);
  border-radius: var(--r-pill);
  font-size: 13.5px;
  font-weight: var(--fw-medium);
  letter-spacing: -0.005em;
  box-shadow: 0 12px 32px rgba(4,38,30,0.20), 0 2px 6px rgba(4,38,30,0.08);
  animation: blife-toast-in 240ms cubic-bezier(0.22,0.61,0.36,1);
}
.blife-toast__icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--ok);
  color: var(--forest);
  display: grid; place-items: center;
}
.blife-toast__icon svg { width: 12px; height: 12px; stroke-width: 2.6; }
@keyframes blife-toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Sidebar saved-check */
.step-status-ic.step-saved {
  background: var(--ok);
  color: var(--paper);
  border-color: var(--ok);
}
.step.active .step-status-ic.step-saved {
  background: var(--forest);
  border-color: var(--forest);
}
.step.saved span:not(.step-status-ic) {
  color: var(--ink);
}

/* "Salvar rascunho" button — saved state styling (green pill) */
.btn.saved {
  background: var(--ok-bg);
  border-color: transparent;
  color: var(--ok-ink);
  font-weight: var(--fw-medium);
}
.btn.saved:hover {
  background: var(--forest-tint-2);
  border-color: transparent;
}
.btn.saved svg { color: var(--ok); stroke-width: 2.4; }

/* ---------- Biomarcadores em foco — search + rows ---------- */
.bio-search-input {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2, var(--paper-2));
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 9px 12px;
  transition: all 160ms var(--ease-soft);
}
.bio-search-input:focus-within { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(4,38,30,0.06); }
.bio-search-input svg { color: var(--ink-3); flex-shrink: 0; }
.bio-search-input input { border: 0; outline: 0; background: transparent; flex: 1; font-size: 13.5px; color: var(--ink); font-family: inherit; }

.bio-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: 0 12px 32px rgba(4,38,30,0.12), 0 2px 6px rgba(4,38,30,0.06);
  overflow: hidden;
  max-height: 320px; overflow-y: auto;
}
.bio-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; cursor: pointer; transition: background 120ms;
}
.bio-opt + .bio-opt { border-top: 1px solid var(--line-2); }
.bio-opt:hover { background: var(--forest-tint); }
.bio-opt-nm { font-weight: var(--fw-medium); font-size: 13.5px; color: var(--ink); }
.bio-opt-cat { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.bio-opt-unit { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.bio-opt.custom { color: var(--forest); font-size: 13px; gap: 8px; justify-content: flex-start; }
.bio-opt.custom svg { color: var(--forest); }
.bio-opt-empty { padding: 14px; font-size: 12px; color: var(--ink-3); text-align: center; }

.bio-edit-list { display: flex; flex-direction: column; gap: 8px; }
.bio-edit-row {
  display: flex; align-items: flex-end; gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
}
.bio-edit-id { flex: 1; min-width: 150px; align-self: center; }
.bio-edit-nm { font-weight: var(--fw-medium); font-size: 14px; color: var(--ink); letter-spacing: -0.005em; }
.bio-edit-cat { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.bio-edit-cat-input { border: 0; outline: 0; background: transparent; font-size: 11.5px; color: var(--ink-3); padding: 2px 0; margin-top: 2px; width: 100%; }
.bio-edit-field { display: flex; flex-direction: column; gap: 4px; }
.bio-edit-field > label { font-family: var(--ff-brand); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: var(--fw-medium); }
.bio-edit-field .input { width: 88px; padding: 7px 10px; }
.bio-status-tabs button { font-size: 11.5px; padding: 6px 9px; }
.bio-status-tabs button.active.ok   { background: var(--ok-bg);   color: var(--ok-ink); }
.bio-status-tabs button.active.warn { background: var(--warn-bg); color: var(--warn-ink); }
.bio-status-tabs button.active.risk { background: var(--risk-bg); color: var(--risk-ink); }

/* exam value badge inside the Biomarcadores search dropdown */
.bio-opt-exam {
  display: inline-flex; align-items: center;
  font-variant-numeric: tabular-nums;
  font-size: 11px; font-weight: var(--fw-medium);
  padding: 3px 9px; border-radius: var(--r-pill); white-space: nowrap;
}
.bio-opt-exam.ok   { background: var(--ok-bg);   color: var(--ok-ink); }
.bio-opt-exam.warn { background: var(--warn-bg); color: var(--warn-ink); }
.bio-opt-exam.risk { background: var(--risk-bg); color: var(--risk-ink); }

/* ============================================================
   Resultado de Exame (Capítulo 2)
============================================================ */
.ico.spin { animation: ico-spin 0.9s linear infinite; transform-origin: 50% 50%; }
@keyframes ico-spin { to { transform: rotate(360deg); } }

/* Import drop zone */
.exam-drop {
  border: 1.5px dashed var(--neutral-30, #C8C1B9);
  border-radius: var(--r-lg);
  padding: 34px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 180ms var(--ease-soft);
  background: var(--paper);
}
.exam-drop:hover, .exam-drop.over {
  border-color: var(--sage);
  background: var(--forest-tint);
}
.exam-drop-ic {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--forest-tint); color: var(--forest);
  display: grid; place-items: center; margin: 0 auto 14px;
}
.exam-drop.over .exam-drop-ic { background: var(--paper); }
.exam-drop-ic svg { width: 24px; height: 24px; }
.exam-drop-ttl { font-weight: var(--fw-medium); font-size: 15px; letter-spacing: -0.005em; color: var(--ink); }
.exam-drop-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; max-width: 420px; margin-left: auto; margin-right: auto; }

/* Analyzing state */
.exam-analyzing { display: flex; align-items: center; gap: 16px; padding: 6px 2px; }
.exam-analyzing-ic {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--forest-tint); color: var(--forest);
  display: grid; place-items: center; flex-shrink: 0;
}
.exam-analyzing-ic svg { width: 22px; height: 22px; }
.exam-analyzing-ttl { font-weight: var(--fw-medium); font-size: 14.5px; letter-spacing: -0.005em; }

/* Bio Age card — dark forest, biological vs chronological age */
.bioage-card {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0c241c 0%, #143229 55%, #0e2a20 100%);
  color: var(--paper);
  border-radius: var(--r-lg); padding: 22px 26px 24px;
}
.bioage-card::before {
  content: ""; position: absolute; top: -30%; right: -6%;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(116,176,168,0.30), transparent 62%);
  pointer-events: none;
}
.bioage-mol {
  position: absolute; top: 20px; right: 22px; width: 46px; height: 46px;
  opacity: 0.92; z-index: 1;
}
.bioage-eyebrow {
  position: relative; z-index: 1;
  font-family: var(--ff-brand); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; font-weight: 500; color: rgba(254,252,249,0.78);
}
.bioage-body {
  position: relative; z-index: 1;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-top: 28px; flex-wrap: wrap;
}
.bioage-figure { display: flex; align-items: baseline; gap: 10px; }
.bioage-num {
  font-family: var(--ff-sans); font-weight: 100; font-size: 66px; line-height: 0.9;
  letter-spacing: -0.02em;
}
.bioage-unit {
  font-family: var(--ff-brand); font-size: 13px; letter-spacing: 0.10em;
  text-transform: uppercase; font-weight: 500; color: rgba(254,252,249,0.66);
}
.bioage-side { text-align: right; max-width: 320px; }
.bioage-phrase {
  font-size: 16px; font-weight: var(--fw-medium); letter-spacing: -0.005em;
  line-height: 1.3; color: var(--paper); text-wrap: pretty;
}
.bioage-chrono {
  font-size: 12px; color: rgba(254,252,249,0.6); margin-top: 8px;
}
.bioage-date {
  font-family: var(--ff-brand); font-size: 10.5px; letter-spacing: 0.06em;
  color: rgba(254,252,249,0.5); margin-top: 4px;
}

/* Status summary card — forest, mirrors the patient "Dados de saúde" card */
.exam-score {
  position: relative; overflow: hidden;
  background: var(--forest); color: var(--paper);
  border-radius: var(--r-lg); padding: 26px 26px 24px;
}
.exam-score::before {
  content: ""; position: absolute; top: -34%; right: -8%;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(116,176,168,0.32), transparent 65%);
  pointer-events: none;
}
.exam-score-eyebrow {
  position: relative; z-index: 1;
  font-family: var(--ff-brand); font-size: 11px; letter-spacing: 0.10em;
  text-transform: uppercase; font-weight: 500; color: rgba(254,252,249,0.72);
  margin-bottom: 16px;
}
.exam-score-cols { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); }
.exam-score-cols .scol { padding: 0 18px; border-right: 1px solid rgba(254,252,249,0.12); }
.exam-score-cols .scol:first-child { padding-left: 0; }
.exam-score-cols .scol:last-child { border-right: 0; }
.exam-score-cols .num {
  font-family: var(--ff-display); font-weight: var(--fw-thin);
  font-size: 56px; line-height: 1; letter-spacing: -0.019em;
}
.exam-score-cols .lbl {
  font-family: var(--ff-brand); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; font-weight: 500; opacity: 0.78; margin-top: 12px;
  display: flex; align-items: center; gap: 7px;
}
.exam-score-cols .lbl .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.exam-score-cols .scol.ok .dot   { background: var(--ok); }
.exam-score-cols .scol.warn .dot { background: var(--warn); }
.exam-score-cols .scol.risk .dot { background: var(--risk); }

/* Grouped editable marker list */
.exam-group + .exam-group { margin-top: 18px; }
.exam-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.exam-edit-list { display: flex; flex-direction: column; gap: 8px; }
.exam-row-edit {
  display: flex; align-items: flex-end; gap: 14px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--paper);
}
.exam-row-edit:hover { border-color: var(--line-2); }
.exam-row-id { flex: 1; min-width: 150px; align-self: center; }
.exam-row-nm { font-weight: var(--fw-medium); font-size: 14px; color: var(--ink); letter-spacing: -0.005em; }
.exam-row-cat { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.exam-row-field { display: flex; flex-direction: column; gap: 4px; }
.exam-row-field > label { font-family: var(--ff-brand); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: var(--fw-medium); }
.exam-row-field .input { width: 88px; padding: 7px 10px; }

/* Peptide Therapy table editor */
.pept-head, .pept-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 30px;
  gap: 10px;
  align-items: center;
}
.pept-head {
  padding: 0 2px 8px;
  font-family: var(--ff-brand); font-size: 10px; letter-spacing: 0.10em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 500;
}
.pept-row { margin-bottom: 8px; }
.pept-row .input { padding: 9px 12px; }

/* ============================================================
   Access gate (senha)
============================================================ */
.gate {
  position: fixed; inset: 0; z-index: 5000;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 28% 18%, rgba(116,176,168,0.22), transparent 55%),
    linear-gradient(160deg, #0B3D31 0%, #04261E 70%);
}
.gate-card {
  width: 380px; max-width: 100%;
  background: var(--paper);
  border-radius: var(--r-card);
  padding: 38px 34px 30px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.34), 0 4px 16px rgba(0,0,0,0.18);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.gate-logo { width: 46px; height: 46px; margin-bottom: 18px; }
.gate-eyebrow {
  font-family: var(--ff-brand); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 500;
}
.gate-title {
  font-family: var(--ff-display); font-weight: var(--fw-xlight);
  font-size: 30px; letter-spacing: -0.019em; line-height: 1.05;
  margin: 5px 0 10px; color: var(--ink);
}
.gate-sub {
  font-size: 13px; color: var(--ink-3); line-height: 1.55;
  margin: 0 0 22px; max-width: 290px;
}
.gate-input { text-align: center; height: 48px; font-size: 15px; }
.gate-input:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(4,38,30,0.08); }
.gate-err {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--risk-ink); background: var(--risk-bg);
  font-size: 12.5px; font-weight: var(--fw-medium);
  margin-top: 12px; padding: 7px 12px; border-radius: var(--r-pill);
}
.gate-err svg { width: 13px; height: 13px; stroke: var(--risk); }
.gate-btn { width: 100%; height: 48px; margin-top: 18px; justify-content: center; font-size: 14px; }
.gate-btn:disabled { opacity: 0.5; cursor: default; }
.gate-foot {
  margin-top: 24px;
  font-family: var(--ff-brand); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(254,252,249,0.5); font-weight: 500;
}

/* ============================================================
   Language selector
============================================================ */
.lang-select { position: relative; }
.lang-btn { gap: 8px; padding-left: 12px; padding-right: 10px; }
.lang-flag { font-size: 16px; line-height: 1; }
.lang-code { font-size: 12px; letter-spacing: 0.04em; font-weight: var(--fw-medium); }
.lang-btn svg { width: 13px; height: 13px; color: var(--ink-3); }
.lang-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-2);
  overflow: hidden; min-width: 230px; padding: 4px;
}
.lang-opt {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; background: transparent;
  border-radius: var(--r-sm); font-size: 13px; color: var(--ink);
  text-align: left; cursor: pointer; transition: background 120ms;
}
.lang-opt:hover { background: var(--paper-2); }
.lang-opt.active { background: var(--forest-tint); color: var(--forest); }
.lang-opt-label { flex: 1; }
.lang-opt svg { width: 14px; height: 14px; color: var(--forest); }

/* ============================================================
   Tablet — landscape editing (≤1366px). Keep all three panels
   side by side; tighten chrome and enlarge touch targets.
============================================================ */
@media (max-width: 1366px) {
  .body.with-preview {
    grid-template-columns: 196px minmax(0, 1.5fr) minmax(0, 1.12fr);
    gap: 10px;
    padding: 0 10px 10px;
  }
  .body { padding: 0 10px 10px; gap: 10px; }
  .editor { padding: 22px 22px 64px; }
  .editor-inner { max-width: 760px; }
  .statusbar { padding: 8px 16px 14px; gap: 12px; flex-wrap: wrap; }
  .statusbar .crumbs { display: none; }
  .sidebar { padding: 18px 10px; }
  .preview.pdf-preview { padding: 12px; }
  .section-header h1 { font-size: 27px; }
  /* Touch targets */
  .btn { height: 42px; }
  .btn.sm { height: 36px; }
  .btn.xs { height: 32px; }
  .step { padding: 12px 12px; font-size: 13px; }
  .period-tabs button { padding: 8px 13px; }
  .pdf-zoom-btn { padding: 7px 11px; }
}

/* Narrower tablets / split view — drop the sidebar to a slim rail of
   numbers so the editor + preview keep working. */
@media (max-width: 1100px) {
  .body.with-preview { grid-template-columns: 168px minmax(0, 1.4fr) minmax(0, 1fr); }
  .editor-inner { max-width: 100%; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .exam-row-edit { flex-wrap: wrap; gap: 10px 14px; }
  .exam-score-cols .num { font-size: 46px; }
}
