html {
  font-size: 14.5px;
}

:root {
  color-scheme: light;

  --pico-font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --pico-border-radius: 0;
  --pico-spacing: 0.85rem;

  --app-bg: #eee8da;
  --app-bg-soft: #f3efe4;
  --app-paper: #fbfaf4;
  --app-paper-soft: #f8f4e9;
  --app-paper-muted: #efe7d7;

  --app-surface: rgba(251, 248, 239, 0.88);
  --app-surface-solid: #fbf8ef;
  --app-surface-soft: rgba(255, 253, 246, 0.72);
  --app-surface-muted: rgba(240, 234, 219, 0.58);

  --app-border: rgba(17, 18, 15, 0.16);
  --app-border-strong: rgba(17, 18, 15, 0.26);
  --app-border-soft: rgba(17, 18, 15, 0.1);

  --app-text: #10110f;
  --app-text-soft: #5f625a;
  --app-text-faint: #7b7e74;

  --app-accent: #42664d;
  --app-accent-strong: #293f31;
  --app-accent-soft: rgba(66, 102, 77, 0.1);

  --app-blue: #283f66;
  --app-blue-soft: rgba(40, 63, 102, 0.1);
  --app-clay: #9f5d3f;
  --app-clay-soft: rgba(159, 93, 63, 0.11);

  --app-success: #42664d;
  --app-warning: #9a6a22;
  --app-danger: #9f3f2f;

  --app-shadow-sm: 0 1px 0 rgba(17, 18, 15, 0.08);
  --app-shadow: 0 24px 70px rgba(21, 22, 19, 0.1);

  --app-serif: "Source Serif 4", Georgia, "Times New Roman", Times, serif;
  --app-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --app-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --sidebar-width-collapsed: 52px;
  --sidebar-width-expanded: 145px;
  --sidebar-width: var(--sidebar-width-collapsed);
  --shell-gap: 1rem;
  --topbar-height: 4.35rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body.app-body {
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: var(--app-sans);
  overflow-x: hidden;
}

.ledger-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(20, 21, 17, 0.036) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(0deg, rgba(20, 21, 17, 0.036) 1px, transparent 1px) 0 0 / 42px 42px,
    radial-gradient(circle at 15% 20%, rgba(126, 70, 43, 0.08), transparent 34%),
    radial-gradient(circle at 86% 8%, rgba(40, 63, 102, 0.06), transparent 28%),
    #eee8da;
}

a {
  color: var(--app-accent);
  text-decoration: none;
}

a:hover {
  color: var(--app-accent-strong);
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  color: var(--app-text);
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.08;
}

h3 {
  font-size: 1.08rem;
  line-height: 1.18;
}

p {
  color: var(--app-text);
}

small,
.muted {
  color: var(--app-text-soft) !important;
}

.subtle {
  color: var(--app-text-faint);
}

.app-container,
.container-narrow {
  width: min(100%, 1500px);
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Top bar */

.site-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  backdrop-filter: blur(16px);
  background: rgba(238, 232, 218, 0.86);
  border-bottom: 1px solid rgba(17, 18, 15, 0.18);
}

.site-topbar-inner {
  min-height: var(--topbar-height);
  display: grid;
  grid-template-columns: var(--sidebar-width-collapsed) minmax(0, 1fr);
  gap: var(--shell-gap);
  align-items: center;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 0;
  color: var(--app-text);
}

.brand:hover {
  color: var(--app-text);
  text-decoration: none;
}

.brand-mark {
  width: 2.55rem;
  height: 2.55rem;
  flex-shrink: 0;
  border: 1px solid var(--app-border-strong);
  background: rgba(251, 248, 239, 0.82);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--app-serif);
  font-size: 1.18rem;
  color: var(--app-text);
  box-shadow: var(--app-shadow-sm);
}

.brand-copy {
  display: none;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  color: var(--app-text);
  font-family: var(--app-serif);
  font-size: 1.22rem;
  font-weight: 650;
  letter-spacing: -0.05em;
  line-height: 0.98;
}

.brand-subtitle {
  margin-top: 0.16rem;
  color: var(--app-text-soft);
  font-family: var(--app-mono);
  font-size: 0.68rem;
  line-height: 1.1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}

.topbar-copy {
  min-width: 0;
}

.topbar-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  border: 1px solid var(--app-border);
  background: rgba(251, 250, 244, 0.66);
  padding: 0.45rem 0.64rem;
  color: var(--app-text-soft);
  font-family: var(--app-mono);
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.inline-form {
  margin: 0;
}

.inline-form button {
  width: auto;
  margin: 0;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.52rem;
  border: 1px solid var(--app-border);
  background: rgba(251, 250, 244, 0.68);
  color: var(--app-text-soft);
  padding: 0.46rem 0.68rem;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1;
  flex-wrap: wrap;
}

.user-name {
  color: var(--app-text);
}

.user-dot {
  width: 0.46rem;
  height: 0.46rem;
  border-radius: 999px;
  background: var(--app-success);
}

.user-role {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--app-border);
  background: var(--app-surface-soft);
  color: var(--app-text-faint);
  padding: 0.18rem 0.4rem;
  font-family: var(--app-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.user-role.owner {
  color: #7c4f2a;
  background: #fbf3ea;
  border-color: #e6d2ba;
}

.user-role.admin {
  color: #4b4268;
  background: #f2eef9;
  border-color: #ddd2ee;
}

.user-role.staff {
  color: #283f66;
  background: #eef2f8;
  border-color: #d6dfec;
}

.user-role.contributor {
  color: #315f47;
  background: #edf6f0;
  border-color: #cfe2d5;
}

/* App shell */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: var(--shell-gap);
  align-items: start;
  padding-top: 1.35rem;
  padding-bottom: 2.35rem;
  transition: grid-template-columns 0.22s ease;
}

.app-main > .section-stack:first-child,
.app-main > .project-detail-page:first-child {
  margin-top: 0;
}

.app-main > .section-stack:first-child > .ledger-panel:first-child,
.app-main > .project-detail-page:first-child > .ledger-panel:first-child {
  margin-top: 0;
}

.app-shell[data-sidebar-state="expanded"] {
  --sidebar-width: var(--sidebar-width-expanded);
}

.app-sidebar {
  position: sticky;
  top: calc(var(--topbar-height) + 1.15rem);
  min-width: 0;
  z-index: 30;
}

.sidebar-panel {
  min-height: calc(100vh - var(--topbar-height) - 2.8rem);
  border: 1px solid var(--app-border-strong);
  background: rgba(250, 247, 235, 0.72);
  box-shadow: var(--app-shadow);
  padding: 0.35rem;
  overflow: hidden;
}

/* Collapsed sidebar */

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.45rem;
  height: 2.45rem;
  min-height: 2.45rem;
  margin: 0 auto 0.55rem;
  padding: 0;
  border: 1px solid var(--app-border);
  border-radius: 0 !important;
  background: rgba(255, 253, 246, 0.58);
  color: var(--app-text);
  font-family: var(--app-mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: rgba(255, 253, 246, 0.84);
  border-color: var(--app-border-strong);
}

.sidebar-toggle-icon {
  font-size: 0.92rem;
  line-height: 1;
}

.sidebar-toggle-label {
  display: none !important;
}

.sidebar-nav {
  display: grid;
  gap: 0.18rem;
}

.sidebar-group {
  display: grid;
  gap: 0.18rem;
}

.sidebar-divider {
  height: 1px;
  width: 1.6rem;
  margin: 0.55rem auto;
  background: rgba(17, 18, 15, 0.14);
}

.sidebar-section-label {
  min-height: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.section-icon,
.section-label-text {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.45rem;
  min-height: 2.45rem;
  margin: 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(16, 17, 15, 0.68);
  font-weight: 700;
  line-height: 1.2;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.nav-item:hover {
  color: var(--app-text);
  background: rgba(255, 253, 246, 0.68);
  border-color: var(--app-border);
}

.nav-item.active {
  position: relative;
  color: var(--app-text);
  background: rgba(255, 253, 246, 0.92);
  border-color: var(--app-border-strong);
  box-shadow: none;
}

.app-shell[data-sidebar-state="collapsed"] .nav-item.active::before {
  content: "";
  position: absolute;
  left: -0.36rem;
  top: 0.55rem;
  bottom: 0.55rem;
  width: 2px;
  background: var(--app-text);
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  min-width: 1.35rem;
  height: 1.35rem;
  color: inherit;
  font-family: var(--app-mono);
  font-size: 0.86rem;
  line-height: 1;
}

.nav-label {
  display: none;
}

.sidebar-note {
  display: none;
}

/* Expanded sidebar */

.app-shell[data-sidebar-state="expanded"] .sidebar-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--topbar-height) - 2.8rem);
  padding: 0.5rem;
}

.app-shell[data-sidebar-state="expanded"] .sidebar-toggle {
  display: grid;
  grid-template-columns: 1.35rem minmax(0, 1fr) 0.6rem;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  height: auto;
  min-height: 2.45rem;
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.25rem 0.5rem 0.55rem;
  justify-content: initial;
}

.app-shell[data-sidebar-state="expanded"] .sidebar-toggle-icon {
  grid-column: 1;
  width: 1.35rem;
  min-width: 1.35rem;
  justify-self: center;
  text-align: center;
}

.app-shell[data-sidebar-state="expanded"] .sidebar-toggle::after {
  content: "";
  grid-column: 3;
}

.app-shell[data-sidebar-state="expanded"] .sidebar-nav {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 0.12rem;
  width: 100%;
}

.app-shell[data-sidebar-state="expanded"] .sidebar-group,
.app-shell[data-sidebar-state="expanded"] .sidebar-home {
  width: 100%;
}

.app-shell[data-sidebar-state="expanded"] .sidebar-divider {
  width: 100%;
  margin: 0.5rem 0;
  background: rgba(17, 18, 15, 0.13);
}

.app-shell[data-sidebar-state="expanded"] .sidebar-section-label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: auto;
  min-height: auto;
  margin: 0.16rem 0 0.28rem;
  padding: 0 0.48rem;
  overflow: visible;
  color: var(--app-text-faint);
  font-family: var(--app-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1.2;
  text-transform: uppercase;
}

.app-shell[data-sidebar-state="expanded"] .section-label-text {
  display: inline !important;
}

.app-shell[data-sidebar-state="expanded"] .section-icon {
  display: none !important;
}

.app-shell[data-sidebar-state="expanded"] .nav-item,
.app-shell[data-sidebar-state="expanded"] .sidebar-home-link {
  display: grid !important;
  grid-template-columns: 1.35rem minmax(0, 1fr);
  column-gap: 0.5rem;
  align-items: center;
  width: 100% !important;
  max-width: none !important;
  min-height: 2.45rem;
  margin: 0;
  padding: 0.5rem 0.25rem 0.5rem 0.55rem;
  color: rgba(16, 17, 15, 0.72);
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.app-shell[data-sidebar-state="expanded"] .nav-item:hover {
  background: rgba(255, 253, 246, 0.54);
  border-color: var(--app-border);
  color: var(--app-text);
}

.app-shell[data-sidebar-state="expanded"] .nav-item.active {
  background: rgba(255, 253, 246, 0.82);
  border-color: var(--app-border-strong);
  color: var(--app-text);
}

.app-shell[data-sidebar-state="expanded"] .nav-icon {
  grid-column: 1;
  justify-self: center;
  width: 1.35rem;
  min-width: 1.35rem;
  height: 1.35rem;
  font-size: 0.78rem;
  opacity: 0.9;
}

.app-shell[data-sidebar-state="expanded"] .nav-label {
  grid-column: 2;
  display: block;
  min-width: 0;
  justify-self: start;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.app-shell[data-sidebar-state="expanded"] .sidebar-home-link {
  font-size: 0.95rem;
  font-weight: 750;
}

.app-shell[data-sidebar-state="expanded"] .sidebar-note {
  display: block;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  margin-top: auto;
  margin-left: 0;
  margin-right: 0;
  padding: 0.9rem 0.78rem 0.78rem;
  border: 1px solid rgba(159, 93, 63, 0.2);
  background:
    radial-gradient(circle at 12% 18%, rgba(159, 93, 63, 0.16), transparent 32%),
    radial-gradient(circle at 92% 4%, rgba(40, 63, 102, 0.13), transparent 34%),
    linear-gradient(135deg, rgba(255, 247, 239, 0.92), rgba(246, 241, 250, 0.84));
  box-shadow: inset 0 1px 0 rgba(255, 253, 246, 0.88);
}

.app-shell[data-sidebar-state="expanded"] .sidebar-note strong {
  display: block;
  color: #6f4d45;
  font-family: var(--app-serif);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.14;
}

.app-shell[data-sidebar-state="expanded"] .sidebar-note strong::after {
  content: "";
  display: block;
  width: 2.35rem;
  height: 2px;
  margin-top: 0.62rem;
  background: linear-gradient(
    90deg,
    rgba(159, 93, 63, 0.9),
    rgba(66, 102, 77, 0.72),
    rgba(40, 63, 102, 0.68)
  );
}

/* Main content */

.app-main {
  min-width: 0;
}

.content-stack > * + * {
  margin-top: 1rem;
}

/* Flash messages */

.flash-stack {
  display: grid;
  gap: 0.75rem;
}

.flash {
  padding: 0.88rem 1rem;
  border: 1px solid var(--app-border);
  background: rgba(255, 253, 246, 0.86);
  color: var(--app-text);
  box-shadow: var(--app-shadow-sm);
}

.flash.success {
  background: #f4faf5;
  border-color: #cadfce;
}

.flash.warning {
  background: #fff8ec;
  border-color: #e5d1a7;
}

.flash.error {
  background: #fbf1f1;
  border-color: #e4c4c4;
}

.flash.info {
  background: #f4f6fa;
  border-color: #d4deeb;
}

/* Page layout */

.page-header {
  margin-bottom: 1.25rem;
}

.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-eyebrow,
.tiny-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  color: var(--app-text-soft);
  font-family: var(--app-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1;
  text-transform: uppercase;
}

.page-eyebrow {
  border: 1px solid var(--app-border);
  background: rgba(255, 253, 246, 0.66);
  padding: 0.42rem 0.58rem;
}

.page-intro {
  max-width: 880px;
  color: var(--app-text-soft);
  margin-top: 0.45rem;
  line-height: 1.55;
}

.page-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Ledger surfaces */

article,
.card,
.panel,
.surface {
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  box-shadow: var(--app-shadow-sm);
}

article,
.card,
.panel {
  padding: 1.05rem 1.1rem;
}

article {
  margin-bottom: 0;
}

.surface-soft {
  border: 1px solid var(--app-border);
  background: var(--app-surface-soft);
}

.surface-muted {
  border: 1px solid var(--app-border);
  background: var(--app-surface-muted);
}

.section-stack {
  display: grid;
  gap: 1rem;
}

.ledger-panel {
  border: 1px solid var(--app-border-strong);
  background: var(--app-surface);
  box-shadow: var(--app-shadow);
}

.ledger-section {
  padding: 1.55rem;
  border-bottom: 1px solid var(--app-border);
}

.ledger-section:last-child {
  border-bottom: 0;
}

.ledger-card {
  border: 1px solid var(--app-border);
  background: rgba(255, 253, 246, 0.7);
  padding: 1rem;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}

.ledger-card:hover {
  border-color: var(--app-border-strong);
  transform: translateY(-1px);
  box-shadow: 0 16px 42px rgba(21, 22, 19, 0.08);
}

/* Records */

.record-list {
  display: grid;
  gap: 0.2rem;
}

.record-line {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: baseline;
  padding: 0.78rem 0;
  border-bottom: 1px solid var(--app-border-soft);
  transition:
    padding-left 0.18s ease,
    border-color 0.18s ease;
}

.record-line:hover {
  padding-left: 0.4rem;
  border-color: var(--app-border-strong);
}

.record-line:last-child {
  border-bottom: 0;
}

.record-line time {
  color: var(--app-text-soft);
  font-family: var(--app-mono);
  font-size: 0.75rem;
}

.record-line strong {
  color: var(--app-text);
  font-size: 0.95rem;
  font-weight: 650;
}

.record-line span {
  color: var(--app-text-soft);
  font-size: 0.78rem;
}

/* Stats and badges */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.85rem;
}

.stat-card {
  border: 1px solid var(--app-border);
  background: rgba(255, 253, 246, 0.54);
  padding: 1rem;
  box-shadow: var(--app-shadow-sm);
}

.stat-label {
  color: var(--app-text-soft);
  font-family: var(--app-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}

.stat-value {
  color: var(--app-text);
  font-family: var(--app-serif);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1;
}

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--app-border);
  background: var(--app-surface-soft);
  color: var(--app-text-soft);
  padding: 0.28rem 0.58rem;
  font-family: var(--app-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.pill::before {
  content: "";
  width: 0.34rem;
  height: 0.34rem;
  border-radius: 999px;
  background: currentColor;
}

.pill-accent {
  background: var(--app-accent-soft);
  border-color: rgba(66, 102, 77, 0.22);
  color: var(--app-accent);
}

.pill-danger {
  background: rgba(159, 63, 47, 0.1);
  border-color: rgba(159, 63, 47, 0.22);
  color: var(--app-danger);
}

/* Buttons and actions */

button,
input[type="submit"],
input[type="button"],
.button,
[role="button"] {
  border-radius: 0 !important;
  font-weight: 700;
  box-shadow: none !important;
}

button.primary,
input[type="submit"].primary,
.button.primary {
  background: var(--app-text);
  border-color: var(--app-text);
  color: #f8f3e8;
}

button.primary:hover,
input[type="submit"].primary:hover,
.button.primary:hover {
  background: #1d1f1a;
  border-color: #1d1f1a;
  color: #f8f3e8;
}

.button.secondary,
button.secondary,
.btn-quiet {
  background: rgba(255, 253, 246, 0.72);
  color: var(--app-text);
  border: 1px solid var(--app-border-strong);
}

.button.secondary:hover,
button.secondary:hover,
.btn-quiet:hover {
  background: rgba(255, 253, 246, 0.96);
  border-color: var(--app-border-strong);
}

.button.ghost,
.action-link {
  background: transparent;
  border: 1px solid transparent;
  color: var(--app-text-soft);
  padding: 0.48rem 0.68rem;
  text-decoration: none;
}

.button.ghost:hover,
.action-link:hover {
  background: rgba(255, 253, 246, 0.7);
  border-color: var(--app-border);
  color: var(--app-text);
}

.button.primary,
.button.secondary,
button.primary,
button.secondary,
.btn-compact.secondary {
  font-family: var(--app-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.btn-compact,
.btn-compact.secondary,
.nav-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: auto;
  margin: 0;
  padding: 0.58rem 0.86rem;
  border-radius: 0;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  box-shadow: none;
}

.btn-compact.secondary {
  background: rgba(255, 253, 246, 0.72);
  color: var(--app-text);
  border: 1px solid var(--app-border);
}

.btn-compact.secondary:hover {
  background: rgba(255, 253, 246, 0.95);
  border-color: var(--app-border-strong);
}

.micro-button {
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  padding: 0.64rem 0.82rem;
  font-family: var(--app-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    color 0.18s ease;
}

.micro-button:hover {
  transform: translateY(-1px);
}

.micro-button.primary {
  background: var(--app-text);
  color: #f8f3e8;
  border-color: var(--app-text);
}

.action-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Forms */

input,
select,
textarea {
  border-radius: 0 !important;
  border-color: var(--app-border-strong) !important;
  background: rgba(255, 253, 246, 0.92) !important;
  color: var(--app-text) !important;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(40, 63, 102, 0.5) !important;
  box-shadow: 0 0 0 3px rgba(40, 63, 102, 0.12) !important;
}

label {
  color: var(--app-text);
  font-weight: 700;
}

form section + section {
  margin-top: 1rem;
}

.helptext {
  color: var(--app-text-soft);
  font-size: 0.86rem;
}

/* Tables */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  box-shadow: var(--app-shadow-sm);
}

table {
  margin-bottom: 0;
  background: transparent;
}

thead th {
  border-bottom: 1px solid var(--app-border);
  background: rgba(240, 234, 219, 0.66);
  color: var(--app-text-faint);
  font-family: var(--app-mono);
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

tbody tr {
  transition: background 0.16s ease;
}

tbody tr:hover {
  background: rgba(255, 253, 246, 0.62);
}

td,
th {
  vertical-align: middle;
}

/* Lists / metadata */

.meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  color: var(--app-text-soft);
  font-size: 0.92rem;
}

.meta-list strong {
  color: var(--app-text);
}

.empty-state {
  padding: 1.25rem;
  border: 1px dashed var(--app-border-strong);
  background: rgba(255, 253, 246, 0.54);
  color: var(--app-text-soft);
}

/* Shared page hero */

.workspace-hero-panel {
  position: relative;
  overflow: hidden;
}

/* Static rule: page headers should never resemble an in-progress loading state. */
.workspace-hero-panel::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: rgba(17, 18, 15, 0.16);
}

.workspace-hero-section {
  padding: 2rem 2rem 2.3rem;
}

.workspace-hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: start;
}

.workspace-hero-panel h1 {
  max-width: 860px;
  margin: 0.35rem 0 0;
  font-family: var(--app-serif);
  font-size: clamp(3.2rem, 6vw, 5.8rem);
  font-weight: 600;
  letter-spacing: -0.065em;
  line-height: 0.9;
}

.workspace-hero-panel .page-intro {
  max-width: 760px;
  margin-top: 0.95rem;
  color: #4b4d46;
  font-size: 1.04rem;
}

.workspace-actions-panel {
  display: flex;
  gap: 0.42rem;
  align-items: flex-start;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.ledger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.05rem;
  border: 1px solid var(--app-border-strong);
  background: rgba(255, 253, 246, 0.65);
  color: var(--app-text);
  padding: 0.52rem 0.66rem;
  font-family: var(--app-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: none;
}

.ledger-action:hover {
  background: rgba(255, 253, 246, 0.92);
  color: var(--app-text);
  border-color: var(--app-border-strong);
  transform: translateY(-1px);
}

.ledger-action.primary {
  background: var(--app-text);
  border-color: var(--app-text);
  color: #f8f3e8;
}

.ledger-action.primary:hover {
  background: #20221d;
  color: #f8f3e8;
}

.workspace-ledger-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.38fr);
  gap: 1rem;
  align-items: start;
}

.workspace-main-stack {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.workspace-project-line {
  grid-template-columns: 4.6rem minmax(0, 1fr) auto;
  align-items: start;
}

.workspace-record-index {
  color: var(--app-text-soft);
  font-family: var(--app-mono);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  line-height: 1.4;
}

.workspace-project-line .subtle,
.workspace-order-line .subtle {
  margin-top: 0.28rem;
  color: #73756d;
}

.workspace-order-line {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: start;
}

.workspace-ledger-grid .ledger-panel {
  min-width: 0;
}

.workspace-ledger-grid aside .ledger-section {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.workspace-ledger-grid aside .record-line {
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}

.workspace-ledger-grid .action-link {
  font-family: var(--app-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.workspace-ledger-grid .page-title-row h2 {
  margin: 0;
  font-family: var(--app-serif);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.workspace-ledger-grid .record-line strong {
  font-size: 0.98rem;
  line-height: 1.28;
}

.workspace-ledger-grid aside .record-line strong {
  font-size: 0.94rem;
}

.workspace-ledger-grid aside .pill {
  margin-top: 0.1rem;
}

/* Mobile nav */

.mobile-nav {
  display: none;
}

.mobile-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.44rem;
  white-space: nowrap;
  border: 1px solid var(--app-border);
  background: rgba(255, 253, 246, 0.7);
  color: var(--app-text-soft);
  padding: 0.66rem 0.82rem;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
}

.mobile-nav-item.active,
.mobile-nav-item:hover {
  background: rgba(255, 253, 246, 0.95);
  color: var(--app-text);
  border-color: var(--app-border-strong);
}

/* Pico cleanup */

[role="button"],
button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
  --pico-border-radius: 0;
}

hr {
  border-color: var(--app-border);
}

/* Responsive */

@media (max-width: 1080px) {
  .workspace-hero-layout,
  .workspace-ledger-grid {
    grid-template-columns: 1fr;
  }

  .workspace-actions-panel {
    justify-content: flex-start;
  }
}

@media (max-width: 1024px) {
  :root {
    --topbar-height: auto;
  }

  .site-topbar-inner,
  .app-shell {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .brand-copy {
    display: flex;
  }

  .topbar-main {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .app-sidebar {
    display: none;
  }

  .mobile-nav {
    display: flex;
    gap: 0.55rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
  }

  .mobile-nav::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 768px) {
  .app-container,
  .container-narrow {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  h1 {
    font-size: 2rem;
  }

  .page-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .record-line,
  .workspace-project-line,
  .workspace-order-line {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .workspace-hero-section {
    padding: 1.35rem;
  }

  .workspace-hero-panel h1 {
    font-size: 3.25rem;
  }

  .workspace-ledger-grid aside .ledger-section {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .user-chip {
    max-width: 100%;
  }
}

/* Lab Trackers */

.tracker-card-list {
  display: grid;
  gap: 0.8rem;
}

.tracker-card {
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  box-shadow: var(--app-shadow-sm);
}

.tracker-card[open] {
  border-color: var(--app-border-strong);
}

.tracker-card-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  cursor: pointer;
  list-style: none;
}

.tracker-card-summary::-webkit-details-marker {
  display: none;
}

.tracker-card-summary::before {
  content: "+";
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  color: var(--app-text-soft);
  font-family: var(--app-mono);
  font-weight: 700;
}

.tracker-card[open] .tracker-card-summary::before {
  content: "−";
}

.tracker-card-title-block {
  display: grid;
  gap: 0.28rem;
  min-width: 0;
}

.tracker-card-title-block strong {
  color: var(--app-text);
  font-family: var(--app-serif);
  font-size: 1.28rem;
  letter-spacing: -0.025em;
}

.tracker-card-title-block span,
.tracker-card-count,
.tracker-template-card p,
.tracker-template-example,
.tracker-column-row span {
  color: var(--app-text-soft);
}

.tracker-card-count {
  grid-column: 2;
  grid-row: 1;
  margin-right: 1.8rem;
  font-family: var(--app-mono);
  font-size: 0.72rem;
  white-space: nowrap;
}

.tracker-card-body {
  display: grid;
  gap: 1rem;
  padding: 1rem 1.1rem 1.1rem;
  border-top: 1px solid var(--app-border);
  background: rgba(255, 253, 246, 0.44);
}

.tracker-card-meta,
.tracker-column-chips,
.tracker-card-actions,
.tracker-column-flags {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tracker-card-meta {
  color: var(--app-text-soft);
  font-size: 0.85rem;
}

.tracker-card-section p {
  margin-bottom: 0;
}

.tracker-column-chip {
  border: 1px solid var(--app-border);
  background: var(--app-surface-soft);
  padding: 0.34rem 0.5rem;
  color: var(--app-text-soft);
  font-size: 0.78rem;
}

.tracker-preview-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--app-text-soft);
}

.tracker-empty-state p {
  max-width: 680px;
}

.tracker-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.tracker-template-card {
  min-height: 13rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  padding: 1.1rem;
  color: var(--app-text);
  text-decoration: none;
  box-shadow: var(--app-shadow-sm);
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.tracker-template-card:not(.is-disabled):hover {
  border-color: var(--app-border-strong);
  color: var(--app-text);
  transform: translateY(-1px);
}

.tracker-template-card.is-disabled {
  background: var(--app-surface-muted);
  opacity: 0.72;
}

.tracker-template-card h2,
.tracker-template-preview h2,
.tracker-section-heading h2 {
  margin-bottom: 0.4rem;
}

.tracker-template-example {
  font-family: var(--app-mono);
  font-size: 0.72rem;
  line-height: 1.45;
}

.tracker-template-action {
  font-family: var(--app-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tracker-create-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr);
  gap: 1rem;
  align-items: start;
}

.tracker-create-form label {
  font-weight: 700;
}

.tracker-form-actions {
  margin-top: 1rem;
}

.tracker-template-preview ol {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0;
  padding-left: 1.3rem;
}

.tracker-template-preview li strong {
  margin-right: 0.45rem;
}

.tracker-instructions {
  margin-bottom: 1rem;
}

.tracker-instructions p {
  margin-bottom: 0;
}

.tracker-detail-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.tracker-structure-panel,
.tracker-record-panel {
  margin-bottom: 1rem;
}

.tracker-section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.tracker-column-list {
  border-top: 1px solid var(--app-border);
}

.tracker-column-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--app-border);
}

.tracker-column-row > div:first-child {
  display: grid;
  gap: 0.15rem;
}

@media (max-width: 768px) {
  .tracker-template-grid,
  .tracker-create-layout,
  .tracker-detail-summary {
    grid-template-columns: 1fr;
  }

  .tracker-card-summary,
  .tracker-column-row {
    grid-template-columns: 1fr;
  }

  .tracker-card-summary::before {
    grid-column: 1;
    justify-self: end;
  }

  .tracker-card-count {
    grid-column: 1;
    grid-row: auto;
    margin-right: 0;
  }
}

/* Reviewable experiment-note cleanup */
.note-cleanup {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--app-border);
  background: rgba(255, 253, 246, 0.58);
}

.note-cleanup-heading,
.note-cleanup-toolbar,
.note-cleanup-actions,
.note-cleanup-applied {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.note-cleanup-heading strong {
  display: block;
  color: var(--app-text);
  font-size: 0.9rem;
  line-height: 1.25;
}

.note-cleanup-heading p,
.note-cleanup-toolbar p,
.note-cleanup-review p,
.note-cleanup-status {
  margin: 0.2rem 0 0;
  color: var(--app-text-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.note-cleanup-mode-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  padding: 0.25rem;
  border: 1px solid var(--app-border);
  background: rgba(255, 255, 255, 0.45);
}

.note-cleanup-mode {
  display: grid;
  gap: 0.15rem;
  min-height: 3.65rem;
  margin: 0;
  padding: 0.62rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--app-text);
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

.note-cleanup-mode:hover:not(:disabled) {
  border-color: var(--app-border);
  background: rgba(255, 255, 255, 0.68);
}

.note-cleanup-mode.is-active {
  border-color: var(--app-border-strong);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 3px 0 0 var(--app-accent-strong);
}

.note-cleanup-mode:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--app-accent-strong) 28%, transparent);
  outline-offset: 2px;
}

.note-cleanup-mode:disabled {
  cursor: wait;
  opacity: 0.58;
}

.note-cleanup-mode strong,
.note-cleanup-mode small {
  display: block;
}

.note-cleanup-mode strong {
  color: var(--app-text);
  font-size: 0.8rem;
  line-height: 1.2;
}

.note-cleanup-mode small {
  color: var(--app-text-soft);
  font-size: 0.7rem;
  line-height: 1.35;
}

.note-cleanup-toolbar {
  align-items: flex-end;
}

.note-cleanup-toolbar p {
  flex: 1 1 16rem;
  margin: 0;
}

.note-cleanup-status:empty {
  display: none;
}

.note-cleanup-status[data-state="error"] {
  color: #8c3b3b;
}

.note-cleanup-status[data-state="success"] {
  color: #315f47;
}

.note-cleanup-review {
  display: grid;
  gap: 0.55rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--app-border);
}

.note-cleanup-review[hidden],
.note-cleanup-applied[hidden] {
  display: none !important;
}

.note-cleanup-review textarea {
  width: 100%;
  min-height: 9rem;
  margin: 0;
  resize: vertical;
  background: rgba(255, 255, 255, 0.72);
}

.note-cleanup-applied {
  justify-content: flex-start;
  color: #315f47;
  font-size: 0.8rem;
  font-weight: 750;
}

@media (max-width: 560px) {
  .note-cleanup-mode-selector {
    grid-template-columns: 1fr;
  }

  .note-cleanup-toolbar,
  .note-cleanup-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .note-cleanup-toolbar .ledger-action,
  .note-cleanup-actions .ledger-action {
    width: 100%;
    justify-content: center;
  }
}

/* Progressive disclosure for optional note tools */
.note-composer-form {
  gap: 0.65rem;
  margin-top: 0.7rem;
}

.note-composer-field {
  display: grid;
  gap: 0.35rem;
}

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

.exp-form-grid .note-composer-field textarea,
.experiment-note-fields.note-composer-field textarea {
  width: 100%;
  min-height: 8rem;
  margin: 0;
  resize: vertical;
}

.note-composer-field ul.errorlist,
.note-composer-errors ul.errorlist {
  margin: 0;
  padding-left: 1rem;
  color: #8c3b3b;
  font-size: 0.82rem;
  line-height: 1.4;
}

.note-composer-errors {
  padding: 0.7rem 0.8rem;
  border-left: 3px solid rgba(159, 63, 47, 0.55);
  background: #fbefef;
  color: #6f2d2d;
}

.exp-note-composer-panel {
  margin-top: 0.85rem;
}

.exp-note-composer {
  padding-top: 0.9rem;
  border-top: 1px solid var(--app-border);
}

.exp-note-composer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.exp-note-composer-head h3 {
  color: var(--app-text);
  font-family: var(--app-serif);
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.exp-note-close {
  color: var(--app-text-soft);
  font-family: var(--app-mono);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
}

.exp-note-close:hover,
.exp-note-close:focus-visible {
  color: var(--app-text);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

#experiment-notes:has(#add-experiment-note-panel:target) .exp-note-open-trigger {
  display: none;
}

.note-composer-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.1rem;
}

.note-composer-actions .ledger-action {
  width: auto;
  min-width: 7.4rem;
}

.note-assist-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  align-items: center;
  min-height: 1.8rem;
}

.note-assist-details {
  flex: 0 1 auto;
  margin: 0;
}

.note-assist-details[open] {
  flex-basis: 100%;
}

.note-assist-details > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  min-height: 1.75rem;
  margin: 0;
  padding: 0.22rem 0;
  border: 0;
  background: transparent;
  color: var(--app-accent-strong);
  cursor: pointer;
  font-family: var(--app-mono);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.045em;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: none;
}

.note-assist-details > summary::-webkit-details-marker {
  display: none;
}

.note-assist-details > summary::before {
  content: "+";
  color: currentColor;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1;
}

.note-assist-details[open] > summary {
  color: var(--app-text);
}

.note-assist-details[open] > summary::before {
  content: "−";
}

.note-assist-details > summary:hover,
.note-assist-details > summary:focus-visible {
  color: var(--app-text);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.note-assist-details > summary:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--app-accent-strong) 34%, transparent);
  outline-offset: 3px;
}

.note-assist-panel {
  margin-top: 0.35rem;
  padding: 0.8rem 0 0;
  border: 0;
  border-top: 1px solid var(--app-border);
  background: transparent;
}

.note-assist-panel .note-cleanup,
.note-assist-panel .voice-note-shell {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

@media (max-width: 560px) {
  .note-assist-list {
    gap: 0.35rem 0.85rem;
  }

  .note-composer-actions {
    justify-content: stretch;
  }

  .note-composer-actions .ledger-action {
    width: 100%;
  }
}

/* Shared waiting state for long-running AI actions */
.ai-wait-overlay[hidden] {
  display: none;
}

body.ai-wait-active {
  overflow: hidden;
}

.ai-wait-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(245, 241, 230, 0.82);
  backdrop-filter: blur(10px);
}

.ai-wait-card {
  width: min(100%, 34rem);
  padding: clamp(1.4rem, 4vw, 2.2rem);
  border: 1px solid var(--app-border);
  border-radius: 1.15rem;
  background: var(--app-surface);
  box-shadow: 0 1.4rem 4rem rgba(57, 49, 38, 0.16);
  text-align: center;
}

.ai-wait-card h2 {
  margin: 0.5rem 0 0;
  color: var(--app-text);
  font-family: var(--app-serif);
  font-size: clamp(1.55rem, 4vw, 2.15rem);
  letter-spacing: -0.045em;
}

.ai-wait-message {
  min-height: 1.7rem;
  margin: 0.9rem 0 0;
  color: var(--app-text-soft);
}

.ai-wait-note {
  margin: 0.55rem 0 0;
  color: var(--app-text-faint);
  font-family: var(--app-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ai-wait-orbit {
  position: relative;
  width: 4.25rem;
  height: 4.25rem;
  margin: 0 auto 1rem;
  border: 1px solid rgba(124, 113, 92, 0.28);
  border-radius: 50%;
  animation: ai-wait-spin 4.8s linear infinite;
}

.ai-wait-orbit::before {
  content: "";
  position: absolute;
  inset: 0.8rem;
  border: 1px dashed rgba(124, 113, 92, 0.3);
  border-radius: 50%;
}

.ai-wait-orbit span {
  position: absolute;
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: var(--app-accent);
}

.ai-wait-orbit span:nth-child(1) {
  top: -0.31rem;
  left: calc(50% - 0.31rem);
}

.ai-wait-orbit span:nth-child(2) {
  right: 0.2rem;
  bottom: 0.5rem;
}

.ai-wait-orbit span:nth-child(3) {
  left: 0.2rem;
  bottom: 0.5rem;
}

.ai-wait-error {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--app-border);
}

.ai-wait-error p {
  margin: 0 0 0.8rem;
  color: #7a3535;
}

@keyframes ai-wait-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-wait-orbit {
    animation: none;
  }
}


/* Preserve working context after save/redirect cycles and keep hash targets below the sticky header. */
:where(main section[id], main article[id], [data-scroll-anchor][id]) {
  scroll-margin-top: calc(var(--topbar-height) + 1.25rem);
}

/* Project literature: quiet hierarchy from discovery to trusted saved papers. */
.literature-panel {
  --literature-accent: #526b59;
  --literature-accent-strong: #3d5546;
  --literature-accent-soft: rgba(82, 107, 89, 0.09);
  --literature-accent-softer: rgba(82, 107, 89, 0.045);
  --literature-amber: #8a642e;
  --literature-amber-soft: rgba(157, 119, 58, 0.09);
  --literature-danger: #8a4640;
  min-width: 0;
}

.literature-panel .tiny-label {
  color: var(--literature-accent);
}

.literature-section-intro {
  display: grid;
  gap: 0.85rem;
  background:
    linear-gradient(90deg, var(--literature-accent-soft), transparent 56%),
    rgba(255, 253, 246, 0.18);
}

.project-card-head.literature-panel-head {
  display: block;
}

.literature-panel-copy {
  min-width: 0;
  max-width: 48rem;
}

.literature-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  align-items: center;
}

.literature-panel .ledger-action.primary {
  background: var(--literature-accent-strong);
  border-color: var(--literature-accent-strong);
  color: #fbf8ef;
}

.literature-panel .ledger-action.primary:hover {
  background: #32473a;
  border-color: #32473a;
  color: #fbf8ef;
}

.literature-tools > .literature-capture-details > summary.ledger-action {
  min-height: 2.1rem;
  padding: 0.42rem 0.68rem;
  border: 1px solid rgba(61, 85, 70, 0.28);
  background: rgba(255, 253, 246, 0.5);
  color: var(--literature-accent-strong);
  box-shadow: none;
  font-size: 0.63rem;
}

.literature-tools > .literature-capture-details > summary.ledger-action:hover {
  background: var(--literature-accent-soft);
  border-color: rgba(61, 85, 70, 0.42);
}

.literature-capture-details,
.literature-edit-details,
.literature-archived-details,
.literature-optional-details,
.literature-metadata-details,
.literature-more-details,
.literature-note-details,
.literature-search-explainer,
.literature-discovery-note-details {
  margin: 0;
}

.literature-panel details > summary,
.literature-discovery details > summary {
  cursor: pointer;
  list-style: none;
  background-image: none !important;
}

.literature-panel details > summary::before,
.literature-panel details > summary::after,
.literature-discovery details > summary::before,
.literature-discovery details > summary::after {
  content: none !important;
  display: none !important;
}

.literature-panel details > summary::marker,
.literature-discovery details > summary::marker {
  content: "";
}

.literature-panel details > summary::-webkit-details-marker,
.literature-discovery details > summary::-webkit-details-marker {
  display: none;
}

.literature-capture-details > summary.ledger-action {
  margin: 0;
  white-space: nowrap;
}

.literature-capture-details[open] {
  flex: 1 0 100%;
  order: 3;
  min-width: 0;
}

.literature-capture-details[open] > summary {
  display: none;
}

.literature-form-panel {
  width: 100%;
  min-width: 0;
  margin-top: 0.08rem;
  padding: 0.82rem 0.92rem;
  border: 1px solid rgba(82, 107, 89, 0.18);
  border-left: 3px solid rgba(82, 107, 89, 0.48);
  background: rgba(250, 249, 242, 0.72);
  box-shadow: none;
}

.literature-form-panel-inline {
  margin-top: 0.58rem;
  padding: 0.78rem 0.85rem;
  border-left-width: 2px;
  background: var(--literature-accent-softer);
}

.literature-form-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.literature-form-panel-head > div {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.literature-form-panel-head strong {
  color: var(--app-text);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.25;
}

.literature-form-panel-head span {
  max-width: 46rem;
  color: var(--app-text-soft);
  font-size: 0.72rem;
  line-height: 1.4;
}

.literature-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.62rem 0.72rem;
  min-width: 0;
  margin: 0;
}

.literature-field {
  min-width: 0;
}

.literature-field-wide {
  grid-column: 1 / -1;
}

.literature-field label {
  display: block;
  margin-bottom: 0.22rem;
  color: var(--app-text);
  font-size: 0.72rem;
  font-weight: 760;
  line-height: 1.25;
}

.literature-field input,
.literature-field select,
.literature-field textarea {
  width: 100%;
  min-width: 0;
  margin: 0;
  border-color: rgba(61, 85, 70, 0.23);
  background: rgba(255, 254, 249, 0.84);
  box-shadow: none;
  color: var(--app-text);
  font-size: 0.82rem;
}

.literature-field input,
.literature-field select {
  min-height: 2.45rem;
  height: 2.45rem;
  padding-top: 0.42rem;
  padding-bottom: 0.42rem;
}

.literature-field input::placeholder,
.literature-field textarea::placeholder {
  color: var(--app-text-faint);
  opacity: 0.86;
}

.literature-field textarea {
  min-height: 4.7rem;
  resize: vertical;
}

.literature-field-hint,
.literature-lookup-help {
  display: block;
  margin: 0.24rem 0 0;
  color: var(--app-text-faint);
  font-size: 0.69rem;
  line-height: 1.4;
}

.literature-text-action,
.literature-id-link,
.literature-experiment-link,
.literature-edit-details > summary,
.literature-note-details > summary,
.literature-search-explainer > summary,
.literature-discovery-note-details > summary {
  color: var(--app-text-soft);
  font-size: 0.74rem;
  font-weight: 720;
  line-height: 1.3;
  text-decoration: none;
}

.literature-text-action:hover,
.literature-id-link:hover,
.literature-experiment-link:hover,
.literature-edit-details > summary:hover,
.literature-note-details > summary:hover,
.literature-search-explainer > summary:hover,
.literature-discovery-note-details > summary:hover {
  color: var(--app-text);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

button.literature-text-action {
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.literature-text-action.danger {
  color: var(--literature-danger);
}

/* Contextual discovery. */
.literature-discovery {
  display: grid;
  gap: 0.72rem;
  min-width: 0;
}

.literature-discovery-form {
  display: grid;
  grid-template-columns: minmax(12rem, 0.38fr) minmax(18rem, 1fr) auto;
  gap: 0.55rem 0.65rem;
  align-items: start;
  margin: 0;
}

.literature-discovery-submit {
  display: flex;
  align-items: flex-start;
  padding-top: 1.33rem;
}

.literature-discovery-submit .ledger-action {
  width: auto;
  min-height: 2.45rem;
  height: 2.45rem;
  margin: 0;
  padding: 0 0.72rem;
  white-space: nowrap;
}

.literature-search-explainer {
  width: fit-content;
  max-width: 100%;
}

.literature-search-explainer > summary {
  color: var(--app-text-faint);
  font-size: 0.69rem;
}

.literature-search-explainer p {
  max-width: 54rem;
  margin: 0.4rem 0 0;
  padding: 0.48rem 0.65rem;
  border-left: 2px solid rgba(82, 107, 89, 0.35);
  background: var(--literature-accent-softer);
  color: var(--app-text-faint);
  font-size: 0.7rem;
  line-height: 1.48;
}

.literature-discovery-status,
.literature-lookup-status {
  margin: 0;
  padding: 0.45rem 0;
  border: 0;
  background: transparent;
  color: var(--app-text-soft);
  font-size: 0.75rem;
  line-height: 1.42;
}

.literature-discovery-status[data-state="loading"],
.literature-lookup-status[data-state="loading"] {
  color: var(--literature-amber);
}

.literature-discovery-status[data-state="error"],
.literature-lookup-status[data-state="error"] {
  color: var(--literature-danger);
}

.literature-discovery-status[data-state="success"] {
  color: var(--literature-accent-strong);
}

.literature-discovery-results {
  display: grid;
  min-width: 0;
  border-top: 1px solid var(--app-border);
}

.literature-discovery-result {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
  margin: 0;
  padding: 0.72rem 0.58rem;
  border: 0;
  border-bottom: 1px solid var(--app-border-soft);
  background: transparent;
  box-shadow: none;
}

.literature-discovery-result:hover {
  background: var(--literature-accent-softer);
}

.literature-discovery-result-copy {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.literature-discovery-result-title {
  color: var(--app-text);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.012em;
  line-height: 1.34;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.literature-discovery-result-title:hover {
  color: var(--app-accent-strong);
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.literature-discovery-result-meta {
  display: -webkit-box;
  overflow: hidden;
  color: var(--app-text-soft);
  font-size: 0.76rem;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.literature-discovery-reason {
  display: grid;
  gap: 0.16rem;
  max-width: 54rem;
  margin: 0.08rem 0 0;
  padding: 0.4rem 0.55rem;
  border-left: 2px solid rgba(82, 107, 89, 0.38);
  background: var(--literature-accent-softer);
}

.literature-discovery-reason-label {
  color: var(--literature-accent);
  font-family: var(--app-mono);
  font-size: 0.57rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1.2;
  text-transform: uppercase;
}

.literature-discovery-reason p {
  margin: 0;
  color: var(--app-text-soft);
  font-size: 0.79rem;
  line-height: 1.48;
}

.literature-discovery-identifiers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.24rem 0.55rem;
  color: var(--app-text-faint);
  font-family: var(--app-mono);
  font-size: 0.58rem;
  line-height: 1.3;
}

.literature-discovery-result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.72rem;
  min-height: 1.8rem;
  margin-top: 0.12rem;
}

.literature-discovery-save-form.is-project {
  display: inline-flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  min-width: 0;
  margin: 0 0 0 auto;
}

.literature-discovery-save-form.is-project > .ledger-action {
  width: auto;
  min-height: 1.85rem;
  height: 1.85rem;
  margin: 0;
  padding: 0 0.58rem;
  font-size: 0.61rem;
}

.literature-discovery-note-details {
  flex: 0 1 auto;
  min-width: 0;
}

.literature-discovery-note-details > summary {
  width: fit-content;
}

.literature-discovery-note {
  display: grid;
  gap: 0.2rem;
  margin: 0.42rem 0 0;
}

.literature-discovery-note-label {
  color: var(--app-text-soft);
  font-size: 0.68rem;
  font-weight: 720;
  line-height: 1.25;
}

.literature-discovery-note textarea {
  width: min(32rem, 75vw);
  min-height: 3.2rem;
  margin: 0;
  resize: vertical;
  font-size: 0.8rem;
  line-height: 1.4;
}

.literature-discovery-saved {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.4rem;
  border: 1px solid rgba(82, 107, 89, 0.2);
  background: var(--literature-accent-soft);
  color: var(--literature-accent-strong);
  font-size: 0.7rem;
  font-weight: 760;
  line-height: 1.3;
}

.literature-discovery-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  align-items: center;
  padding-top: 0.15rem;
}

.literature-discovery-controls[hidden] {
  display: none;
}

/* Known-paper lookup. */
.literature-smart-add {
  display: grid;
  gap: 0.65rem;
  min-width: 0;
}

.literature-lookup-form,
.literature-smart-save-form {
  margin: 0;
}

.literature-lookup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.literature-lookup-row input,
.literature-lookup-row button {
  min-width: 0;
  margin: 0;
}

.literature-lookup-row button {
  width: auto;
  min-width: 4.8rem;
  min-height: 2.45rem;
  height: 2.45rem;
  padding: 0 0.72rem;
}

.literature-candidate-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--app-border);
}

.literature-candidate-heading {
  margin: 0;
  padding: 0.48rem 0 0.28rem;
  color: var(--app-text-soft);
  font-size: 0.72rem;
  font-weight: 760;
}

.literature-candidate {
  display: grid;
  gap: 0.12rem;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0.52rem 0;
  border: 0;
  border-bottom: 1px solid var(--app-border-soft);
  background: transparent;
  color: var(--app-text);
  text-align: left;
  cursor: pointer;
}

.literature-candidate:hover,
.literature-candidate:focus-visible {
  background: var(--literature-accent-softer);
  outline: none;
}

.literature-candidate strong {
  font-size: 0.84rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.literature-candidate span,
.literature-candidate small {
  color: var(--app-text-soft);
  font-size: 0.72rem;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.literature-manual-entry-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.28rem;
  color: var(--app-text-faint);
  font-size: 0.71rem;
  line-height: 1.35;
}

.literature-smart-save-form {
  margin-top: 0.04rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--app-border);
}

.literature-selected-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.58rem 0.65rem;
  border: 1px solid rgba(82, 107, 89, 0.16);
  background: var(--literature-accent-softer);
}

.literature-selected-copy {
  display: grid;
  gap: 0.14rem;
  min-width: 0;
}

.literature-selection-label {
  color: var(--literature-accent) !important;
  font-family: var(--app-mono);
  font-size: 0.56rem !important;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.literature-selected-copy strong {
  color: var(--app-text);
  font-size: 0.92rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.literature-selected-copy span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--app-text-soft);
  font-size: 0.73rem;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.literature-link-fields {
  display: grid;
  grid-template-columns: minmax(10rem, 0.38fr) minmax(0, 1fr);
  gap: 0.65rem 0.72rem;
  align-items: end;
}

.literature-optional-details > summary,
.literature-metadata-details > summary {
  display: inline-flex;
  color: var(--app-text-soft);
  font-size: 0.73rem;
  font-weight: 720;
  line-height: 1.3;
}

.literature-optional-details-body {
  margin-top: 0.5rem;
}

.literature-metadata-grid {
  margin-top: 0.58rem;
  padding-top: 0.58rem;
  border-top: 1px solid var(--app-border-soft);
}

.literature-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem 0.75rem;
  padding-top: 0.08rem;
}

.literature-smart-save-form [data-literature-save-button]:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

/* Saved literature shelf. */
.literature-shelf-section {
  padding-top: 0.82rem;
  padding-bottom: 0.92rem;
  background: rgba(255, 253, 246, 0.18);
}

.literature-shelf-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
}

.literature-shelf-head p {
  margin: 0.18rem 0 0;
  color: var(--app-text-faint);
  font-size: 0.72rem;
  line-height: 1.35;
}

.literature-list {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.literature-row {
  position: relative;
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0.75rem 0.55rem;
  border: 0;
  border-bottom: 1px solid var(--app-border-soft);
  background: transparent;
  box-shadow: none;
}

.literature-row:hover,
.literature-row:focus-within {
  background: var(--literature-accent-softer);
}

.literature-row:first-child {
  border-top: 1px solid var(--app-border);
}

.literature-row-main {
  min-width: 0;
}

.literature-title-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.28rem 0.48rem;
  min-width: 0;
}

.literature-title {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  color: var(--app-text);
  font-size: 0.97rem;
  font-weight: 800;
  letter-spacing: -0.016em;
  line-height: 1.32;
  overflow-wrap: anywhere;
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.literature-title:hover {
  color: var(--app-accent-strong);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.literature-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.12rem 0.48rem;
  min-width: 0;
  margin-top: 0.2rem;
  color: var(--app-text-soft);
  font-size: 0.77rem;
  line-height: 1.42;
}

.literature-authors {
  display: block;
  min-width: 0;
  max-width: min(100%, 48rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.literature-meta span + span::before {
  content: "·";
  margin-right: 0.48rem;
  color: rgba(82, 107, 89, 0.5);
}

.literature-state-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.32rem 0.55rem;
  margin-top: 0.3rem;
}

.literature-source-state,
.literature-state-note {
  display: inline-flex;
  align-items: center;
  min-height: 1.28rem;
  padding: 0.13rem 0.38rem;
  border: 1px solid rgba(82, 107, 89, 0.14);
  background: rgba(82, 107, 89, 0.055);
  color: var(--literature-accent);
  font-family: var(--app-mono);
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  line-height: 1.15;
  text-transform: uppercase;
}

.literature-source-state.is-full-text {
  border-color: rgba(82, 107, 89, 0.22);
  background: var(--literature-accent-soft);
  color: var(--literature-accent-strong);
}

.literature-source-state.is-warning {
  border-color: rgba(157, 119, 58, 0.22);
  background: var(--literature-amber-soft);
  color: var(--literature-amber);
}

.literature-source-state.is-muted,
.literature-state-note {
  border-color: rgba(17, 18, 15, 0.1);
  background: rgba(17, 18, 15, 0.035);
  color: var(--app-text-faint);
}

.literature-note-details {
  width: fit-content;
  max-width: 100%;
  margin-top: 0.38rem;
}

.literature-note-details > summary {
  display: inline-flex;
  padding: 0.17rem 0.4rem;
  border: 1px solid rgba(157, 119, 58, 0.16);
  background: var(--literature-amber-soft);
  color: #74562c;
  font-size: 0.68rem;
}

.literature-note-details > summary:hover {
  color: #5e4423;
  text-decoration: none;
  border-color: rgba(157, 119, 58, 0.28);
}

.literature-note-details p {
  max-width: 54rem;
  margin: 0.42rem 0 0;
  padding: 0.48rem 0.62rem;
  border-left: 2px solid rgba(157, 119, 58, 0.32);
  background: rgba(157, 119, 58, 0.04);
  color: var(--app-text-soft);
  font-size: 0.78rem;
  line-height: 1.48;
}

.literature-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.48rem;
  align-items: center;
  margin-top: 0.38rem;
}

.literature-link-label {
  color: var(--app-text-faint);
  font-size: 0.68rem;
  line-height: 1.3;
}

.literature-experiment-link {
  color: var(--app-text-soft);
  font-size: 0.7rem;
}

.literature-row-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.42rem 0.78rem;
  margin-top: 0.52rem;
  padding-top: 0.48rem;
  border-top: 1px solid rgba(17, 18, 15, 0.07);
}

.literature-reference-links {
  order: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.42rem 0.75rem;
}

.literature-reference-links .literature-id-link {
  color: var(--literature-accent-strong);
  font-weight: 760;
}

.literature-manage-actions {
  display: contents;
}

.literature-id-link,
.literature-edit-details > summary {
  font-size: 0.72rem;
}

.literature-edit-details {
  order: 2;
}

.literature-pdf-details {
  margin-left: auto;
}

.literature-edit-details > summary {
  color: var(--app-text-faint);
}

.literature-edit-details[open] {
  order: 3;
  flex: 1 0 100%;
  width: 100%;
  margin-left: 0;
}

.literature-pdf-details[open] + .literature-edit-details {
  margin-left: auto;
}

.literature-edit-details[open] > summary {
  display: none;
}

.literature-pdf-panel {
  width: min(100%, 48rem);
  min-width: 0;
  margin-top: 0.5rem;
  padding: 0.52rem 0 0.08rem;
  border: 0;
  border-top: 1px solid rgba(82, 107, 89, 0.2);
  background: transparent;
}

.literature-pdf-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem 1rem;
}

.literature-pdf-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.18rem 0.58rem;
  min-width: 0;
}

.literature-pdf-heading strong {
  color: var(--literature-accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.3;
}

.literature-pdf-name {
  min-width: 0;
  max-width: min(100%, 26rem);
  overflow: hidden;
  color: var(--app-text-soft);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.literature-pdf-help {
  color: var(--app-text-faint);
  font-size: 0.68rem;
  line-height: 1.35;
}

.literature-pdf-status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--app-text-faint);
  font-size: 0.65rem;
  line-height: 1.3;
}

.literature-pdf-status::before {
  width: 0.34rem;
  height: 0.34rem;
  border-radius: 999px;
  background: currentColor;
  content: "";
  opacity: 0.72;
}

.literature-pdf-status.is-ready {
  color: var(--literature-accent);
}

.literature-pdf-status.is-warning {
  color: var(--literature-amber);
}

.literature-pdf-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.78rem;
  margin-top: 0.38rem;
}

.literature-pdf-replace-details {
  margin: 0;
}

.literature-pdf-replace-details > summary {
  display: inline-flex;
}

.literature-pdf-replace-details[open] {
  flex: 1 0 100%;
  min-width: 0;
}

.literature-pdf-replace-details[open] > summary {
  margin-bottom: 0.34rem;
}

.literature-pdf-remove-form {
  margin: 0;
}

.literature-pdf-upload-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.38rem 0.5rem;
  min-width: 0;
  margin: 0.42rem 0 0;
}

.literature-pdf-replace-form {
  margin-top: 0;
}

.literature-file-picker {
  display: grid;
  gap: 0.16rem;
  flex: 0 1 24rem;
  min-width: min(100%, 14rem);
  color: var(--app-text-soft);
  font-size: 0.66rem;
  font-weight: 700;
}

.literature-file-picker-label {
  color: var(--app-text-faint);
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.25;
}

.literature-pdf-upload-form input[type="file"] {
  width: min(100%, 24rem);
  max-width: 100%;
  min-height: 1.95rem;
  margin: 0;
  padding: 0.1rem;
  border: 1px solid rgba(61, 85, 70, 0.2);
  background: rgba(255, 254, 249, 0.72);
  color: var(--app-text-soft);
  font-size: 0.68rem;
  line-height: 1.2;
}

.literature-pdf-upload-form input[type="file"]::file-selector-button {
  min-height: 1.55rem;
  margin-right: 0.42rem;
  padding: 0.2rem 0.44rem;
  border: 1px solid rgba(61, 85, 70, 0.24);
  background: rgba(82, 107, 89, 0.07);
  color: var(--literature-accent-strong);
  font: 700 0.64rem/1 var(--app-sans);
  cursor: pointer;
}

.literature-pdf-upload-form .literature-form-actions {
  padding: 0;
}

.literature-pdf-upload-form .ledger-action {
  width: auto;
  min-height: 1.95rem;
  height: 1.95rem;
  margin: 0;
  padding: 0 0.56rem;
  font-size: 0.6rem;
}

.literature-reference-edit-panel {
  width: min(100%, 54rem);
  padding: 0.66rem 0.74rem;
}

.literature-reference-edit-panel .literature-form-panel-head {
  margin-bottom: 0.5rem;
}

.literature-reference-edit-panel .literature-form-grid {
  gap: 0.5rem 0.6rem;
}

.literature-reference-edit-panel .literature-field input,
.literature-reference-edit-panel .literature-field select {
  min-height: 2.22rem;
  height: 2.22rem;
}

.literature-reference-edit-panel .literature-field textarea {
  min-height: 4rem;
}

.literature-reference-edit-panel .literature-archive-form {
  margin: 0.42rem 0 0;
  padding-top: 0;
  border-top: 0;
}

.literature-more-details {
  margin-top: 0.45rem;
}

.literature-more-details > summary,
.literature-archived-details > summary {
  display: inline-flex;
  color: var(--app-text-soft);
  font-size: 0.72rem;
  font-weight: 720;
  line-height: 1.3;
}

.literature-more-label-open {
  display: none;
}

.literature-more-details[open] .literature-more-label-closed {
  display: none;
}

.literature-more-details[open] .literature-more-label-open {
  display: inline;
}

.literature-more-list {
  margin-top: 0.28rem;
}

.literature-archived-details {
  margin-top: 0.8rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--app-border-soft);
}

.literature-archived-list {
  display: grid;
  gap: 0;
  margin-top: 0.45rem;
}

.literature-archived-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--app-border-soft);
  color: var(--app-text-soft);
  font-size: 0.75rem;
}

.literature-archived-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.literature-archived-row form {
  flex: 0 0 auto;
  margin: 0;
}

.literature-empty {
  margin-top: 0.35rem;
  border-color: rgba(82, 107, 89, 0.16);
  background: var(--literature-accent-softer);
}

@media (max-width: 900px) {
  .literature-discovery-form,
  .literature-form-grid,
  .literature-link-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .literature-discovery-submit {
    width: 100%;
    padding-top: 0;
  }

  .literature-discovery-submit .ledger-action,
  .literature-lookup-row button {
    width: 100%;
  }

  .literature-discovery-save-form.is-project {
    justify-content: flex-start;
  }

  .literature-discovery-note-details {
    flex-basis: 100%;
  }

  .literature-row-footer {
    align-items: flex-start;
  }

  .literature-pdf-panel {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .literature-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .literature-capture-details,
  .literature-capture-details > summary.ledger-action {
    width: 100%;
  }

  .literature-capture-details > summary.ledger-action {
    justify-content: center;
  }

  .literature-capture-details[open] {
    grid-column: 1 / -1;
  }

  .literature-lookup-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .literature-selected-preview {
    grid-template-columns: minmax(0, 1fr);
  }

  .literature-form-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .literature-form-actions .ledger-action,
  .literature-form-actions .literature-text-action {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .literature-meta {
    display: grid;
    gap: 0.08rem;
  }

  .literature-authors {
    white-space: normal;
  }

  .literature-meta span + span::before {
    content: none;
    margin: 0;
  }

  .literature-reference-links {
    gap: 0.42rem 0.65rem;
  }

  .literature-pdf-details,
  .literature-pdf-details[open] + .literature-edit-details {
    margin-left: 0;
  }

  .literature-pdf-toolbar {
    align-items: flex-start;
  }

  .literature-pdf-heading {
    display: grid;
    gap: 0.12rem;
  }

  .literature-pdf-name {
    max-width: 100%;
    white-space: normal;
  }

  .literature-pdf-upload-form {
    align-items: stretch;
    flex-direction: column;
  }

  .literature-file-picker {
    flex-basis: auto;
    width: 100%;
  }

  .literature-pdf-upload-form input[type="file"] {
    width: 100%;
  }

  .literature-pdf-upload-form .literature-form-actions,
  .literature-pdf-upload-form .ledger-action {
    width: 100%;
  }

  .literature-archived-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .literature-panel *,
  .literature-discovery * {
    scroll-behavior: auto !important;
  }
}

.literature-panel summary:focus-visible,
.literature-panel a:focus-visible,
.literature-panel button:focus-visible,
.literature-panel input:focus-visible,
.literature-panel select:focus-visible,
.literature-panel textarea:focus-visible,
.literature-discovery summary:focus-visible,
.literature-discovery a:focus-visible,
.literature-discovery button:focus-visible {
  outline: 2px solid var(--app-accent-strong);
  outline-offset: 2px;
}

/* Project reasoning question starters: optional prompts, never required modes. */
.reasoning-prompt-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.reasoning-prompt-shortcuts-label {
  margin-right: 0.1rem;
  color: var(--app-text-faint);
  font-family: var(--app-mono);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

button.reasoning-prompt-shortcut {
  width: auto;
  min-height: 1.8rem;
  margin: 0;
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(124, 113, 92, 0.22);
  background: transparent;
  color: var(--app-text-soft);
  box-shadow: none;
  font-family: var(--app-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: none;
}

button.reasoning-prompt-shortcut:hover,
button.reasoning-prompt-shortcut:focus-visible {
  border-color: rgba(183, 119, 45, 0.46);
  background: rgba(244, 234, 216, 0.35);
  color: var(--app-text);
  box-shadow: none;
}

@media (max-width: 640px) {
  .reasoning-prompt-shortcuts {
    gap: 0.26rem;
  }

  .reasoning-prompt-shortcuts-label {
    flex-basis: 100%;
    margin-bottom: 0.05rem;
  }
}

/* Shared lightweight scientific-file profile presentation. */
.scientific-profile-line,
.scientific-verification-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.18rem 0.38rem;
  margin-top: 0.22rem;
  color: var(--app-text-soft);
  font-size: 0.66rem;
  line-height: 1.35;
}

.scientific-profile-label {
  color: var(--app-text-faint);
  font-family: var(--app-mono);
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scientific-verification-line strong {
  font-size: 0.68rem;
  font-weight: 760;
}

.scientific-verification-warning {
  color: #795f2e;
}

.scientific-verification-danger {
  color: #8c3b3b;
}

/* Shared Method authoring shell: Protocol and Code use the same quiet, ordered hierarchy. */
.method-editor-page {
  width: 100%;
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.method-editor-page > .workspace-hero-panel > .ledger-section {
  padding: 0.7rem 0.9rem;
}

.method-editor-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
}

.method-editor-title {
  margin: 0.12rem 0 0;
  font-family: var(--app-serif);
  font-size: clamp(1.72rem, 2.6vw, 2.2rem);
  font-weight: 650;
  letter-spacing: -0.05em;
  line-height: 1;
}

.method-editor-subtitle {
  max-width: 620px;
  margin: 0.34rem 0 0;
  color: var(--app-text-soft);
  font-size: 0.76rem;
  line-height: 1.4;
}

.method-editor-actions,
.method-editor-footer,
.method-editor-section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.method-editor-actions,
.method-editor-footer {
  justify-content: flex-end;
}

.method-editor-actions .ledger-action,
.method-editor-section-actions .ledger-action,
.method-editor-footer .ledger-action {
  width: auto !important;
  margin: 0;
  flex: 0 0 auto;
}

.method-editor-section-actions .ledger-action {
  min-height: 1.85rem;
  padding: 0.28rem 0.5rem;
  font-size: 0.58rem;
}

.method-editor-form {
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.method-editor-main-panel > .ledger-section {
  padding-top: 0.3rem;
  padding-bottom: 0.35rem;
}

.method-editor-error {
  padding: 0.72rem 0.82rem;
  border: 1px solid rgba(159, 63, 47, 0.28);
  background: #fbefef;
  color: #6f2d2d;
  font-size: 0.78rem;
  line-height: 1.4;
}

.method-editor-section {
  display: grid;
  gap: 0.48rem;
  padding: 0.82rem 0;
  border-top: 1px solid rgba(113, 92, 52, 0.13);
}

.method-editor-section:first-child {
  padding-top: 0.58rem;
  border-top: 0;
}

.method-editor-section:last-child {
  padding-bottom: 0.58rem;
}

.method-editor-section-head {
  display: grid;
  grid-template-columns: 1.85rem minmax(0, 1fr) auto;
  gap: 0.58rem;
  align-items: start;
}

.method-editor-section-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.38rem;
  height: 1.38rem;
  margin-top: 0.01rem;
  border: 1px solid rgba(113, 92, 52, 0.2);
  background: rgba(255, 253, 246, 0.36);
  color: var(--app-text-faint);
  font-family: var(--app-mono);
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.method-editor-section-title {
  margin: 0;
  color: var(--app-text);
  font-family: var(--app-serif);
  font-size: 1.04rem;
  font-weight: 650;
  letter-spacing: -0.028em;
  line-height: 1.15;
}

.method-editor-title-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.38rem;
}

.method-editor-optional-label,
.method-editor-label-optional {
  color: var(--app-text-faint);
  font-family: var(--app-mono);
  font-size: 0.5rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.method-editor-label-optional {
  margin-left: 0.18rem;
}

.method-editor-section-note {
  max-width: 560px;
  margin: 0.12rem 0 0;
  color: var(--app-text-soft);
  font-size: 0.68rem;
  line-height: 1.35;
}

.method-editor-section-body {
  min-width: 0;
  margin-left: 2.43rem;
}

.method-editor-type-switch {
  width: min(100%, 24rem);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.method-editor-type-option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  padding: 0.42rem 0.7rem;
  border: 1px solid var(--app-border);
  background: rgba(255, 253, 246, 0.35);
  color: var(--app-text-soft);
  font-size: 0.76rem;
  font-weight: 760;
  text-decoration: none;
}

.method-editor-type-option:hover {
  border-color: var(--app-border-strong);
  background: rgba(244, 234, 216, 0.25);
  color: var(--app-text);
  text-decoration: none;
}

.method-editor-type-option.is-active {
  border-color: rgba(40, 63, 102, 0.36);
  background: rgba(40, 63, 102, 0.075);
  color: var(--app-text);
}

.method-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.42fr);
  gap: 0.58rem 0.68rem;
}

.method-editor-field {
  display: grid;
  gap: 0.23rem;
  min-width: 0;
  margin: 0;
}

.method-editor-field.full {
  grid-column: 1 / -1;
}

.method-editor-field label {
  margin: 0;
  color: var(--app-text-faint);
  font-family: var(--app-mono);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.075em;
  line-height: 1.1;
  text-transform: uppercase;
}

.method-editor-field input,
.method-editor-field textarea,
.method-editor-field select,
.method-editor-row input,
.method-editor-row textarea,
.method-editor-row select,
.method-editor-step-row input,
.method-editor-step-row textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 1.9rem;
  margin: 0;
  padding: 0.3rem 0.42rem;
  border: 1px solid rgba(113, 92, 52, 0.24);
  border-radius: 0;
  background: rgba(255, 253, 246, 0.62);
  box-shadow: none;
  color: var(--app-text);
  font-size: 0.72rem;
}

.method-editor-field input:focus,
.method-editor-field textarea:focus,
.method-editor-field select:focus,
.method-editor-row input:focus,
.method-editor-row textarea:focus,
.method-editor-row select:focus,
.method-editor-step-row input:focus,
.method-editor-step-row textarea:focus {
  border-color: var(--app-border-strong);
  box-shadow: 0 0 0 1px var(--app-border-strong);
}

.method-editor-field textarea,
.method-editor-step-row textarea {
  resize: vertical;
  line-height: 1.48;
}

.method-editor-field textarea {
  min-height: 4.5rem;
}

.method-editor-field textarea.method-editor-purpose {
  min-height: 4rem;
}

.method-editor-field textarea.method-editor-source-text {
  min-height: 11rem;
  max-height: 30rem;
  overflow: auto;
  padding: 0.56rem;
  font-size: 0.78rem;
  line-height: 1.55;
}

.method-editor-hint,
.method-editor-status {
  margin: 0.16rem 0 0;
  color: var(--app-text-faint);
  font-size: 0.65rem;
  line-height: 1.35;
}

.method-editor-status.is-error {
  color: var(--app-danger);
}

.method-editor-sync-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0 0 0.8rem;
  padding: 0.62rem 0.72rem;
  border: 1px solid rgba(154, 106, 34, 0.34);
  border-left: 3px solid var(--app-warning);
  background: rgba(154, 106, 34, 0.07);
  color: var(--app-text-soft);
}

.method-editor-sync-banner[hidden] {
  display: none;
}

.method-editor-sync-banner > div {
  min-width: 0;
}

.method-editor-sync-banner strong,
.method-editor-sync-banner span {
  display: block;
}

.method-editor-sync-banner strong {
  color: var(--app-text);
  font-size: 0.76rem;
  line-height: 1.3;
}

.method-editor-sync-banner span {
  margin-top: 0.12rem;
  font-size: 0.68rem;
  line-height: 1.4;
}

.method-editor-sync-banner .ledger-action {
  flex: 0 0 auto;
  width: auto !important;
  margin: 0 !important;
}

.method-editor-rows,
.method-editor-step-list {
  display: grid;
}

.method-editor-row {
  display: grid;
  gap: 0.3rem;
  padding: 0.3rem 0;
  border-top: 1px solid var(--app-border-soft);
}

.method-editor-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.method-editor-setting-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.62fr) 4.8rem 1.25rem;
  align-items: center;
}

.method-editor-remove,
.method-editor-step-action {
  width: 1.2rem;
  min-width: 1.2rem;
  min-height: 1.2rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--app-text-soft);
  font-size: 0.9rem;
  line-height: 1;
  text-transform: none;
}

.method-editor-remove:hover,
.method-editor-remove:focus-visible,
.method-editor-step-action.remove:hover,
.method-editor-step-action.remove:focus-visible {
  color: var(--app-danger);
  background: transparent;
  box-shadow: none;
}

.method-editor-step-row {
  display: grid;
  grid-template-columns: 1.65rem minmax(0, 1fr) auto;
  gap: 0.42rem;
  align-items: start;
  padding: 0.42rem 0;
  border-top: 1px solid var(--app-border-soft);
}

.method-editor-step-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.method-editor-step-index {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--app-border);
  color: var(--app-text-soft);
  font-family: var(--app-mono);
  font-size: 0.58rem;
  font-weight: 800;
}

.method-editor-step-fields {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.method-editor-step-row textarea {
  min-height: 3.2rem;
  max-height: 14rem;
}

.method-editor-step-actions {
  display: flex;
  gap: 0.15rem;
}

.method-editor-step-action:hover,
.method-editor-step-action:focus-visible {
  background: transparent;
  color: var(--app-text);
}

.method-editor-empty {
  margin: 0;
  padding: 0.12rem 0;
  color: var(--app-text-faint);
  font-size: 0.68rem;
  line-height: 1.35;
}

.method-editor-optional {
  margin: 0.52rem 0 0;
  border-top: 1px solid rgba(113, 92, 52, 0.11);
}

.method-editor-optional > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0;
  list-style: none;
  cursor: pointer;
  background-image: none !important;
  color: var(--app-text-soft);
  font-size: 0.72rem;
  font-weight: 720;
}

.method-editor-optional > summary::before,
.method-editor-optional > summary::after {
  content: none !important;
  display: none !important;
}

.method-editor-optional > summary::-webkit-details-marker {
  display: none;
}

.method-editor-optional-meta {
  color: var(--app-text-faint);
  font-size: 0.62rem;
  font-weight: 650;
}

.method-editor-optional-body {
  padding: 0.05rem 0 0.3rem;
}

.method-editor-source-note {
  padding: 0.5rem 0.6rem;
  border-left: 2px solid rgba(113, 92, 52, 0.18);
  background: rgba(244, 234, 216, 0.14);
  color: var(--app-text-soft);
  font-size: 0.68rem;
  line-height: 1.4;
}

.method-editor-footer {
  padding: 0.15rem 0 0;
}


.method-editor-source-entry {
  display: grid;
  gap: 0.5rem;
}

.method-editor-source-choice {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--app-text-faint);
  font-size: 0.64rem;
}

.method-editor-source-choice span:first-child {
  font-family: var(--app-mono);
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.method-editor-inline-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.method-editor-inline-action .ledger-action,
.method-editor-derive-head > .ledger-action,
.method-editor-extract-block-head .ledger-action,
.method-editor-step-toolbar .ledger-action,
.code-flow-head .ledger-action,
.code-runtime-head .ledger-action {
  width: auto !important;
  min-height: 1.82rem;
  margin: 0;
  padding: 0.27rem 0.48rem;
  flex: 0 0 auto;
  font-size: 0.57rem;
}

.method-editor-code-source {
  font-family: var(--app-mono);
  font-size: 0.73rem !important;
  line-height: 1.5 !important;
  white-space: pre;
  tab-size: 2;
}

.method-editor-derive-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: 0;
  border-top: 1px solid rgba(113, 92, 52, 0.13);
}

.method-editor-derive-column {
  min-width: 0;
  padding: 0.85rem 0.82rem 0.68rem 0;
}

.method-editor-derive-column + .method-editor-derive-column {
  padding-left: 0.82rem;
  padding-right: 0;
  border-left: 1px solid rgba(113, 92, 52, 0.16);
}

.method-editor-derive-head {
  display: grid;
  grid-template-columns: 1.85rem minmax(0, 1fr) auto;
  gap: 0.58rem;
  align-items: start;
}

.method-editor-derive-title-wrap {
  min-width: 0;
}

.method-editor-derive-column > .method-editor-status {
  display: block;
  margin: 0.35rem 0 0 2.43rem;
}

.method-editor-derive-body {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  margin: 0.6rem 0 0 2.43rem;
}

.method-editor-extract-block {
  display: grid;
  gap: 0.42rem;
  min-width: 0;
  padding-top: 0.62rem;
  border-top: 1px solid var(--app-border-soft);
}

.method-editor-extract-block:first-child {
  padding-top: 0;
  border-top: 0;
}

.method-editor-extract-block-head,
.method-editor-step-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem;
}

.method-editor-extract-label {
  color: var(--app-text);
  font-family: var(--app-mono);
  font-size: 0.57rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.method-editor-extract-block-head p {
  margin: 0.08rem 0 0;
  color: var(--app-text-soft);
  font-size: 0.64rem;
  line-height: 1.32;
}

.method-editor-guidance-field textarea {
  min-height: 3.15rem;
  max-height: 7rem;
}

.method-editor-step-toolbar {
  align-items: center;
  padding-top: 0.15rem;
}

@media (max-width: 700px) {
  .method-editor-sync-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .method-editor-sync-banner .ledger-action {
    width: 100% !important;
  }

  .method-editor-page {
    width: 100%;
  }

  .method-editor-hero,
  .method-editor-grid {
    grid-template-columns: 1fr;
  }

  .method-editor-derive-grid {
    grid-template-columns: 1fr;
  }

  .method-editor-derive-column,
  .method-editor-derive-column + .method-editor-derive-column {
    padding: 0.78rem 0;
    border-left: 0;
  }

  .method-editor-derive-column + .method-editor-derive-column {
    border-top: 1px solid rgba(113, 92, 52, 0.16);
  }

  .method-editor-derive-head {
    grid-template-columns: 1.7rem minmax(0, 1fr);
    gap: 0.48rem;
  }

  .method-editor-derive-head > .ledger-action {
    grid-column: 2;
    justify-self: start;
  }

  .method-editor-derive-column > .method-editor-status,
  .method-editor-derive-body {
    margin-left: 2.18rem;
  }

  .method-editor-section-head {
    grid-template-columns: 1.7rem minmax(0, 1fr);
    gap: 0.48rem;
  }

  .method-editor-section-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .method-editor-section-body {
    margin-left: 2.18rem;
  }

  .method-editor-type-switch {
    width: 100%;
  }

  .method-editor-setting-row {
    grid-template-columns: 1fr;
  }

  .method-editor-remove {
    justify-self: end;
  }

  .method-editor-step-row {
    grid-template-columns: 1.6rem minmax(0, 1fr);
  }

  .method-editor-step-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .method-editor-actions,
  .method-editor-footer {
    justify-content: flex-start;
  }

  .method-editor-field.full {
    grid-column: auto;
  }
}


/* Dense Method derivation and saved-record readers. Keep Protocol and Code mechanics aligned. */
.method-editor-extract-block > .method-editor-rows,
.code-flow-block > .method-editor-rows,
.code-runtime > .method-editor-rows {
  max-height: 15rem;
  overflow-y: auto;
  padding-right: 0.22rem;
  scrollbar-width: thin;
}

.method-editor-step-list {
  max-height: 34rem;
  overflow-y: auto;
  padding-right: 0.24rem;
  scrollbar-width: thin;
}

.method-editor-code-step {
  min-height: 5.2rem !important;
  max-height: 14rem !important;
  overflow: auto;
  font-family: var(--app-mono);
  font-size: 0.68rem !important;
  line-height: 1.45 !important;
  white-space: pre;
  tab-size: 2;
}

.code-document.method-reader,
.protocol-document.method-reader {
  box-sizing: border-box;
  max-height: min(30rem, 58vh);
  overflow: auto;
  margin: 0;
  padding: 0.68rem 0.78rem;
  border: 1px solid var(--app-border-soft);
  background: rgba(255, 253, 246, 0.42);
  scrollbar-width: thin;
}

.code-document.method-reader {
  white-space: pre;
  overflow-wrap: normal;
}

.protocol-document.method-reader {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code-step-display.method-step-reader,
.protocol-step-display.method-step-reader {
  max-height: min(30rem, 58vh);
  overflow-y: auto;
  padding-right: 0.28rem;
  scrollbar-width: thin;
}

.code-step-code.method-step-code-reader {
  max-height: 12rem;
  overflow: auto;
  white-space: pre;
  overflow-wrap: normal;
}

.code-side.method-record-side .ledger-section,
.protocol-side.method-record-side .ledger-section {
  padding: 0.72rem 0.78rem;
}

.method-compare-diff.method-compare-reader {
  max-height: min(30rem, 58vh);
  overflow: auto;
  scrollbar-width: thin;
}

@media (max-width: 700px) {
  .method-editor-extract-block > .method-editor-rows,
  .code-flow-block > .method-editor-rows,
  .code-runtime > .method-editor-rows,
  .method-editor-step-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .code-document.method-reader,
  .protocol-document.method-reader,
  .code-step-display.method-step-reader,
  .protocol-step-display.method-step-reader,
  .method-compare-diff.method-compare-reader {
    max-height: 26rem;
  }
}

/* Keep long Method source inside its own reader instead of widening the page. */
.code-page,
.protocol-page,
.code-layout,
.protocol-layout,
.code-main,
.protocol-main,
.code-side,
.protocol-side,
.code-main > *,
.protocol-main > *,
.method-compare-page {
  min-width: 0;
  max-width: 100%;
}

.code-layout,
.protocol-layout {
  width: 100%;
}

.code-main > .ledger-panel,
.protocol-main > .ledger-panel,
.method-compare-page > .ledger-panel {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.code-main .ledger-section,
.protocol-main .ledger-section,
.method-compare-page .ledger-section {
  min-width: 0;
  max-width: 100%;
}

.code-document.method-reader,
.protocol-document.method-reader,
.code-step-code.method-step-code-reader,
.method-compare-diff.method-compare-reader {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.code-document.method-reader,
.code-step-code.method-step-code-reader,
.method-compare-diff.method-compare-reader.is-code {
  overflow-x: auto;
}

.code-document.method-reader > code,
.code-step-code.method-step-code-reader > code {
  display: block;
  width: max-content;
  min-width: 100%;
  max-width: none;
}

.code-step-row > :last-child,
.protocol-step-display-row > :last-child {
  min-width: 0;
  max-width: 100%;
}

/* Keep saved Method records and comparisons information-dense. */
.code-main .ledger-section,
.protocol-main .ledger-section {
  padding: 0.9rem 1rem;
}

.method-compare-page .ledger-section {
  padding: 0.9rem 1rem;
}

.method-editor-row-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.62fr) 4.8rem 1.25rem;
  gap: 0.3rem;
  padding: 0 0 0.22rem;
  color: var(--app-text-faint);
  font-family: var(--app-mono);
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@media (max-width: 700px) {
  .method-editor-row-head {
    display: none;
  }
}

/* Shared Method compare surface: canonical source only, aligned controls, compact diffs. */
.method-compare-page {
  display: grid;
  gap: 1rem;
  margin: 0;
}

.method-compare-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.15rem;
  align-items: start;
}

.method-compare-title {
  max-width: 900px;
  margin: 0.32rem 0 0;
  font-family: var(--app-serif);
  font-size: clamp(1.9rem, 3.1vw, 3rem);
  font-weight: 650;
  letter-spacing: -0.065em;
  line-height: 0.96;
}

.method-compare-subtitle {
  max-width: 760px;
  margin: 0.5rem 0 0;
  color: var(--app-text-soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.method-compare-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.method-compare-actions .ledger-action,
.method-compare-version-form .ledger-action {
  width: auto !important;
  margin: 0 !important;
  flex: 0 0 auto;
}

.method-compare-control-section {
  padding-top: 1rem !important;
  padding-bottom: 1rem !important;
}

.method-compare-control-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
}

.method-compare-control-copy {
  min-width: 0;
}

.method-compare-control-title {
  margin: 0.18rem 0 0;
  color: var(--app-text);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.25;
}

.method-compare-control-note {
  margin: 0.24rem 0 0;
  color: var(--app-text-soft);
  font-size: 0.78rem;
  line-height: 1.4;
}

.method-compare-version-form {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 0.5rem;
  align-items: end;
  justify-content: end;
  margin: 0;
}

.method-compare-field {
  display: grid;
  grid-template-rows: 0.68rem 2.15rem;
  gap: 0.28rem;
  margin: 0;
}

.method-compare-field label {
  margin: 0;
  color: var(--app-text-faint);
  font-family: var(--app-mono);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 0.68rem;
  text-transform: uppercase;
}

.method-compare-field select,
.method-compare-submit {
  box-sizing: border-box;
  height: 2.15rem;
  min-height: 2.15rem;
  margin: 0;
}

.method-compare-field select {
  width: 7rem;
  min-width: 7rem;
  padding: 0 1.8rem 0 0.55rem;
  border: 1px solid var(--app-border);
  border-radius: 0;
  background: rgba(255, 253, 246, 0.76);
  box-shadow: none;
  color: var(--app-text);
  font-size: 0.8rem;
}

.method-compare-field select:focus {
  border-color: var(--app-border-strong);
  box-shadow: 0 0 0 1px var(--app-border-strong);
}

.method-compare-submit {
  min-width: 6.8rem;
  align-self: end;
  padding-top: 0;
  padding-bottom: 0;
}

.method-compare-card-title {
  margin: 0;
  font-family: var(--app-serif);
  font-size: 1.7rem;
  font-weight: 650;
  letter-spacing: -0.05em;
  line-height: 1.05;
}

.method-compare-card-note {
  margin: 0.35rem 0 0;
  color: var(--app-text-soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.method-compare-diff {
  padding: 0.2rem 0;
  font-family: var(--app-mono);
  font-size: 0.74rem;
  line-height: 1.52;
}

.method-compare-line {
  display: block;
  min-height: 1.45rem;
  padding: 0.14rem 0.5rem;
}

.method-compare-line.added {
  background: rgba(66, 102, 77, 0.1);
}

.method-compare-line.removed {
  background: rgba(159, 63, 47, 0.08);
}

.method-compare-line.gap {
  color: var(--app-text-faint);
  font-style: italic;
}

.method-compare-diff.is-code .method-compare-line {
  width: max-content;
  min-width: 100%;
  white-space: pre;
  overflow-wrap: normal;
}

.method-compare-diff.is-protocol .method-compare-line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.method-compare-prefix {
  display: inline-block;
  width: 1.3rem;
  color: var(--app-text-soft);
}

.method-compare-empty {
  display: block;
  margin: 0;
  padding: 0.2rem 0.5rem;
  color: var(--app-text-soft);
  font-size: 0.82rem;
  line-height: 1.4;
}

/* Recent Method controls use explicit box heights/baselines instead of native control sizing. */
.method-editor-inline-action .ledger-action,
.method-editor-derive-head > .ledger-action,
.method-editor-extract-block-head .ledger-action,
.method-editor-step-toolbar .ledger-action,
.code-flow-head .ledger-action,
.code-runtime-head .ledger-action {
  box-sizing: border-box;
  height: 1.82rem;
  min-height: 1.82rem;
  line-height: 1;
}

.method-editor-actions,
.method-editor-footer,
.method-editor-section-actions,
.method-editor-inline-action,
.method-editor-extract-block-head,
.method-editor-step-toolbar,
.code-flow-head,
.code-runtime-head,
.code-actions,
.protocol-actions,
.code-source-action,
.protocol-source-action {
  align-items: center;
}

.method-editor-derive-head > .ledger-action {
  align-self: start;
}

@media (max-width: 900px) {
  .method-compare-control-layout {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .method-compare-version-form {
    justify-content: start;
  }
}

@media (max-width: 720px) {
  .method-compare-hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .method-compare-actions {
    justify-content: flex-start;
  }

  .method-compare-version-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    width: 100%;
  }

  .method-compare-field select {
    width: 100%;
    min-width: 0;
  }

  .method-compare-submit {
    grid-column: 1 / -1;
    width: 100% !important;
  }
}

/* C7E Code no-split result: make the intentional single-block decision unmistakable. */
.method-editor-status.is-strong {
  max-width: 34rem;
  margin-top: 0.48rem;
  padding: 0.5rem 0.62rem;
  border-left: 3px solid var(--app-text);
  background: rgba(113, 92, 52, 0.07);
  color: var(--app-text);
  font-size: 0.76rem;
  font-weight: 820;
  line-height: 1.4;
}
