/* App shell: sidebar + main area. The sidebar can fold to an icon rail
   (data-sidebar="rail" on <html>), hides in review (body.focus) and becomes a
   drawer on narrow windows. */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh;
  transition: grid-template-columns var(--dur-3) var(--ease-out); }
html[data-sidebar="rail"] .app { grid-template-columns: 64px minmax(0, 1fr); }
body.focus .app { grid-template-columns: 0 minmax(0, 1fr); }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 0.25rem;
  padding: 0.9rem 0.7rem 0.7rem; overflow: hidden; background: var(--surface); border-right: 1px solid var(--line);
  view-transition-name: sidebar; transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-2); }
body.focus .sidebar { transform: translateX(-100%); opacity: 0; pointer-events: none; }

.brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.2rem 0.45rem 0.9rem; text-decoration: none;
  color: var(--fg); }
.brand:hover { color: var(--fg); }
.brand .mark { width: 28px; height: 28px; flex: none; border-radius: 6.5px;
  box-shadow: 0 2px 8px oklch(0.25 0.06 285 / 0.3); transition: transform var(--dur-3) var(--spring-bouncy); }
.brand:hover .mark { transform: rotate(-6deg) scale(1.06); }
.wordmark { font: 650 1.12rem/1 var(--font-read); letter-spacing: 0.08em; white-space: nowrap; }

.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-nav a, .side-foot a, .side-foot button.side-item {
  position: relative; display: flex; align-items: center; gap: 0.7rem; min-height: 2.1rem; padding: 0.3rem 0.6rem;
  border: 0; border-radius: var(--r-sm); background: none; color: var(--fg-soft); text-decoration: none;
  font: 500 var(--text-sm)/1.2 var(--font-ui); white-space: nowrap; cursor: pointer;
  transition: background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out); }
.side-nav a:hover, .side-foot a:hover, .side-foot button.side-item:hover { background: var(--hover); color: var(--fg); }
.side-nav a[aria-current="page"], .side-foot a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.side-nav a[aria-current="page"]::before { content: ""; position: absolute; left: -0.7rem; top: 0.45rem; bottom: 0.45rem;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.side-nav .icon, .side-foot .icon { width: 1.05rem; height: 1.05rem; }
.side-nav .count { margin-left: auto; }
.side-nav .count.due { padding: 0 0.4rem; border-radius: var(--r-pill); background: var(--accent-soft); }

.side-topics { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 1rem; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0.3rem 0.35rem 0.6rem; }
.side-head a { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 5px; color: var(--faint); }
.side-head a:hover { background: var(--hover); color: var(--fg); }
.tree { list-style: none; margin: 0; padding: 0; overflow-y: auto; scrollbar-width: thin; }
.tree ul { list-style: none; margin: 0; padding: 0 0 0 0.85rem; }
.tree summary { list-style: none; }
.tree summary::-webkit-details-marker { display: none; }
.tree-row { position: relative; display: flex; align-items: center; gap: 0.15rem; border-radius: var(--r-sm); }
.tree-row:hover, .tree-row:focus-within { background: var(--hover); }
.tree-twist { display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; flex: none; color: var(--faint);
  cursor: pointer; border-radius: 4px; }
.tree-twist .icon { width: 0.8rem; height: 0.8rem; transition: transform var(--dur-2) var(--ease-out); }
details[open] > summary .tree-twist .icon { transform: rotate(90deg); }
.tree-twist.leaf { visibility: hidden; }
.tree-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.55rem; padding: 0.32rem 0.3rem;
  color: var(--fg-soft); text-decoration: none; font-size: var(--text-sm); }
.tree-link:hover { color: var(--fg); }
.tree-link[aria-current="page"] { color: var(--fg); font-weight: 600; }
.tree-link .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-link .count { margin-left: auto; padding-right: 0.25rem; }
.tree-acts { display: none; gap: 1px; padding-right: 0.2rem; }
.tree-row:hover .tree-acts, .tree-row:focus-within .tree-acts { display: flex; }
.tree-row:hover .tree-link .count, .tree-row:focus-within .tree-link .count { display: none; }
.tree-acts a { display: inline-grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: 5px; color: var(--muted); }
.tree-acts a:hover { background: var(--hover); color: var(--accent-text); }
.tree-acts .icon { width: 0.85rem; height: 0.85rem; }
.tree-empty { padding: 0.3rem 0.6rem; font-size: var(--text-xs); color: var(--faint); }
details.tree-node > ul { animation: fade-in var(--dur-2) var(--ease-out); }

.side-foot { display: flex; flex-direction: column; gap: 2px; padding-top: 0.6rem; border-top: 1px solid var(--line); }
.side-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; padding: 0.25rem 0.1rem 0 0.25rem; }
.theme-switch { --n: 3; }
.theme-switch button { padding: 0.2rem 0.5rem; }
.theme-switch .icon { width: 0.95rem; height: 0.95rem; }
.rail-toggle { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--faint); cursor: pointer; }
.rail-toggle:hover { background: var(--hover); color: var(--fg); }

/* The icon rail */
html[data-sidebar="rail"] .sidebar { padding-inline: 0.55rem; }
html[data-sidebar="rail"] .wordmark,
html[data-sidebar="rail"] .side-nav span,
html[data-sidebar="rail"] .side-foot span,
html[data-sidebar="rail"] .side-topics,
html[data-sidebar="rail"] .theme-switch { display: none; }
html[data-sidebar="rail"] .brand { justify-content: center; padding-inline: 0; }
html[data-sidebar="rail"] .side-nav a, html[data-sidebar="rail"] .side-foot a { justify-content: center; padding-inline: 0; }
html[data-sidebar="rail"] .side-nav .count.due { position: absolute; top: 1px; right: 4px; min-width: 1rem; padding: 0 0.25rem;
  font-size: 0.6rem; text-align: center; background: var(--accent); color: var(--accent-fg); }
html[data-sidebar="rail"] .side-foot-row { justify-content: center; }
html[data-sidebar="rail"] .side-topics + .side-foot { margin-top: auto; }
html[data-sidebar="rail"] .rail-toggle .icon { transform: scaleX(-1); }

/* Main area */
.main { min-width: 0; }
.page { padding: 2rem clamp(1.25rem, 3vw, 3rem) 4rem; animation: rise-in var(--dur-3) var(--ease-out); }
.page.narrow { max-width: 58rem; margin-inline: auto; }
.page.medium { max-width: 80rem; margin-inline: auto; }
.page.full { padding-bottom: 1.25rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem 1rem;
  margin-bottom: 1.5rem; }
.page-head h1 { font-size: var(--text-2xl); }
.page-head .sub { margin: 0.35rem 0 0; color: var(--muted); }
.page-head .tools { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 0.35rem; margin: 0 0 0.5rem; font-size: var(--text-sm); color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--fg); }

.drawer-toggle { display: none; }
.scrim { display: none; }

@media (max-width: 760px) {
  .app, html[data-sidebar="rail"] .app, body.focus .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: min(80vw, 280px); transform: translateX(-100%);
    box-shadow: var(--shadow-3); }
  html[data-sidebar] body.drawer-open .sidebar { transform: none; }
  html[data-sidebar="rail"] .wordmark, html[data-sidebar="rail"] .side-nav span, html[data-sidebar="rail"] .side-foot span,
  html[data-sidebar="rail"] .theme-switch { display: revert; }
  html[data-sidebar="rail"] .side-topics { display: flex; }
  .rail-toggle { display: none; }
  .drawer-toggle { display: inline-grid; place-items: center; position: fixed; z-index: 40; top: 0.7rem; left: 0.7rem;
    width: 2.25rem; height: 2.25rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--glass);
    backdrop-filter: blur(12px); color: var(--fg); cursor: pointer; }
  body.focus .drawer-toggle { display: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: oklch(0 0 0 / 0.35);
    animation: fade-in var(--dur-2); }
  .page { padding-top: 3.5rem; }
}

/* Signing in, joining, a new password (bare.html): no sidebar, one card in the middle */
body.bare .app { grid-template-columns: minmax(0, 1fr); }
.sign-in { width: min(100%, 24rem); margin: 12vh auto 3rem; padding: 0 1rem; animation: rise-in var(--dur-3) var(--ease-out); }
.sign-in .brand { justify-content: center; margin: 0 0 1rem; }
.sign-in-form { display: grid; gap: 1rem; }
.sign-in-form h1 { margin: 0; font-size: var(--text-xl); }
.sign-in-form label { display: grid; gap: 0.35rem; font: 500 var(--text-sm)/1.2 var(--font-ui); }
.sign-in-form p { margin: 0; }
.sign-in > .muted { margin-top: 1rem; text-align: center; font-size: var(--text-sm); }

/* The front page online, before signing in (welcome.html) */
.front-page { width: min(100%, 68rem); margin: 0 auto; padding: 1.25rem clamp(1rem, 4vw, 2.5rem) 3rem;
  animation: rise-in var(--dur-3) var(--ease-out); }
.front-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.front-top .brand { padding: 0; }
.front-hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center;
  gap: clamp(2rem, 5vw, 4rem); margin: clamp(2.5rem, 9vh, 6rem) 0 clamp(2.5rem, 7vh, 4.5rem); }
.front-copy h1 { margin: 0; font: 600 clamp(2.1rem, 5vw, 3.2rem)/1.08 var(--font-read); letter-spacing: -0.015em; }
.front-copy .lede { margin: 1.1rem 0 1.6rem; max-width: 34rem; font-size: 1.12rem; color: var(--fg-soft); }
.front-copy .muted { margin-top: 0.9rem; font-size: var(--text-sm); }
.front-card { margin: 0; }
.front-card .reveal-hint { margin-top: 1.5rem; }
.front-card figcaption { margin-top: 0.75rem; text-align: center; font-size: var(--text-xs); }
.front-points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.front-points > div { padding: 1.1rem 1.2rem; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); }
.front-points h2 { margin: 0 0 0.4rem; font-size: var(--text-md); }
.front-points p { margin: 0; font-size: var(--text-sm); color: var(--fg-soft); }
.front-foot { margin-top: 2.5rem; text-align: center; font-size: var(--text-sm); color: var(--muted); }
.front-foot p { margin: 0.3rem 0; }
.front-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
@media (max-width: 760px) {
  .front-hero, .front-points { grid-template-columns: minmax(0, 1fr); }
}

/* The apps to download (apps.html), alone like the front page or beside the sidebar */
.apps-page .front-top { margin-bottom: clamp(2rem, 6vh, 3.5rem); }
.apps-page.front-page { width: min(100%, 52rem); }
.app-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.app-choice { display: grid; gap: 0.6rem; align-content: start; }
.app-choice.yours { order: -1; border-color: var(--accent-line); box-shadow: var(--shadow-1); }
.app-choice h2, .app-choice > p { margin: 0; }
.app-choice .button { justify-self: start; }
.checksum summary { cursor: pointer; font-size: var(--text-xs); color: var(--muted); }
.checksum p { margin: 0.4rem 0 0.2rem; font-size: var(--text-xs); }
.checksum code { display: block; font: var(--text-xs)/1.4 var(--font-mono); overflow-wrap: anywhere; color: var(--fg-soft); }
.apps-version { margin: 0.6rem 0 1.5rem; font-size: var(--text-xs); }
.apps-help { margin-bottom: 1rem; }
.apps-help ol { margin: 0 0 0.8rem; padding-left: 1.3rem; display: grid; gap: 0.45rem; }
.apps-help > p:last-child { margin-bottom: 0; }

.password-change { display: grid; gap: 0.75rem; max-width: 24rem; }
.password-change label { display: grid; gap: 0.35rem; font: 500 var(--text-sm)/1.2 var(--font-ui); }

/* Admin page (server mode) */
.admin-block { display: grid; gap: 0.9rem; margin-top: 1rem; }
.admin-block h2, .new-link h2 { margin: 0; }
.invite-switch, .link-list li, .person { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.invite-switch span { flex: 1 1 16rem; }
.link-list, .people { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.link-list li { justify-content: space-between; padding: 0.4rem 0; border-top: 1px solid var(--line); }
.person { justify-content: space-between; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.person .who { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; }
.person .facts { flex-basis: 100%; font-size: var(--text-sm); }
.person.is-disabled .who b { color: var(--faint); }
.person .acts { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.new-link { display: grid; gap: 0.6rem; border-color: var(--accent); }
.new-link pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.storage-form { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem; }
.storage-form label { display: grid; gap: 0.3rem; font: 500 var(--text-sm)/1.2 var(--font-ui); }
.mb-field { display: inline-flex; align-items: center; gap: 0.4rem; }
.mb-field input { width: 7rem; }
.storage-use meter { width: min(100%, 24rem); height: 0.6rem; }
.tz-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.tz-row select { flex: 1 1 14rem; max-width: 24rem; }
