/*** STATS ***/
.stats article.stat {
  margin: 0 0 var(--spacing, 1rem);
  padding: 1rem 1.25rem;
}
.stat small {
  display: block;
  color: var(--muted-color);
}
.stat strong {
  display: block;
  font-size: 2rem;
  line-height: 1.2;
}
.stat strong.stat-date {
  font-size: 1.35rem;
  line-height: 2.4rem;
}

/*** LIST / GRID ***/
.docs-toolbar {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}
.docs-toolbar input[type="search"] {
  flex: 1;
}
.view-toggle {
  display: flex;
  gap: .25rem;
}
.view-toggle button {
  width: auto;
  padding: .6rem .8rem;
  line-height: 1;
}
.view-toggle button.active {
  background-color: var(--secondary);
  color: var(--secondary-inverse);
}
.docs-list,
html[data-layout="list"] .docs-grid {
  display: none;
}
html[data-layout="list"] .docs-list {
  display: block;
}
[data-search][hidden] {
  display: none !important;
}
.docs-list td.row-actions {
  text-align: right;
  white-space: nowrap;
}
.docs-list td.row-actions a + a {
  margin-left: .75rem;
}

/*** CARDS ***/
.docs-grid {
  margin-top: .5rem;
}
.doc-item {
  display: flex;
  margin-bottom: 1.5rem;
}
.doc-card {
  --card-radius: 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: var(--card-radius);
  border: 1px solid var(--muted-border-color);
  box-shadow: 0 1px 2px rgba(16, 24, 32, .04), 0 2px 8px rgba(16, 24, 32, .04);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.doc-card:hover,
.doc-card:focus-within {
  transform: translateY(-3px);
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(16, 24, 32, .06), 0 14px 32px rgba(16, 24, 32, .10);
}
.doc-banner {
  position: relative;
  height: 112px;
  flex-shrink: 0;
  background-size: auto;
  background-position: center;
  transition: filter .2s ease;
}
.doc-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .06);
  pointer-events: none;
}
.doc-card:hover .doc-banner {
  filter: saturate(1.15) brightness(1.03);
}
.doc-chip {
  position: absolute;
  top: .75rem;
  left: .75rem;
  max-width: calc(100% - 1.5rem);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: #1f2d38;
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.doc-body {
  flex: 1;
  padding: 1.1rem 1.25rem .9rem;
}
.doc-title {
  margin: 0 0 .45rem;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.doc-title a {
  color: var(--ink-strong);
  text-decoration: none;
}
.doc-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}
.doc-card:hover .doc-title a {
  color: var(--primary);
}
.doc-meta {
  margin: 0;
  font-size: .8rem;
  color: var(--muted-color);
}
.doc-meta strong {
  font-weight: 600;
  color: var(--color);
}
article.doc-card > footer.doc-actions {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: .7rem 1.25rem;
  border-top: 1px solid var(--muted-border-color);
  background: transparent;
  font-size: .85rem;
}
.doc-open {
  font-weight: 600;
  text-decoration: none;
}
.doc-open span {
  display: inline-block;
  transition: transform .2s ease;
}
.doc-card:hover .doc-open span {
  transform: translateX(3px);
}
.doc-tools {
  display: flex;
  align-items: center;
  gap: 1rem;
}
article.doc-card .doc-tools a,
article.doc-card .doc-tools .link-button {
  color: var(--muted-color);
  text-decoration: none;
  font-size: .8rem;
  line-height: 1.5;
}
.doc-tools a:hover {
  color: var(--primary);
}
.doc-tools .link-button {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
  line-height: inherit;
  cursor: pointer;
}
.doc-tools .doc-delete:hover {
  color: #c62828;
}
.doc-stats {
  display: flex;
  gap: 1.25rem;
  margin: .6rem 0 0;
  font-size: .8rem;
  color: var(--muted-color);
}
.doc-stats strong {
  display: block;
  font-size: 1.15rem;
  line-height: 1.2;
  color: var(--color);
}
[data-theme="dark"] .doc-card {
  box-shadow: none;
}
[data-theme="dark"] .doc-card:hover,
[data-theme="dark"] .doc-card:focus-within {
  border-color: var(--muted-border-color);
  box-shadow: 0 14px 32px rgba(0, 0, 0, .35);
}
[data-theme="dark"] .doc-chip {
  color: #edf0f3;
  background: rgba(17, 25, 31, .72);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .doc-card { box-shadow: none; }
  :root:not([data-theme="light"]) .doc-card:hover,
  :root:not([data-theme="light"]) .doc-card:focus-within {
    border-color: var(--muted-border-color);
    box-shadow: 0 14px 32px rgba(0, 0, 0, .35);
  }
  :root:not([data-theme="light"]) .doc-chip {
    color: #edf0f3;
    background: rgba(17, 25, 31, .72);
  }
}
@media (prefers-reduced-motion: reduce) {
  .doc-card, .doc-banner, .doc-open span { transition: none; }
  .doc-card:hover, .doc-card:focus-within { transform: none; }
}

/* stats cards share one height */
.stats > [class*="col-"] {
  display: flex;
}
.stats article.stat {
  width: 100%;
}

/*** CLIENT RAIL ***/
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.client-rail {
  --rail-tile: 44px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  width: 76px;
  padding: 1rem 0;
  background: var(--card-sectionning-background-color);
  border-right: 1px solid var(--muted-border-color);
}
.rail-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .4rem 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.rail-list::-webkit-scrollbar {
  display: none;
}
.rail-item {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--rail-tile);
  height: var(--rail-tile);
  border-radius: 12px;
  background-color: var(--card-background-color);
  background-size: 120px;
  background-position: center;
  color: var(--muted-color);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(16, 24, 32, .08);
  transition: transform .15s ease, box-shadow .15s ease, border-radius .15s ease;
}
.rail-item:hover,
.rail-item:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 24, 32, .16);
}
.rail-initials {
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.rail-item::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  width: 4px;
  height: 30px;
  margin-top: -15px;
  border-radius: 0 4px 4px 0;
  background: var(--contrast);
  opacity: 0;
  transform: scaleY(0);
  transition: transform .15s ease, opacity .15s ease;
}
.rail-item:hover::before {
  opacity: 1;
  transform: scaleY(.45);
}
.rail-item.active::before {
  opacity: 1;
  transform: scaleY(1);
}
.rail-item.active {
  box-shadow: 0 0 0 2px var(--card-sectionning-background-color), 0 0 0 4px var(--contrast);
}
.rail-all.active {
  background-color: var(--contrast);
  color: var(--contrast-inverse);
}
.rail-add {
  background: transparent;
  border: 1.5px dashed var(--muted-border-color);
  box-shadow: none;
}
.rail-add:hover {
  color: var(--primary);
  border-color: var(--primary);
}
.rail-divider {
  width: 28px;
  height: 2px;
  flex-shrink: 0;
  border-radius: 2px;
  background: var(--muted-border-color);
}
#rail-tip {
  position: fixed;
  z-index: 1001;
  padding: .3rem .6rem;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  color: #fff;
  background: #1f2d38;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
  pointer-events: none;
  opacity: 0;
  transform: translate(-4px, -50%);
  transition: opacity .12s ease, transform .12s ease;
}
#rail-tip.show {
  opacity: 1;
  transform: translate(0, -50%);
}
[data-theme="dark"] #rail-tip {
  color: #1f2d38;
  background: #edf0f3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #rail-tip {
    color: #1f2d38;
    background: #edf0f3;
  }
}
/*** CLIENTS ***/

/*** BASE ***/
:root,
[data-theme] {
  --brand: #e5484d;
  /* Text colour captured at the root: inside links Pico redefines --color as the link colour. */
  --ink: var(--color);
  --ink-strong: var(--h1-color, var(--color));
}
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body > main {
  flex: 1;
  padding-top: 2rem;
}
.site-footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--muted-color);
}
.link-button {
  display: inline;
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  cursor: pointer;
}
.link-button:hover,
.link-button:focus {
  background: none;
  color: var(--primary-hover);
  text-decoration: underline;
}
.inline-form {
  display: inline;
  margin: 0;
}

.notice {
  padding: .75rem 1rem;
  border-radius: var(--border-radius);
  background: rgba(46, 160, 67, .12);
  color: var(--color);
}
.form-error {
  padding: .75rem 1rem;
  border-radius: var(--border-radius);
  background: rgba(229, 72, 77, .12);
  color: var(--color);
}
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}
.page-heading {
  margin-bottom: 1.75rem;
}
.page-heading h1 {
  font-size: 1.75rem;
}

/*** TOP BAR ***/
.topbar {
  padding: 0;
  border-bottom: 1px solid var(--muted-border-color);
  background: var(--card-sectionning-background-color);
}
.topbar nav {
  padding-top: .15rem;
  padding-bottom: .15rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  color: var(--h1-color, var(--color));
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  letter-spacing: -.01em;
}
.brand:hover {
  color: var(--h1-color, var(--color));
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
}
.brand-mark-lg {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  font-size: 1.7rem;
}
.topbar a.current {
  color: var(--color);
  font-weight: 600;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--contrast);
  color: var(--contrast-inverse);
  font-size: .78rem;
  font-weight: 700;
}

/*** LOGIN ***/
.login-page {
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(229, 72, 77, .10), transparent 60%),
    var(--background-color);
}
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  margin: 0;
  border-radius: 16px;
}
.login-card > header {
  text-align: center;
}
.login-card h1 {
  margin: .9rem 0 .25rem;
  font-size: 1.5rem;
}
.login-card header p {
  margin: 0;
  color: var(--muted-color);
}
.login-card button[type="submit"] {
  margin-bottom: 0;
}

/*** APP LAYOUT: rail + panel + content ***/
:root {
  --rail-w: 76px;
  --panel-w: 264px;
}
body.has-panel {
  padding-left: var(--panel-w);
}
body.has-rail.has-panel {
  padding-left: calc(var(--rail-w) + var(--panel-w));
}
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding-left: 2rem;
  padding-right: 2rem;
}
.page.narrow {
  max-width: 860px;
}
.muted {
  color: var(--muted-color);
}
.icon {
  flex-shrink: 0;
  vertical-align: -2px;
}

/*** SIDE PANEL ***/
.side-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 999;
  width: var(--panel-w);
  overflow-y: auto;
  padding: 1.1rem .75rem 2rem;
  background: var(--card-background-color);
  border-right: 1px solid var(--muted-border-color);
  font-size: .9rem;
}
body.has-rail .side-panel {
  left: var(--rail-w);
}
.panel-head {
  padding: .15rem .6rem 1rem;
}
.panel-title {
  display: block;
  color: var(--ink-strong);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
a.panel-title:hover {
  color: var(--primary);
}
.panel-sub {
  color: var(--muted-color);
  font-size: .78rem;
}
.panel-section {
  margin: 0 0 1.1rem;
}
.panel-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .6rem;
  margin-bottom: .7rem;
  color: var(--muted-color);
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.2;
}
.panel-action {
  display: inline-flex;
  margin: -.15rem 0;
  padding: .15rem;
  border-radius: 6px;
  color: var(--muted-color);
}
.panel-action:hover {
  color: var(--primary);
  background: var(--card-sectionning-background-color);
}
.side-panel ul {
  margin: 0;
  padding: 0;
}
.side-panel li {
  list-style: none;
  margin: 0;
  padding: 0;
}
/* Doc tree: on hover the chevron covers the row's icon or swatch, like Notion. It covers it with
   the row's hover background instead of hiding the swatch, because toggling visibility on the
   clipped swatch left it half-painted in some browsers. */
.tree-row {
  position: relative;
}
.side-panel .tree-toggle {
  position: absolute;
  top: 50%;
  left: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 6px;
  background: var(--card-sectionning-background-color);
  box-shadow: none;
  color: var(--muted-color);
  opacity: 0;
  cursor: pointer;
  transition: none;
}
.side-panel .tree-toggle:hover {
  background: var(--muted-border-color);
  color: var(--ink-strong);
}
.side-panel .tree-toggle:focus-visible {
  opacity: 1;
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.tree-toggle .icon {
  transition: transform .15s ease;
}
.tree-toggle[aria-expanded="true"] .icon {
  transform: rotate(90deg);
}
.tree-row:hover > .tree-toggle,
.tree-row:focus-within > .tree-toggle {
  opacity: 1;
}
@media (hover: none) {
  .side-panel .tree-toggle { opacity: 1; }
}
.side-panel .tree-children {
  margin: .1rem 0 .1rem 1.1rem;
  padding-left: .3rem;
  border-left: 1px solid var(--muted-border-color);
}
.tree-children .panel-item {
  min-height: 2rem;
  padding-top: .32rem;
  padding-bottom: .32rem;
  font-size: .92em;
}
.tree-children .panel-item .icon {
  width: 14px;
  height: 14px;
}
.side-panel li + li {
  margin-top: 2px;
}
.panel-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 2.25rem;
  padding: .42rem .6rem;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.3;
}
.panel-item .icon {
  color: var(--muted-color);
}
/* Icons take the same 20px slot as client and collection swatches so labels line up. */
.panel-item > .icon:first-child {
  flex-shrink: 0;
  margin-inline: 2px;
}
.tree-children .panel-item > .icon:first-child {
  margin-inline: 3px;
}
.panel-item:hover {
  background: var(--card-sectionning-background-color);
  color: var(--ink-strong);
}
.panel-item.active {
  background: var(--card-sectionning-background-color);
  color: var(--ink-strong);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--muted-border-color);
}
.panel-item.active .icon {
  color: var(--primary);
}
.panel-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.panel-count {
  min-width: 1.4rem;
  padding: 0 .35rem;
  border-radius: 5px;
  background: var(--card-sectionning-background-color);
  border: 1px solid var(--muted-border-color);
  color: var(--muted-color);
  font-size: .7rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.5;
}
.panel-swatch,
.panel-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  overflow: hidden;
  background-size: 60px;
  background-position: center;
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
}
.panel-logo {
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.panel-logo img,
.rail-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.panel-empty {
  margin: 0;
  padding: .2rem .6rem;
  color: var(--muted-color);
  font-size: .82rem;
}
.rail-item.has-logo {
  padding: 6px;
  background: #fff;
}

.panel-toggle {
  display: inline-flex;
  width: auto;
  margin: 0;
  padding: .45rem;
  border: 0;
  background: transparent;
  color: var(--color);
}
.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 998;
  background: rgba(10, 15, 20, .45);
}
@media (max-width: 991px) {
  body.has-panel,
  body.has-rail.has-panel {
    padding-left: 0;
  }

  .client-rail,
  .side-panel {
    transform: translateX(-110%);
    transition: transform .2s ease;
  }
  body.has-rail .side-panel {
    transform: translateX(calc(-100% - var(--rail-w) - 10px));
  }
  body.panel-open .client-rail,
  body.panel-open .side-panel {
    transform: none;
  }
  .page {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/*** TOP BAR extras ***/
.crumbs {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .9rem;
  min-width: 0;
}
.crumbs a,
.crumbs span {
  margin: 0;
  padding: 0;
  white-space: nowrap;
}
.crumb-sep {
  color: var(--muted-border-color);
}
.crumb-current {
  color: var(--muted-color);
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: .7rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  margin-left: .4rem;
  padding: .05rem .45rem;
  border-radius: 999px;
  background: var(--card-sectionning-background-color);
  border: 1px solid var(--muted-border-color);
  color: var(--muted-color);
  font-size: .7rem;
  font-weight: 600;
  vertical-align: 1px;
  white-space: nowrap;
}
.danger-link,
.danger-link:hover {
  color: #d93036;
}

/*** CARDS extras ***/
.doc-chip-right {
  left: auto;
  right: .75rem;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}
.banner-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  padding: 8px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
  transform: translate(-50%, -50%);
}
.banner-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.doc-card.is-trashed .doc-banner {
  filter: grayscale(1) opacity(.6);
}
.docs-list td.muted {
  font-size: .88rem;
}

/*** CLIENT SETTINGS ***/
.client-hero {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 1.5rem;
}
.client-hero hgroup {
  margin: 0;
}
.client-hero h1 {
  margin-bottom: .2rem;
}
.client-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  overflow: hidden;
  background-size: 160px;
  background-position: center;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.client-avatar.has-logo {
  padding: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.client-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.settings-card {
  margin: 0 0 1.25rem;
}
.settings-card > header {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.settings-card > header small {
  color: var(--muted-color);
}
.settings-list {
  margin: 0 0 1rem;
  padding: 0;
}
.settings-list li {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding: .6rem 0;
  border-bottom: 1px solid var(--muted-border-color);
}
.settings-list li:last-child {
  border-bottom: 0;
}
.settings-list li > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}
.viewer-scope {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
}
.viewer-scope .badge {
  margin: 0;
}
.inline-fields {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}
.inline-fields > input,
.inline-fields > select {
  flex: 1;
}
.inline-fields > button {
  width: auto;
  white-space: nowrap;
}
.logo-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.logo-row form {
  margin: 0;
}
.logo-row input[type="file"] {
  margin: 0;
}
.viewer-form .grid {
  margin-bottom: 0;
}

/*** DOC VIEW ***/
.doc-hero {
  height: 140px;
  background-position: center;
}
.doc-page > main {
  padding-top: 0;
}
.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 2.5rem;
  align-items: start;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 2rem;
  padding-right: 2rem;
}
.public-doc .doc-layout {
  max-width: 1040px;
}
.doc-main {
  margin-top: -3rem;
  border-radius: 14px;
  position: relative;
  min-width: 0;
  padding: 2rem 2.5rem;
}
.doc-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--muted-border-color);
}
.doc-eyebrow {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-bottom: .4rem;
  color: var(--muted-color);
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.eyebrow-logo {
  width: 18px;
  height: 18px;
  object-fit: contain;
}
.doc-heading {
  margin-bottom: .4rem;
  font-size: 2.1rem;
  line-height: 1.2;
}
.doc-byline {
  margin-bottom: .9rem;
  color: var(--muted-color);
  font-size: .9rem;
}
.doc-byline strong {
  color: var(--color);
  font-weight: 600;
}
.doc-urlbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.doc-url {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .6rem;
  border-radius: 6px;
  background: var(--card-sectionning-background-color);
  color: var(--muted-color);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.doc-aside {
  position: sticky;
  top: 1.25rem;
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.share-link {
  display: flex;
  gap: .4rem;
  margin-bottom: .6rem;
}
.share-link input {
  margin: 0;
  height: auto;
  padding: .35rem .55rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .75rem;
}

.doc-toc {
  font-size: .85rem;
}
.doc-toc ul {
  margin: 0;
  padding: 0 0 0 .75rem;
  border-left: 2px solid var(--muted-border-color);
}
.doc-toc li {
  list-style: none;
  margin: 0;
  padding: .18rem 0;
}
.doc-toc li.toc-h3 { padding-left: .75rem; }
.doc-toc a {
  display: block;
  color: var(--muted-color);
  text-decoration: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.doc-toc a:hover,
.doc-toc a.active {
  color: var(--primary);
}
.doc-toc a.active {
  font-weight: 600;
}

.trash-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: .75rem 1rem;
  border-radius: var(--border-radius);
  background: rgba(229, 72, 77, .12);
}
@media (max-width: 1199px) {
  .doc-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .doc-aside {
    position: static;
    order: -1;
    margin-top: 1rem;
  }
  .doc-main {
    margin-top: 0;
  }
  .doc-toc {
    display: none;
  }
}
@media (max-width: 991px) {
  .doc-layout {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .doc-main {
    padding: 1.25rem;
  }
}

/*** MARKDOWN READING ***/
.markdown-body {
  font-size: 1rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.markdown-body > :first-child {
  margin-top: 0;
}
.markdown-body :is(h1, h2, h3, h4) {
  margin-top: 2rem;
  margin-bottom: .6rem;
  line-height: 1.3;
  scroll-margin-top: 1.5rem;
}
.markdown-body h1 { font-size: 1.75rem; }
.markdown-body h2 { font-size: 1.4rem; padding-bottom: .3rem; border-bottom: 1px solid var(--muted-border-color); }
.markdown-body h3 { font-size: 1.15rem; }
.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table {
  margin-bottom: 1rem;
}
.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}
.markdown-body blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: .6rem 1rem;
  border-left: 3px solid var(--primary);
  background: var(--card-sectionning-background-color);
  border-radius: 0 8px 8px 0;
  color: var(--color);
}
.markdown-body blockquote > :last-child {
  margin-bottom: 0;
}
.markdown-body li {
  margin-bottom: .25rem;
}
.markdown-body li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -1.2rem;
}
.markdown-body input[type="checkbox"] {
  margin: 0 .45rem 0 0;
  vertical-align: -2px;
}
.markdown-body table {
  width: 100%;
  display: block;
  overflow-x: auto;
}
.markdown-body :not(pre) > code {
  padding: .1rem .35rem;
  border-radius: 5px;
  font-size: .87em;
}
.markdown-body pre {
  border-radius: 10px;
}

/*** EDITOR ***/
.editor-page > form {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.editor-head {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding-top: 1rem;
}
.editor-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1rem;
}
.location-picker {
  margin: 0;
  flex: 0 1 320px;
}
.location-picker select {
  margin: 0;
  padding-top: .45rem;
  padding-bottom: .45rem;
  font-size: .88rem;
}
.slug-hint {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--muted-color);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.editor-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}
.editor-actions button {
  width: auto;
  margin: 0;
  padding: .5rem 1.1rem;
}
.title-input {
  margin: 1rem 0 .5rem;
  padding: .2rem 0 !important;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 2rem;
  font-weight: 700;
  color: var(--h1-color, var(--color));
}
.editor-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 1rem;
}
.md-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .5rem;
  padding: .5rem;
  border: 1px solid var(--muted-border-color);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: var(--card-sectionning-background-color);
}
.md-group {
  display: flex;
  gap: .15rem;
  padding-right: .5rem;
  border-right: 1px solid var(--muted-border-color);
}
.md-group:last-of-type {
  border-right: 0;
}
.md-toolbar .md-btn {
  --background-color: transparent;
  --border-color: transparent;
  --color: var(--color);
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  width: auto;
  margin: 0;
  padding: .3rem .5rem;
  border-radius: 7px;
  font-size: .8rem;
  line-height: 1.2;
  box-shadow: none;
}
.md-toolbar .md-btn:hover,
.md-toolbar .md-btn:focus-visible {
  --background-color: var(--card-background-color);
  --border-color: var(--muted-border-color);
  --color: var(--primary);
}
.md-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1rem;
  font-weight: 700;
  font-family: ui-serif, Georgia, serif;
}
.md-label {
  color: var(--muted-color);
}
.md-btn:hover .md-label {
  color: inherit;
}
.md-modes {
  display: flex;
  margin-left: auto;
  padding: .15rem;
  border-radius: 8px;
  background: var(--card-background-color);
  border: 1px solid var(--muted-border-color);
}
.md-modes button {
  --background-color: transparent;
  --border-color: transparent;
  --color: var(--muted-color);
  width: auto;
  margin: 0;
  padding: .2rem .65rem;
  border-radius: 6px;
  font-size: .78rem;
  box-shadow: none;
}
.md-modes button.active {
  --background-color: var(--card-sectionning-background-color);
  --color: var(--h1-color, var(--color));
  font-weight: 600;
}
.editor-panes {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 60vh;
  border: 1px solid var(--muted-border-color);
  border-radius: 0 0 12px 12px;
  background: var(--card-background-color);
  overflow: hidden;
}
.editor-shell[data-mode="write"] .editor-panes,
.editor-shell[data-mode="preview"] .editor-panes {
  grid-template-columns: 1fr;
}
.editor-shell[data-mode="write"] .editor-preview,
.editor-shell[data-mode="preview"] #editor {
  display: none;
}
#editor {
  margin: 0;
  min-height: 60vh;
  height: 100%;
  padding: 1.25rem 1.5rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9rem;
  line-height: 1.7;
  resize: none;
}
#editor:focus {
  box-shadow: none;
}
.editor-shell[data-mode="write"] #editor {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}
.editor-preview {
  overflow: auto;
  padding: 1.25rem 1.75rem;
  border-left: 1px solid var(--muted-border-color);
}
.editor-shell[data-mode="preview"] .editor-preview {
  border-left: 0;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}
.editor-help {
  margin: .5rem 0 0;
  color: var(--muted-color);
}
@media (max-width: 991px) {
  .editor-panes {
    grid-template-columns: 1fr;
  }
  .editor-shell[data-mode="split"] .editor-preview {
    border-left: 0;
    border-top: 1px solid var(--muted-border-color);
  }
  .md-label {
    display: none;
  }
}

/*** compact cards (override Pico's roomy article spacing) ***/
.settings-card {
  --block-spacing-vertical: 1.25rem;
  --block-spacing-horizontal: 1.5rem;
}
.settings-card > header {
  margin-bottom: 1.1rem;
}
.settings-card form {
  margin-bottom: 0;
}
.settings-card .inline-fields > * {
  margin-bottom: 0;
}
/* ---------- nested docs ---------- */
.doc-header-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.doc-children {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--muted-border-color);
}
.doc-children-heading {
  margin: 0 0 .6rem;
  color: var(--muted-color);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.doc-children ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: .5rem;
  margin: 0;
  padding: 0;
}
.doc-children li {
  list-style: none;
  margin: 0;
}
.doc-children a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .8rem;
  border: 1px solid var(--muted-border-color);
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
}
.doc-children a:hover {
  border-color: var(--primary);
  color: var(--ink-strong);
}
.doc-children a .icon {
  flex-shrink: 0;
  color: var(--muted-color);
}
.doc-children a span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Theme toggle in the client rail */
.client-rail button.rail-item {
  margin: 0;
  padding: 0;
  border: 0;
  cursor: pointer;
}
.client-rail .rail-theme {
  --rail-theme-size: 36px;
  width: var(--rail-theme-size);
  height: var(--rail-theme-size);
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
}
.client-rail .rail-theme:hover {
  background: var(--card-background-color);
  color: var(--ink-strong);
}
.client-rail .rail-theme:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.client-rail .rail-theme .icon {
  transition: transform .25s ease;
}
[data-theme="dark"] .client-rail .rail-theme .icon {
  transform: rotate(180deg);
}

/* ---------- account menu (rail avatar, or top bar on pages without a rail) ---------- */
.account-menu {
  position: relative;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.account-menu--rail {
  margin-top: .35rem;
}
.account-menu > summary.account-trigger {
  display: block;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  box-shadow: none;
  line-height: 0;
  list-style: none;
  cursor: pointer;
}
.account-menu > summary::-webkit-details-marker,
.account-menu > summary::after {
  display: none !important;
}
.account-menu > summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.account-menu--rail .account-trigger .avatar {
  width: 38px;
  height: 38px;
}
.account-menu[open] .account-trigger .avatar {
  box-shadow: 0 0 0 3px var(--muted-border-color);
}
.account-popover {
  position: absolute;
  z-index: 1100;
  min-width: 230px;
  padding: .4rem;
  border: 1px solid var(--muted-border-color);
  border-radius: 12px;
  background: var(--card-background-color);
  box-shadow: 0 12px 32px rgba(16, 24, 32, .16);
  line-height: 1.3;
}
.account-menu--rail .account-popover {
  left: calc(100% + 12px);
  bottom: 0;
}
.account-menu--top .account-popover {
  right: 0;
  top: calc(100% + 8px);
}
.account-head {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .55rem .65rem;
  margin-bottom: .3rem;
  border-bottom: 1px solid var(--muted-border-color);
}
.account-head strong {
  display: block;
  color: var(--ink-strong);
  font-size: .9rem;
}
.account-head small {
  color: var(--muted-color);
  font-size: .75rem;
}
.account-links form {
  margin: 0;
}
.account-popover .account-links :is(a, button).account-link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: .6rem;
  width: 100%;
  margin: 0;
  padding: .5rem .55rem;
  border: 0;
  border-radius: 8px;
  background: none;
  box-shadow: none;
  color: var(--ink);
  font-size: .88rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.account-popover .account-links .account-link .icon {
  color: var(--muted-color);
}
.account-popover .account-links :is(a, button).account-link:is(:hover, :focus-visible) {
  background: var(--card-sectionning-background-color);
  color: var(--ink-strong);
}
