/* MedPally design system — built to Apple's Human Interface Guidelines: the
   system typeface and type scale, semantic colours that follow the system
   light/dark appearance, translucent navigation and tab bars, segmented
   controls, pull-down menus and inset grouped lists.

   The marketing site at the end of this file keeps a fixed light look of its
   own; the semantic colours only switch to dark on app pages (html.app). */

:root {
  color-scheme: light;

  /* Brand — the same in both appearances. */
  --brand: #123A4D;
  --brand-dark: #0D2A38;

  /* iOS system colours, light appearance. */
  --bg: #FFFFFF;
  --bg-grouped: #F2F2F7;
  --bg-elevated: #FFFFFF;
  --bg-secondary: #F2F2F7;
  --label: #000000;
  --label-body: #3A3A3C;
  --label-2: rgba(60, 60, 67, 0.62);
  --label-3: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.29);
  --fill: rgba(120, 120, 128, 0.2);
  --fill-3: rgba(118, 118, 128, 0.12);
  --fill-4: rgba(116, 116, 128, 0.08);
  --gray: #8E8E93;
  /* Tint is the brand's interactive teal; fills use a deeper shade so white
     text on them keeps its contrast in dark mode too. */
  --tint: #1C6E8C;
  --tint-fill: #1C6E8C;
  --tint-fill-hover: #155670;
  --tint-soft: rgba(28, 110, 140, 0.11);
  --red: #E5352B;
  --red-soft: rgba(255, 59, 48, 0.12);
  --green: #248A3D;
  --green-soft: rgba(52, 199, 89, 0.15);
  --bar-bg: rgba(255, 255, 255, 0.8);
  --bar-bg-grouped: rgba(242, 242, 247, 0.8);
  --menu-bg: rgba(250, 250, 252, 0.97);
  --menu-gap: rgba(60, 60, 67, 0.08);
  --segment-thumb: #FFFFFF;
  --toast-bg: rgba(28, 28, 30, 0.9);
  --shadow-menu: 0 12px 40px rgba(0, 0, 0, 0.16), 0 0 0 0.5px rgba(0, 0, 0, 0.08);

  --nav-bar-height: 44px;
  --nav-bar-offset: calc(var(--nav-bar-height) + env(safe-area-inset-top, 0px));
  --tab-bar-height: 50px;
  --tab-bar-offset: calc(var(--tab-bar-height) + env(safe-area-inset-bottom, 0px));
  --sidebar-width: 260px;
  --content-width: 600px;
  --gutter: 20px;
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);

  /* Names the marketing site still uses; fixed light values. */
  --primary: var(--brand);
  --primary-dark: var(--brand-dark);
  --accent: #1C6E8C;
  --border: #EFEFEF;
  --border-strong: #DBDBDB;
  --text: #1C1C1E;
  --text-secondary: #6E6E73;
  --text-muted: #9A9A9E;
}

html.app { color-scheme: light dark; }

@media (prefers-color-scheme: dark) {
  html.app {
    --bg: #000000;
    --bg-grouped: #000000;
    --bg-elevated: #1C1C1E;
    --bg-secondary: #1C1C1E;
    --label: #FFFFFF;
    --label-body: rgba(235, 235, 245, 0.86);
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.65);
    --fill: rgba(120, 120, 128, 0.36);
    --fill-3: rgba(118, 118, 128, 0.24);
    --fill-4: rgba(118, 118, 128, 0.18);
    --gray: #8E8E93;
    --tint: #6DBBDB;
    --tint-fill: #2A7FA1;
    --tint-fill-hover: #3290B5;
    --tint-soft: rgba(109, 187, 219, 0.16);
    --red: #FF453A;
    --red-soft: rgba(255, 69, 58, 0.18);
    --green: #30D158;
    --green-soft: rgba(48, 209, 88, 0.18);
    --bar-bg: rgba(22, 22, 23, 0.8);
    --bar-bg-grouped: rgba(22, 22, 23, 0.8);
    --menu-bg: rgba(44, 44, 46, 0.97);
    --menu-gap: rgba(0, 0, 0, 0.32);
    --segment-thumb: #636366;
    --toast-bg: rgba(58, 58, 60, 0.94);
    --shadow-menu: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 0.5px rgba(255, 255, 255, 0.1);
  }
}

* { box-sizing: border-box; }

/* Components set their own display, which would otherwise outrank the UA's
   [hidden] rule and leave hidden controls on screen. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}
/* Grouped screens (Account and its settings) sit on the grey grouped
   background, which has to reach the overscroll area as well. */
html:has(#app-main.grouped) { background: var(--bg-grouped); }
html:has(body.is-landing) { background: var(--brand-dark); }

body {
  background: var(--bg);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body:has(#app-main.grouped) { background: var(--bg-grouped); }

a { color: var(--tint); text-decoration: none; }
a, button, summary, label { touch-action: manipulation; }

h1, h2, h3 { color: var(--label); margin: 0 0 0.4em; }

.app-main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 4px max(var(--gutter), env(safe-area-inset-right, 0px)) 40px max(var(--gutter), env(safe-area-inset-left, 0px));
  min-height: 100vh;
  min-height: 100dvh;
}
.app-main:focus { outline: none; }
.app-main.has-bottom-nav { padding-bottom: calc(var(--tab-bar-offset) + 32px); }
body:not(.has-app-chrome) .app-main { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }

/* Kept intentionally close to the feed layout, so a cold screen still feels
   responsive rather than flashing an empty page. */
.page-loading { padding: 8px 0; }
.skeleton, .skeleton-card {
  background: linear-gradient(90deg, var(--fill-4) 25%, var(--fill-3) 37%, var(--fill-4) 63%);
  background-size: 400% 100%; animation: skeleton-shimmer 1.2s ease infinite;
}
.skeleton { border-radius: 6px; }
.skeleton-title { width: 180px; height: 34px; margin: 6px var(--gutter) 10px; border-radius: 8px; }
.skeleton-subtitle { width: 100px; height: 14px; margin: 0 var(--gutter) 22px; }
.skeleton-card { min-height: 170px; padding: 18px var(--gutter); margin: 0; background: var(--bg); }
.skeleton-line { width: 56%; height: 14px; margin-bottom: 11px; }
.skeleton-line-short { width: 24%; height: 11px; margin-bottom: 20px; }
.skeleton-copy { width: 95%; height: 13px; margin-bottom: 8px; }
.skeleton-copy-short { width: 73%; }
@keyframes skeleton-shimmer { to { background-position: -400% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton, .skeleton-card { animation: none; } }

/* ---------------------------------------------------------------- navigation bar */

.nav-bar {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  background: transparent;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  view-transition-name: nav-bar;
}
/* Transparent over the large title; frosted, with a hairline, once content
   passes underneath — the iOS scroll-edge appearance. */
.nav-bar.is-scrolled {
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0.5px 0 var(--separator);
}
html:has(#app-main.grouped) .nav-bar.is-scrolled { background: var(--bar-bg-grouped); }
/* A tab's root screen keeps its actions beside the large title, so its bar
   is empty until content scrolls under it. It floats over the page rather
   than holding an empty strip above the title, and lets taps through while
   it is still transparent. */
.nav-bar.is-overlay { margin-bottom: calc(-1 * var(--nav-bar-height)); }
.nav-bar.is-overlay:not(.is-scrolled) { pointer-events: none; }
.nav-bar.is-overlay ~ .app-main { padding-top: 10px; }

.nav-bar-inner {
  position: relative; display: flex; align-items: center;
  max-width: var(--content-width); height: var(--nav-bar-height); margin: 0 auto;
  padding: 0 max(8px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px));
}
.nav-bar-leading, .nav-bar-trailing {
  position: relative; z-index: 1; flex: 1 1 0; display: flex; align-items: center; min-width: max-content;
}
.nav-bar-trailing { justify-content: flex-end; }
.nav-bar-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 200px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 17px; font-weight: 600; color: var(--label);
  opacity: 0; transition: opacity 0.2s ease;
}
.nav-bar.is-collapsed .nav-bar-title { opacity: 1; }

.nav-back {
  display: inline-flex; align-items: center; gap: 6px; height: 44px;
  padding: 0 8px 0 6px; color: var(--tint); font-size: 17px;
  transition: opacity 0.15s ease;
}
.nav-back:active { opacity: 0.35; }

.nav-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--tint); cursor: pointer; list-style: none;
  transition: opacity 0.15s ease;
}
.nav-icon-btn::-webkit-details-marker { display: none; }
.nav-icon-btn:active { opacity: 0.35; }

/* Onboarding and sign-in screens have no bar, so their back link sits in the
   page and looks like the bar's. */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 44px;
  margin: 0 0 4px -6px; padding: 0 8px 0 6px; color: var(--tint); font-size: 17px;
}
.back-btn:active { opacity: 0.35; }

/* ---------------------------------------------------------------- large titles */

.page-header { padding: 2px 0 14px; }
.page-eyebrow {
  margin: 0; font-size: 13px; font-weight: 600; line-height: 18px;
  color: var(--label-2); text-transform: uppercase; letter-spacing: 0.02em;
}
.page-title {
  margin: 0; font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: 0.011em;
  color: var(--label);
}
.page-subtitle { margin: 2px 0 0; font-size: 15px; line-height: 20px; color: var(--label-2); }
.page-title-row { display: flex; align-items: center; gap: 12px; }
.page-title-row .page-title { flex: 1; min-width: 0; }
/* A round tinted action beside a large title, like the App Store's account
   button. Filled while it has something applied (a filter). */
.title-action-btn {
  position: relative; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--tint-soft); color: var(--tint); cursor: pointer; list-style: none;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s var(--ease-ios);
}
.title-action-btn::-webkit-details-marker { display: none; }
.title-action-btn::after { content: ""; position: absolute; inset: -4px; }
.title-action-btn:active { transform: scale(0.9); }
.title-action-btn:hover { color: var(--tint); }
.title-action-btn.is-active, .title-action-btn.is-active:hover { background: var(--tint-fill); color: #fff; }
.wizard-step {
  margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--tint);
  letter-spacing: 0.04em; text-transform: uppercase;
}

/* ---------------------------------------------------------------- segmented control */

.segmented {
  position: relative; display: flex; margin-top: 14px; padding: 2px;
  border-radius: 9px; background: var(--fill-3);
}
.segmented-item {
  position: relative; flex: 1 1 0; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 28px; padding: 0 8px; border: 0; border-radius: 7px; background: none;
  color: var(--label); font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1;
  white-space: nowrap; cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}
.segmented-item + .segmented-item::before {
  content: ""; position: absolute; left: -0.5px; top: 7px; bottom: 7px; width: 1px;
  background: var(--fill); transition: opacity 0.2s ease;
}
.segmented-item.is-selected,
.segmented-item.is-active {
  background: var(--segment-thumb); font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
}
.segmented-item.is-selected::before, .segmented-item.is-selected + .segmented-item::before,
.segmented-item.is-active::before, .segmented-item.is-active + .segmented-item::before { opacity: 0; }
.segmented-item:hover { color: var(--label); }

.filter-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 12px; padding: 9px 14px; border-radius: 10px;
  background: var(--tint-soft); color: var(--tint); font-size: 14px; font-weight: 600;
}
.filter-summary a { color: var(--tint); font-weight: 600; }

/* ---------------------------------------------------------------- pull-down menus */

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; z-index: 40; top: calc(100% + 4px);
  min-width: 240px; max-width: min(300px, calc(100vw - 24px));
  border-radius: 13px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  background: var(--menu-bg);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  box-shadow: var(--shadow-menu);
  transform-origin: top right;
  animation: menu-in 0.2s var(--ease-ios);
}
.menu-panel-end { right: 0; }
.menu.opens-up .menu-panel { top: auto; bottom: calc(100% + 4px); transform-origin: bottom right; }
@keyframes menu-in { from { opacity: 0; transform: scale(0.9); } }
.menu-section-title {
  padding: 9px 16px 5px; font-size: 13px; color: var(--label-2);
}
.menu-section-title:not(:first-child) { border-top: 8px solid var(--menu-gap); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px;
  padding: 11px 16px; border: 0; background: none; color: var(--label);
  font-family: inherit; font-size: 16px; line-height: 1.25; text-align: left; text-decoration: none;
  cursor: pointer;
}
.menu-panel form { margin: 0; }
.menu-item + .menu-item, .menu-item + form .menu-item, form + .menu-item {
  box-shadow: inset 0 0.5px 0 var(--separator);
}
.menu-item:hover, .menu-item:active { background: var(--fill-3); color: var(--label); }
.menu-item-icon { margin-left: auto; flex-shrink: 0; }
.menu-item-destructive, .menu-item-destructive:hover, .menu-item-destructive:active { color: var(--red); }
.menu-item[aria-checked] { padding-left: 12px; }
.menu-check { width: 18px; height: 18px; flex-shrink: 0; }
.menu-item[aria-checked="true"] .menu-check {
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 12.5l5 5L19.5 7'/%3E%3C/svg%3E") center / 15px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 12.5l5 5L19.5 7'/%3E%3C/svg%3E") center / 15px no-repeat;
}

/* ---------------------------------------------------------------- feed list */

.app-main.feed-flush { padding-left: 0; padding-right: 0; }
.feed-flush .page-header, .feed-flush .messages, .feed-flush .empty-state {
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

/* A week heading is a card-level object, so it carries its own gutter like
   .card does. It sticks under the bar while its week scrolls past, as section
   headers do in an iOS list. */
.week-header {
  position: sticky; top: var(--nav-bar-offset); z-index: 5;
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left;
  padding: 9px var(--gutter) 8px; border: 0;
  background: var(--bg); box-shadow: inset 0 -0.5px 0 var(--separator), inset 0 0.5px 0 var(--separator);
  font-family: inherit; font-size: 13px; font-weight: 600; line-height: 18px;
  color: var(--label-2); text-transform: uppercase; letter-spacing: 0.02em;
  cursor: pointer;
}
.week-header:active { background: var(--bg-secondary); }
/* Explicit rather than relying on the UA [hidden] rule, which any later
   display declaration on .card would silently outrank. */
.card[hidden] { display: none; }
.week-count { font-weight: 500; }
.week-chevron { margin-left: auto; color: var(--label-3); transition: transform 0.2s var(--ease-ios); }
.week-header[aria-expanded="false"] .week-chevron { transform: rotate(-90deg); }
@media (prefers-reduced-motion: reduce) { .week-chevron { transition: none; } }

/* Loading the next page is a request once anything below is collapsed: hidden
   cards have almost no height, so scrolling can't be what asks for them. */
.feed-more {
  display: block; width: 100%; padding: 16px var(--gutter); border: 0; background: none;
  font-family: inherit; font-size: 17px; color: var(--tint); cursor: pointer; text-align: center;
}
.feed-more:active { background: var(--fill-4); }

/* The sentinel stands in for the page that hasn't arrived yet, so it borrows
   the loading skeleton and sits in the list like a real card would. */
.feed-sentinel .skeleton-card { margin: 0; }

/* ---------------------------------------------------------------- cards */

.card {
  position: relative;
  padding: 14px var(--gutter) 4px;
  background: var(--bg);
  transition: background-color 0.15s ease;
}
/* Inset hairline separators, like an iOS list. */
.card::after {
  content: ""; position: absolute; left: var(--gutter); right: 0; bottom: 0; height: 1px;
  background: var(--separator); transform: scaleY(0.5); transform-origin: bottom;
}
/* The whole card is the tap target (the title link stretches over it), so it
   highlights like a table cell when pressed. */
.card:has(.card-title a:active) { background: var(--fill-4); }
@media (hover: hover) {
  .card:has(.card-title a:hover) { background: var(--fill-4); }
}
.card:has(.card-title a:focus-visible) { outline: 2px solid var(--tint); outline-offset: -2px; }
/* An open menu has to sit above the cards that follow it. */
.card:has(details[open]) { z-index: 6; }

.card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-header .journal-cover { border-radius: 7px; flex-shrink: 0; }
.card-source { flex: 1; min-width: 0; }
.card-journal {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; font-weight: 600; line-height: 17px; color: var(--label);
}
.card-date { font-size: 12px; line-height: 16px; color: var(--label-2); }
/* nowrap so the star stays beside the design badge instead of dropping under
   it — a two-word label like "Prospective cohort" wraps inside its own box
   rather than pushing the star onto a second row. */
.card-badges {
  margin-left: auto; display: flex; flex-wrap: nowrap; align-items: center; gap: 6px;
  justify-content: flex-end; flex-shrink: 0;
}
.badge {
  display: inline-block; padding: 3px 7px; border-radius: 6px;
  background: var(--green-soft); color: var(--green);
  font-size: 11px; font-weight: 700; line-height: 14px; letter-spacing: 0.01em; white-space: nowrap;
}
/* A paper the reader brought in from outside their feed. */
.badge-external { background: var(--fill-3); color: var(--label-2); }
.summary-pending { color: var(--label-2); font-style: italic; }
/* Featured repeats on every pick, so it's a mark rather than a second word
   badge — the design label is what the eye is actually scanning for. */
.featured-star { display: inline-flex; align-items: center; flex-shrink: 0; color: #F5A623; }
.new-divider {
  margin-bottom: 8px; color: var(--tint); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em;
}

.card-title { margin: 0 0 6px; font-size: 17px; line-height: 22px; font-weight: 600; }
.card-title a { color: var(--label); }
.card-title a:focus-visible { outline: none; }
.card-title a::after { content: ""; position: absolute; inset: 0; }
.card.seen .card-title a, .card.seen .summary { color: var(--label-2); }

.summary { margin: 0 0 10px; font-size: 15px; line-height: 20px; color: var(--label-body); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 4px; padding: 0; list-style: none; }
.tag {
  display: inline-block; padding: 3px 9px; border-radius: 100px;
  background: var(--fill-3); color: var(--label-2); font-size: 12px; font-weight: 500; line-height: 16px;
}

/* Buttons and menus sit above the stretched title link. */
.card-actions {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 2px; margin: 0 -12px;
}
.card-actions .spacer { flex: 1; }
.action-form { display: inline-flex; margin: 0; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 11px; border: 0; border-radius: 22px;
  background: none; color: var(--label-2); cursor: pointer; list-style: none;
  font-family: inherit; font-size: 15px; font-weight: 500;
}
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn svg { display: block; flex-shrink: 0; transition: transform 0.15s var(--ease-ios); }
.icon-btn:active svg { transform: scale(0.84); }
@media (hover: hover) { .icon-btn:hover { background: var(--fill-4); color: var(--label); } }
.icon-btn-save.is-active, .icon-btn-save.is-active:hover { color: var(--tint); }
.icon-btn-like.is-active, .icon-btn-like.is-active:hover { color: var(--red); }
/* In a card the glyph is the whole button; the word stays for screen readers. */
.card .icon-btn-label {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap;
}

/* Kept just outside the feed column on wide screens and tucked against the
   viewport edge on phones. It clears the tab bar in both. */
.back-to-top {
  position: fixed; z-index: 12;
  right: max(16px, calc((100vw - var(--content-width)) / 2 - 60px));
  bottom: calc(var(--tab-bar-offset) + 16px);
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: var(--bar-bg); color: var(--tint);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14), 0 0 0 0.5px var(--separator);
  cursor: pointer;
}
.back-to-top:active { transform: scale(0.92); }
.back-to-top[hidden] { display: none; }

/* ---------------------------------------------------------------- paper detail */

.app-main.detail { padding-top: 6px; }
.detail-source { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.detail-source .journal-cover { border-radius: 10px; flex-shrink: 0; }
.detail-source .card-journal { font-size: 15px; line-height: 20px; white-space: normal; }
.detail-source .card-date { font-size: 13px; line-height: 18px; }
.detail-title {
  margin: 0 0 20px; font-size: 26px; line-height: 32px; font-weight: 700; letter-spacing: 0.004em;
}
.detail-summary { margin: 0 0 14px; }
.detail-section { margin: 0 0 16px; }
.detail-section dt {
  margin: 0 0 3px; font-size: 13px; font-weight: 600; line-height: 18px;
  color: var(--label-2); text-transform: uppercase; letter-spacing: 0.03em;
}
.detail-section dd { margin: 0; font-size: 17px; line-height: 25px; color: var(--label); }
/* "So what" is the line a clinician reads first, so it is set apart. */
.detail-section-callout { padding: 14px 16px; border-radius: 14px; background: var(--tint-soft); }
.detail-section-callout dt { color: var(--tint); }
.summary-disclaimer {
  margin: 4px 0 20px; color: var(--label-2); font-size: 12px; font-style: italic; line-height: 1.4;
}
.detail-pending {
  display: flex; align-items: center; gap: 12px; margin: 0 0 20px; padding: 16px;
  border-radius: 14px; background: var(--bg-secondary); color: var(--label-2);
  font-size: 15px; line-height: 20px;
}
.detail-pending-spinner {
  flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--fill); border-top-color: var(--tint);
  animation: button-spin 0.8s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .detail-pending-spinner { animation: none; } }
.detail-actions { display: flex; gap: 10px; margin: 0 0 12px; }
.detail-actions .action-form { flex: 1; }
.detail-actions .icon-btn {
  width: 100%; height: 50px; border-radius: 12px;
  background: var(--fill-3); color: var(--label); font-size: 17px; font-weight: 600;
}
.detail-actions .icon-btn-save.is-active { background: var(--tint-soft); color: var(--tint); }
.detail-actions .icon-btn-like.is-active { background: var(--red-soft); color: var(--red); }

.public-brand {
  display: inline-flex; align-items: center; gap: 8px; margin: 4px 0 20px;
  color: var(--label); font-size: 17px; font-weight: 700;
}
.public-cta { margin-top: 28px; padding: 18px; border-radius: 14px; background: var(--bg-secondary); text-align: center; }
.public-cta p { margin: 0 0 12px; color: var(--label-2); font-size: 15px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border: 0; border-radius: 12px;
  font-family: inherit; font-size: 17px; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}
.btn:active { opacity: 0.72; }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--tint-fill); color: #FFFFFF; }
.btn-primary:hover { background: var(--tint-fill-hover); color: #FFFFFF; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-tinted { background: var(--tint-soft); color: var(--tint); }
.btn-tinted:hover { color: var(--tint); }
.btn-danger { background: var(--red); color: #FFFFFF; }
.btn-danger:hover { color: #FFFFFF; }
.btn-outline { background: transparent; color: var(--tint); box-shadow: inset 0 0 0 1px var(--tint); }
.btn-outline-light { background: transparent; color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45); }
.btn-outline-light:hover { color: #fff; }
.btn-soft { background: var(--fill-3); color: var(--label); }
.btn-white { background: #fff; color: var(--brand); }
.btn-white:hover { color: var(--brand-dark); }
.btn-text {
  padding: 10px; border: 0; background: none; color: var(--tint);
  font-family: inherit; font-size: 17px; cursor: pointer;
}
.btn-text-danger {
  padding: 10px; border: 0; background: none; color: var(--red);
  font-family: inherit; font-size: 17px; cursor: pointer;
}
.btn-sm { min-height: 34px; padding: 0 16px; border-radius: 100px; font-size: 15px; }
.btn.is-loading { cursor: wait; opacity: 0.8; }
.button-spinner {
  width: 16px; height: 16px; border: 2px solid rgb(255 255 255 / 45%); border-top-color: #fff;
  border-radius: 50%; animation: button-spin 0.7s linear infinite;
}
@keyframes button-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- forms */

.field { margin-bottom: 16px; }
.field label, .field-label {
  display: block; margin: 0 0 6px 4px; font-size: 13px; font-weight: 600; color: var(--label-2);
}
.field .hint { color: var(--label-2); font-weight: 400; }

/* 17px keeps iOS Safari from zooming the page whenever a field is focused. */
input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], textarea {
  width: 100%; min-height: 44px; padding: 11px 14px; border: 0; border-radius: 10px;
  background: var(--fill-3); color: var(--label); font-family: inherit; font-size: 17px;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus,
input[type=search]:focus, input[type=url]:focus, textarea:focus {
  outline: 2px solid var(--tint); outline-offset: 0;
}
input::placeholder, textarea::placeholder { color: var(--label-3); }

.errorlist { list-style: none; padding: 0; margin: 0 0 8px; color: var(--red); font-size: 13px; }
.errorlist li { margin-bottom: 2px; }

.form-status { min-height: 0; color: var(--label-2); font-size: 13px; }
.form-status:not(:empty) { margin: 0 0 8px; }
.form-status.is-error { padding: 10px 12px; border-radius: 10px; background: var(--red-soft); color: var(--red); }
.form-submit { margin-top: 24px; }

/* ---------------------------------------------------------------- inset grouped lists */

.inset-list { margin: 0; border-radius: 10px; background: var(--bg-elevated); overflow: hidden; }
/* On a white screen the list takes the secondary fill, as a sheet's does. */
.app-main:not(.grouped) .inset-list { background: var(--bg-secondary); }
.inset-list > * { position: relative; margin: 0; }
.inset-list > :not(:first-child)::before {
  content: ""; position: absolute; z-index: 1; top: 0; right: 0; left: 16px; height: 1px;
  background: var(--separator); transform: scaleY(0.5); transform-origin: top;
}
.inset-list > :not(:first-child):has(.row-icon)::before { left: 58px; }
.inset-list-spaced { margin-top: 36px; }

.inset-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px;
  padding: 11px 16px; border: 0; background: none; color: var(--label);
  font-family: inherit; font-size: 17px; line-height: 22px; text-align: left; text-decoration: none;
}
a.inset-row, button.inset-row, label.inset-row { cursor: pointer; }
a.inset-row:active, button.inset-row:active, label.inset-row:active { background: var(--fill-3); }
@media (hover: hover) {
  a.inset-row:hover, button.inset-row:hover, label.inset-row:hover { background: var(--fill-4); color: var(--label); }
}
.inset-row-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.inset-row-label { font-size: 17px; color: var(--label); }
.inset-row-detail {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; line-height: 18px; color: var(--label-2);
}
.inset-row-value {
  flex-shrink: 0; display: flex; align-items: center; gap: 4px;
  font-size: 17px; color: var(--label-2); white-space: nowrap;
}
.inset-row-value.is-verified { color: var(--green); }
.inset-row-value.is-action { color: var(--tint); }
.inset-row-center { justify-content: center; text-align: center; }
.inset-row-destructive, .inset-row-destructive:hover { color: var(--red); }
.chevron { flex-shrink: 0; color: var(--label-3); }
.row-icon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 30px; height: 30px; border-radius: 7px; color: #FFFFFF;
}
.row-icon-blue { background: #1C7FA6; }
.row-icon-red { background: #FF3B30; }
.row-icon-green { background: #34C759; }

.list-section-title {
  margin: 26px 16px 7px; font-size: 13px; font-weight: 400; line-height: 18px;
  color: var(--label-2); text-transform: uppercase; letter-spacing: 0.01em;
}
.list-section-footer { margin: 7px 16px 0; font-size: 13px; line-height: 18px; color: var(--label-2); }
.list-section-errors:not(:empty) { margin: 8px 16px 0; }

/* Text fields inside a grouped list: the cell is the field. */
.form-row { display: flex; flex-direction: column; gap: 1px; padding: 9px 16px 8px; cursor: text; }
.form-row-label { font-size: 13px; line-height: 18px; color: var(--label-2); }
.form-row:focus-within .form-row-label { color: var(--tint); }
.form-row input[type=text], .form-row input[type=email], .form-row input[type=url] {
  min-height: 0; padding: 1px 0 2px; border-radius: 0; background: none;
}
.form-row input:focus { outline: none; }

/* A single choice from a list: a checkmark on the chosen row. */
.option-check input[type=radio] {
  position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none;
}
.option-check .checkmark { flex-shrink: 0; color: var(--tint); opacity: 0; }
.option-check:has(input:checked) .checkmark { opacity: 1; }
.option-check:has(input:focus-visible) { outline: 2px solid var(--tint); outline-offset: -2px; }

/* ---------------------------------------------------------------- account */

.account-profile-row { gap: 14px; padding-top: 12px; padding-bottom: 12px; }
.avatar {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(180deg, #2C7A99 0%, var(--brand) 100%); color: #fff;
  font-size: 15px; font-weight: 600; letter-spacing: 0.02em;
}
.avatar-lg { width: 60px; height: 60px; font-size: 22px; }
.avatar-sm { width: 36px; height: 36px; font-size: 13px; }
.account-name { font-size: 20px; font-weight: 600; line-height: 25px; color: var(--label); }
.account-email, .account-profile-meta {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; line-height: 18px; color: var(--label-2);
}
.account-danger-link { margin-top: 20px; text-align: center; }

/* ---------------------------------------------------------------- journals */

.journal-picker-form { padding-bottom: 96px; }
.journal-search {
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px;
  border-radius: 10px; background: var(--fill-3); color: var(--label-2);
}
.journal-search:focus-within { outline: 2px solid var(--tint); outline-offset: 0; }
.journal-search input[type=search] {
  flex: 1; min-width: 0; min-height: 0; height: 100%; padding: 0; border: 0;
  background: transparent; color: var(--label); font-size: 17px; outline: none;
}
.journal-search-clear {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 18px; height: 18px; padding: 0 0 1px; border: 0; border-radius: 50%;
  background: var(--label-3); color: var(--bg); font-family: inherit; font-size: 15px; line-height: 1;
  cursor: pointer;
}
.journal-filters { margin: 12px 0 10px; }
.journal-filter span { color: var(--label-2); font-variant-numeric: tabular-nums; }
.journal-selection-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 4px 12px; color: var(--label-2); font-size: 13px;
}
.journal-selection-summary strong { color: var(--label); }
.journal-selection-summary button {
  padding: 6px 0; border: 0; background: none; color: var(--tint);
  font-family: inherit; font-size: 15px; white-space: nowrap; cursor: pointer;
}
.journal-selection-summary button:disabled { color: var(--label-3); cursor: default; }
.journal-results { min-height: 150px; }
.journal-group { margin: 0 0 16px; border-radius: 10px; background: var(--bg-elevated); overflow: hidden; }
.journal-group-title {
  margin: 0 0 8px; font-size: 13px; color: var(--label-2); text-transform: uppercase;
}
.journal-group-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; cursor: pointer; list-style: none;
}
.journal-group-summary::-webkit-details-marker { display: none; }
.journal-group-summary > span { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.journal-group-summary svg { flex-shrink: 0; color: var(--label-3); transition: transform 0.2s var(--ease-ios); }
.journal-group[open] > .journal-group-summary svg { transform: rotate(180deg); }
.journal-group-name { font-size: 17px; font-weight: 600; color: var(--label); }
.journal-group-description { font-size: 13px; color: var(--label-2); }
.journal-group-body { padding-left: 16px; }
.journal-row, .journal-group-toggle {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; padding: 10px 16px 10px 0; cursor: pointer;
}
.journal-row::before, .journal-group-toggle::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: var(--separator); transform: scaleY(0.5); transform-origin: top;
}
.journal-name-copy, .journal-group-toggle-copy { min-width: 0; display: flex; flex-direction: column; }
.journal-row .journal-name { font-size: 17px; color: var(--label); }
.journal-short-name { font-size: 13px; color: var(--label-2); }
.journal-group-toggle-title { font-size: 17px; color: var(--tint); }
.journal-group-toggle-detail { font-size: 13px; color: var(--label-2); }
.journal-checkbox { position: relative; width: 24px; height: 24px; flex-shrink: 0; }
.journal-checkbox input {
  position: absolute; inset: 0; width: 24px; height: 24px; margin: 0; opacity: 0; cursor: pointer;
}
.journal-checkbox .box {
  display: flex; align-items: center; justify-content: center; pointer-events: none;
  width: 24px; height: 24px; border-radius: 50%; color: #fff;
  box-shadow: inset 0 0 0 1.5px var(--label-3);
  transition: background-color 0.15s ease;
}
.journal-checkbox input:checked ~ .box,
.journal-checkbox input:indeterminate ~ .box { background: var(--tint-fill); box-shadow: none; }
.journal-checkbox .box svg { opacity: 0; }
.journal-checkbox input:checked ~ .box svg { opacity: 1; }
.journal-checkbox input:indeterminate ~ .box svg { opacity: 0; }
.journal-checkbox input:indeterminate ~ .box::after {
  content: ""; width: 11px; height: 2px; border-radius: 2px; background: #fff;
}
.journal-checkbox input:focus-visible ~ .box { outline: 2px solid var(--tint); outline-offset: 2px; }
.journal-empty {
  min-height: 170px; padding: 28px 16px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; color: var(--label-2);
}
.journal-empty[hidden] { display: none; }
[data-journal-row][hidden], [data-journal-section][hidden] { display: none; }
.journal-empty strong { margin-top: 8px; color: var(--label); font-size: 17px; }
.journal-empty span { font-size: 13px; }

.settings-save-bar {
  position: fixed; z-index: 9; left: 0; right: 0; bottom: var(--tab-bar-offset);
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: var(--bar-bg-grouped);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -0.5px 0 var(--separator);
}
.settings-save-bar > * { max-width: calc(var(--content-width) - 2 * var(--gutter)); margin-left: auto; margin-right: auto; }
.settings-save-bar.is-onboarding { bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }

/* ---------------------------------------------------------------- search */

.search-bar {
  display: flex; align-items: center; gap: 6px; height: 40px; margin-top: 10px;
  padding: 0 4px 0 10px; border-radius: 10px; background: var(--fill-3); color: var(--label-2);
}
.search-bar:focus-within { outline: 2px solid var(--tint); outline-offset: 0; }
.search-bar svg { flex-shrink: 0; }
.search-bar input[type=search] {
  flex: 1; min-width: 0; min-height: 0; height: 100%; padding: 0; border: 0;
  background: none; color: var(--label); font-size: 17px; outline: none;
}
.search-bar-submit {
  display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%;
  background: var(--tint-fill); color: #fff; cursor: pointer;
}
.search-bar-submit:active { opacity: 0.7; }

.add-paper-message {
  margin: 0 0 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--bg-secondary); color: var(--label); font-size: 15px; line-height: 20px;
}
.add-paper-message.is-error { background: var(--red-soft); }
.add-paper-preview { align-items: flex-start; padding-top: 14px; padding-bottom: 14px; }
.add-paper-source { font-size: 13px; line-height: 18px; color: var(--label-2); }
.add-paper-title { margin: 3px 0 6px; font-size: 17px; line-height: 22px; font-weight: 600; color: var(--label); }
.add-paper-status { font-size: 13px; line-height: 18px; color: var(--tint); }
.add-paper-tip { margin-top: 18px; }

.recent-searches { margin-top: 8px; }
.recent-searches .list-section-title { margin-left: 16px; }
.recent-search-title {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 17px; color: var(--label);
}
.recent-search-meta { display: block; font-size: 13px; color: var(--label-2); }
.recent-search-empty { margin: 0 16px; color: var(--label-2); font-size: 15px; }

/* ---------------------------------------------------------------- empty states */

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 64px 32px;
}
.empty-state-icon {
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
  width: 60px; height: 60px; border-radius: 50%; background: var(--fill-3); color: var(--label-2);
}
.empty-state h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; color: var(--label); }
.empty-state p { max-width: 290px; margin: 0 auto; font-size: 15px; line-height: 20px; color: var(--label-2); }
.empty-state-action {
  margin-top: 18px; padding: 10px 18px; border-radius: 100px;
  background: var(--tint-soft); color: var(--tint); font-size: 15px; font-weight: 600;
}

/* ---------------------------------------------------------------- messages, toast */

.messages { list-style: none; padding: 0; margin: 4px 0 14px; }
.messages li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  margin-bottom: 8px; padding: 12px 14px; border-radius: 12px;
  background: var(--green-soft); color: var(--label); font-size: 15px;
}
.messages li.error, .messages li.warning { background: var(--red-soft); }
.message-action { color: var(--tint); font-size: 15px; font-weight: 600; white-space: nowrap; }
/* app.js takes the list away five seconds after it appears; this is the fade
   on the way out. */
.messages[data-autodismiss] { transition: opacity 0.4s ease; }
.messages[data-autodismiss].is-dismissed { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .messages[data-autodismiss] { transition: none; } }

.toast {
  position: fixed; z-index: 50; left: 50%;
  bottom: calc(var(--tab-bar-offset) + 18px);
  padding: 11px 20px; border-radius: 100px;
  background: var(--toast-bg); color: #fff; font-size: 15px; font-weight: 600;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
  opacity: 0; transform: translate(-50%, 10px);
  transition: opacity 0.22s ease, transform 0.22s var(--ease-ios);
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[hidden] { display: none; }
body:not(.has-app-chrome) .toast { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }

/* ---------------------------------------------------------------- tab bar */

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -0.5px 0 var(--separator);
  view-transition-name: tab-bar;
}
.bottom-nav-inner {
  display: flex; max-width: var(--content-width); height: var(--tab-bar-height); margin: 0 auto;
  padding: 0 env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  padding-top: 2px; color: var(--gray); text-decoration: none;
}
.bottom-nav a span { font-size: 10px; font-weight: 500; line-height: 12px; letter-spacing: 0.01em; }
.bottom-nav a.is-active { color: var(--tint); }
.tab-icon { display: block; transition: transform 0.15s var(--ease-ios); }
.tab-icon-filled, .bottom-nav a.is-active .tab-icon-outline { display: none; }
.bottom-nav a.is-active .tab-icon-filled { display: block; }
.bottom-nav a:active .tab-icon { transform: scale(0.88); }

/* ---------------------------------------------------------------- sidebar (wide screens) */

.sidebar { display: none; }
.brand-tile {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 26px; height: 26px; border-radius: 7px; background: var(--brand); color: #fff;
}
.brand-tile .logo-glyph { width: 12.5px; }

@media (min-width: 1024px) {
  body.has-app-chrome { padding-left: var(--sidebar-width); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 30;
    display: flex; flex-direction: column; width: var(--sidebar-width);
    padding: calc(16px + env(safe-area-inset-top, 0px)) 12px 16px;
    background: var(--bg-secondary); box-shadow: 0.5px 0 0 var(--separator);
    view-transition-name: sidebar;
  }
  html:has(#app-main.grouped) .sidebar { background: var(--bg-elevated); }
  .sidebar-brand {
    display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px;
    color: var(--label); font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
  }
  .sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
  .sidebar-link {
    display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px;
    color: var(--label); font-size: 15px; font-weight: 500;
  }
  .sidebar-link svg { flex-shrink: 0; color: var(--tint); }
  .sidebar-link:hover { background: var(--fill-4); color: var(--label); }
  .sidebar-link.is-active, .sidebar-link.is-active:hover { background: var(--tint-fill); color: #fff; }
  .sidebar-link.is-active svg { color: #fff; }
  .sidebar-footer {
    display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; color: var(--label);
  }
  .sidebar-footer:hover { background: var(--fill-4); color: var(--label); }
  .sidebar-user { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .sidebar-user-name, .sidebar-user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar-user-name { font-size: 14px; font-weight: 600; }
  .sidebar-user-email { font-size: 12px; color: var(--label-2); }

  .bottom-nav { display: none; }
  .app-main.has-bottom-nav { padding-bottom: 56px; }
  .back-to-top {
    bottom: 28px;
    right: max(24px, calc((100vw - var(--sidebar-width) - var(--content-width)) / 2 - 64px));
  }
  .settings-save-bar { left: var(--sidebar-width); bottom: 0; }
  .toast { left: calc(50% + var(--sidebar-width) / 2); bottom: 32px; }
}

/* ---------------------------------------------------------------- push / pop transitions */

/* app.js marks the direction on <html> and starts a view transition; the
   page slides like a navigation controller while the bars stay put. */
::view-transition-old(root), ::view-transition-new(root) { mix-blend-mode: normal; }
:root[data-nav-direction="forward"]::view-transition-old(root) {
  animation: 0.4s var(--ease-ios) both vt-recede-left;
}
:root[data-nav-direction="forward"]::view-transition-new(root) {
  animation: 0.4s var(--ease-ios) both vt-enter-right;
}
:root[data-nav-direction="back"]::view-transition-old(root) {
  z-index: 1; animation: 0.4s var(--ease-ios) both vt-exit-right;
}
:root[data-nav-direction="back"]::view-transition-new(root) {
  animation: 0.4s var(--ease-ios) both vt-return-left;
}
@keyframes vt-enter-right { from { transform: translateX(100%); } }
@keyframes vt-recede-left { to { transform: translateX(-30%); filter: brightness(0.9); } }
@keyframes vt-exit-right { to { transform: translateX(100%); } }
@keyframes vt-return-left { from { transform: translateX(-30%); filter: brightness(0.9); } }

/* ---------------------------------------------------------------- welcome / landing */

/* The hero is the whole page: no gutter, no rounded corner, and it runs
   under the notch and the home indicator rather than stopping at them. The
   body carries the same colour so overscroll and the iOS status bar area do
   not flash white either. */
body.is-landing { background: var(--brand-dark); }
.app-main.landing-flush { max-width: none; padding: 0; }

.welcome-hero {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding:
    calc(48px + env(safe-area-inset-top, 0px))
    calc(24px + env(safe-area-inset-right, 0px))
    calc(32px + env(safe-area-inset-bottom, 0px))
    calc(24px + env(safe-area-inset-left, 0px));
}
.welcome-hero > * { width: 100%; max-width: 420px; }
.welcome-hero .welcome-body {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center;
}
.welcome-mark {
  width: 64px; height: 64px; border-radius: 18px; background: rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.welcome-mark .logo-glyph { width: 31px; }
.welcome-hero h1 { font-size: 34px; font-weight: 700; margin: 0; color: #fff; letter-spacing: 0.011em; }
.welcome-hero .lede { font-size: 17px; line-height: 1.45; color: rgba(255,255,255,0.75); max-width: 340px; margin: 0 auto; }
.welcome-hero ul { text-align: left; padding-left: 1.1rem; color: rgba(255,255,255,0.85); font-size: 15px; line-height: 1.55; }
.welcome-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.welcome-fineprint { text-align: center; font-size: 12px; color: rgba(255,255,255,0.55); margin: 4px 0 0; }

/* ---------------------------------------------------------------- auth pages (allauth) */

.auth-shell { max-width: 440px; margin: 0 auto; }
.auth-shell h1 { margin: 4px 0 8px; font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: 0.011em; }
.auth-shell > p:first-of-type,
.auth-shell p.entrance-lede { margin-bottom: 24px; font-size: 17px; line-height: 1.4; color: var(--label-2); }
.auth-shell form p { margin: 0 0 14px; }
.auth-shell form label { display: block; margin: 0 0 6px 4px; font-size: 13px; font-weight: 600; color: var(--label-2); }
.auth-shell form ul.errorlist { margin-bottom: 10px; }
.auth-shell button[type=submit],
.auth-shell input[type=submit] {
  display: flex; width: 100%; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; margin-top: 8px; padding: 0 20px; border: 0; border-radius: 12px;
  background: var(--tint-fill); color: #fff; font-family: inherit; font-size: 17px; font-weight: 600;
  cursor: pointer;
}
.auth-shell button[type=submit]:active { opacity: 0.72; }
.auth-shell button[type=submit]:disabled { cursor: wait; opacity: 0.78; }
.auth-shell a.button, .auth-shell button:not([type=submit]) {
  display: flex; width: 100%; align-items: center; justify-content: center;
  min-height: 50px; margin-top: 10px; padding: 0 20px; border: 0; border-radius: 12px;
  background: var(--tint-soft); color: var(--tint); font-family: inherit; font-size: 17px; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.auth-shell hr { margin: 20px 0; border: 0; border-top: 0.5px solid var(--separator); }

.auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 20px 0;
  color: var(--label-2); font-size: 13px;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 0.5px; background: var(--separator); }
.provider-list form { margin: 0; }
/* .auth-shell button[type=submit] restyles submits as the primary CTA, so the
   Google button needs the higher-specificity variants to keep Google's look. */
.btn-google,
.auth-shell button[type=submit].btn-google {
  display: flex; width: 100%; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; margin-top: 0; padding: 0 16px; border: 1px solid #dadce0; border-radius: 12px;
  background: #fff; color: #3c4043; font-family: inherit; font-size: 17px; font-weight: 600; cursor: pointer;
}
.btn-google:hover,
.auth-shell button[type=submit].btn-google:hover { background: #f8f9fa; color: #3c4043; }
.btn-google svg { flex-shrink: 0; }
.btn-google:disabled,
.auth-shell button.btn-google:disabled {
  background: #f5f5f5; color: #8a8d91; border-color: #e2e2e2; cursor: not-allowed; opacity: 1;
}
.btn-google:disabled svg { opacity: 0.45; }
.provider-coming-soon { font-size: 11px; font-weight: 700; color: #75787c; }
@media (prefers-color-scheme: dark) {
  html.app .btn-google,
  html.app .auth-shell button[type=submit].btn-google { background: #131314; border-color: #8e918f; color: #e3e3e3; }
  html.app .btn-google:hover,
  html.app .auth-shell button[type=submit].btn-google:hover { background: #1f1f20; color: #e3e3e3; }
  html.app .btn-google:disabled,
  html.app .auth-shell button.btn-google:disabled { background: #1c1c1e; border-color: #3a3a3c; color: #8e8e93; }
}

/* ---------------------------------------------------------------- delete confirm */

.danger-panel { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px 8px 20px; }
.danger-icon-circle {
  display: flex; align-items: center; justify-content: center; margin-bottom: 18px;
  width: 60px; height: 60px; border-radius: 50%; background: var(--red-soft); color: var(--red);
}
.danger-panel h1 { margin-bottom: 10px; font-size: 22px; }
.danger-panel p { max-width: 320px; margin: 0 auto; font-size: 15px; line-height: 1.5; color: var(--label-2); }
.confirm-input { text-align: center; letter-spacing: 0.08em; }

/* ---------------------------------------------------------------- misc */

.fineprint { color: var(--label-2); font-size: 13px; }
.journal-cover { border-radius: 9px; }
.logo-glyph { display: block; height: auto; }

@media (max-width: 480px) {
  :root { --gutter: 16px; }
}

/* ---------------------------------------------------------------- marketing site */

.marketing-body {
  min-height: 100vh; display: flex; flex-direction: column;
  background: #fff; color: var(--text);
}
.marketing-body main { flex: 1; }
.marketing-shell { width: min(1080px, calc(100% - 40px)); margin: 0 auto; }
.marketing-header {
  position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border); backdrop-filter: blur(14px);
}
.marketing-header-inner {
  min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.marketing-brand {
  display: inline-flex; align-items: center; gap: 9px; color: var(--text);
  font-size: 17px; font-weight: 800; letter-spacing: -0.02em;
}
.marketing-brand:hover { color: var(--text); }
.marketing-nav { display: flex; align-items: center; gap: 24px; }
.marketing-nav a { color: var(--text-secondary); font-size: 13.5px; font-weight: 600; }
.marketing-nav a:hover { color: var(--primary); }
.marketing-nav .marketing-nav-cta {
  padding: 9px 14px; border-radius: 10px; background: var(--primary); color: #fff;
}
.marketing-nav .marketing-nav-cta:hover { background: var(--primary-dark); color: #fff; }

.marketing-hero {
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 18%, rgba(28, 110, 140, 0.11), transparent 28%),
    linear-gradient(180deg, #fff 0%, #f8fbfc 100%);
  border-bottom: 1px solid var(--border);
}
.marketing-hero-grid {
  min-height: 610px; padding: 92px 0 86px; display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
  align-items: center; gap: 72px;
}
.marketing-eyebrow, .marketing-section-kicker {
  margin: 0 0 14px; color: var(--accent); font-size: 12px; font-weight: 750;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.marketing-hero h1 {
  max-width: 690px; margin: 0; color: var(--primary); font-size: clamp(42px, 5.5vw, 68px);
  line-height: 1.03; letter-spacing: -0.048em;
}
.marketing-lede {
  max-width: 620px; margin: 25px 0 0; color: var(--text-secondary);
  font-size: 18px; line-height: 1.65;
}
.marketing-actions { margin-top: 30px; display: flex; align-items: center; gap: 24px; }
.marketing-primary-btn {
  padding: 13px 19px; border-radius: 11px; background: var(--primary); color: #fff;
  font-size: 14.5px;
}
.marketing-primary-btn:hover { background: var(--primary-dark); color: #fff; }
.marketing-text-link { color: var(--primary); font-size: 14px; font-weight: 650; }
.marketing-text-link span { display: inline-block; transition: transform 0.16s ease; }
.marketing-text-link:hover span { transform: translateX(3px); }
.marketing-beta-note { margin: 13px 0 0; color: var(--text-muted); font-size: 12px; }

.marketing-preview {
  position: relative; padding: 28px; border: 1px solid var(--border-strong);
  border-radius: 20px; background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 22px 65px rgba(18, 58, 77, 0.11);
}
.marketing-preview::before {
  content: ""; position: absolute; inset: 12px -12px -12px 12px; z-index: -1;
  border-radius: 20px; background: #eaf3f6;
}
.marketing-preview-source { display: flex; align-items: center; gap: 10px; }
.marketing-preview-mark {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; border-radius: 9px; background: var(--primary); color: #fff;
  font-size: 14px; font-weight: 800;
}
.marketing-preview-source strong, .marketing-preview-source small { display: block; }
.marketing-preview-source strong { color: var(--text); font-size: 13px; }
.marketing-preview-source small { margin-top: 1px; color: var(--text-muted); font-size: 11px; }
.marketing-preview-badge {
  margin-left: auto; padding: 3px 8px; border-radius: 6px; background: #e7f2ec;
  color: #1c5e3f; font-size: 9.5px; font-weight: 750; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.marketing-preview h2 {
  margin: 25px 0 18px; color: var(--text); font-size: 19px; line-height: 1.32;
  letter-spacing: -0.02em;
}
.marketing-preview dl { margin: 0; }
.marketing-preview dl div { padding: 12px 0; border-top: 1px solid var(--border); }
.marketing-preview dt { color: var(--text); font-size: 11px; font-weight: 750; }
.marketing-preview dd { margin: 2px 0 0; color: var(--text-secondary); font-size: 12.5px; }
.marketing-preview > p {
  margin: 17px 0 0; color: var(--text-muted); font-size: 9.5px;
  font-style: italic; line-height: 1.45;
}

.marketing-section { padding: 92px 0 96px; }
.marketing-section h2, .marketing-trust h2, .marketing-final-cta h2 {
  margin: 0; color: var(--primary); font-size: clamp(30px, 4vw, 43px);
  line-height: 1.13; letter-spacing: -0.035em;
}
.marketing-steps { margin-top: 48px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 38px; }
.marketing-steps article { padding-top: 20px; border-top: 1px solid var(--border-strong); }
.marketing-steps article > span { color: var(--accent); font-size: 11px; font-weight: 750; }
.marketing-steps h3 { margin: 17px 0 9px; font-size: 17px; letter-spacing: -0.015em; }
.marketing-steps p { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 1.65; }

.marketing-trust { padding: 78px 0; background: var(--primary); color: #fff; }
.marketing-trust-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 80px; align-items: center; }
.marketing-trust .marketing-section-kicker { color: #8ec4d6; }
.marketing-trust h2 { color: #fff; }
.marketing-trust p:not(.marketing-section-kicker) {
  margin: 0 0 22px; color: rgba(255, 255, 255, 0.76); font-size: 15px; line-height: 1.75;
}
.marketing-trust .marketing-text-link { color: #fff; }

.marketing-final-cta { padding: 92px 0 96px; text-align: center; }
.marketing-final-cta h2 { margin-bottom: 28px; }

.marketing-footer { border-top: 1px solid var(--border); padding: 24px 0 28px; }
.marketing-footer-inner {
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  color: var(--text-muted); font-size: 11.5px;
}
.marketing-footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.marketing-footer-links a {
  padding: 0; border: 0; border-radius: 0; background: none;
  color: var(--text-muted); font-size: 11.5px; font-weight: 500;
}
.marketing-footer-links a:hover { color: var(--primary); }

.marketing-document { max-width: 760px; padding-top: 76px; padding-bottom: 90px; }
.marketing-document header { padding-bottom: 34px; border-bottom: 1px solid var(--border); }
.marketing-document h1 {
  margin: 0; color: var(--primary); font-size: clamp(38px, 6vw, 54px);
  line-height: 1.08; letter-spacing: -0.042em;
}
.marketing-document-intro {
  max-width: 650px; margin: 20px 0 0; color: var(--text-secondary); font-size: 17px; line-height: 1.65;
}
.marketing-document-date { margin: 15px 0 0; color: var(--text-muted); font-size: 12px; }
.marketing-document section { padding-top: 30px; }
.marketing-document section h2 {
  margin: 0 0 9px; color: var(--text); font-size: 18px; letter-spacing: -0.015em;
}
.marketing-document section p {
  margin: 0 0 12px; color: var(--text-secondary); font-size: 14.5px; line-height: 1.72;
}
.marketing-document section a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.marketing-document .marketing-disclosure {
  margin-top: 16px; color: var(--text-muted); font-size: 11px; font-style: italic;
}
.marketing-document-cta { margin-top: 38px; }
.marketing-error { max-width: 760px; padding-top: 110px; padding-bottom: 130px; }
.marketing-error h1 {
  margin: 0; color: var(--primary); font-size: clamp(38px, 6vw, 54px);
  line-height: 1.08; letter-spacing: -0.042em;
}
.marketing-error > p:not(.marketing-eyebrow) {
  margin: 18px 0 24px; color: var(--text-secondary); font-size: 16px;
}

@media (max-width: 800px) {
  .marketing-hero-grid { min-height: 0; grid-template-columns: 1fr; gap: 58px; padding: 72px 0 76px; }
  .marketing-hero-copy { max-width: 690px; }
  .marketing-preview { width: min(100%, 520px); }
  .marketing-steps { grid-template-columns: 1fr; gap: 28px; }
  .marketing-trust-inner { grid-template-columns: 1fr; gap: 30px; }
}

@media (max-width: 560px) {
  .marketing-shell { width: min(100% - 32px, 1080px); }
  .marketing-header-inner { min-height: 58px; }
  .marketing-nav { gap: 14px; }
  .marketing-nav > a:first-child { display: none; }
  .marketing-nav a { font-size: 12.5px; }
  .marketing-nav .marketing-nav-cta { padding: 8px 11px; }
  .marketing-hero-grid { padding: 58px 0 64px; gap: 46px; }
  .marketing-hero h1 { font-size: clamp(40px, 12vw, 52px); }
  .marketing-lede { margin-top: 20px; font-size: 16px; }
  .marketing-actions { align-items: flex-start; flex-direction: column; gap: 17px; }
  .marketing-preview { padding: 22px; border-radius: 17px; }
  .marketing-section { padding: 70px 0 74px; }
  .marketing-trust { padding: 66px 0; }
  .marketing-final-cta { padding: 70px 0 76px; }
  .marketing-final-cta h2 br { display: none; }
  .marketing-footer-inner { align-items: flex-start; flex-direction: column; }
  .marketing-footer-links { gap: 16px; }
  .marketing-document { padding-top: 56px; padding-bottom: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  .marketing-text-link span { transition: none; }
}
