/* The app shell: navigation shelf · writing column · sidebar. On phones the navigation becomes a
   drawer and the sidebar a full-screen sheet. */

.shell {
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100dvh;
  font-size: var(--t-ui);
}
.shell.with-side { grid-template-columns: var(--nav-width) minmax(0, 1fr) var(--side-width); }
.shell.test { grid-template-rows: auto minmax(0, 1fr); }
.shell > .topbar { display: none; }

.testbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 5px 16px;
  background: var(--caution-wash);
  color: var(--caution);
  font-size: var(--t-sm);
  border-bottom: 1px solid var(--rule);
}
.testbar strong { font-weight: 700; letter-spacing: .02em; }
.testbar button { font-weight: 600; border: 1px solid currentColor; border-radius: 5px; padding: 0 8px; }

/* navigation */
.nav {
  background: var(--shelf);
  border-right: 1px solid var(--rule);
  padding: 16px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
  overflow-y: auto;
}
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 9px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink-3);
  font-size: var(--t-sm);
  text-align: left;
}
.search .icon { width: 13px; height: 13px; }
.search kbd { padding: 0 4px; }
.search span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search:hover { border-color: var(--ink-3); }
.nav-list { display: flex; flex-direction: column; gap: 1px; }
.nav-list a { display: block; padding: 5px 8px; border-radius: 6px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-list a:hover { color: var(--ink); background: rgb(127 127 127 / .08); }
.nav-list a.active, .settings-link.active { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--rule); }
.nav-row { display: flex; align-items: center; gap: 2px; }
.nav-row a { flex: 1; min-width: 0; }
.nav-label { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; font-weight: 600; color: var(--ink-3); padding: 0 8px 5px; }
.nav-section .empty-hint { padding: 0 8px; }
.nav-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 8px; font-size: var(--t-xs); color: var(--ink-3); }
.settings-link { padding: 2px 6px; border-radius: 5px; }
.settings-link:hover { color: var(--ink); }
.status { font-size: var(--t-xs); color: var(--ink-3); text-align: left; cursor: default; }
.status::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.status.saving { color: var(--ink-2); }
.status.offline, .status.conflict { color: var(--caution); cursor: pointer; }

/* main column */
.main { overflow-y: auto; overflow-x: hidden; padding: 48px 56px 120px; position: relative; min-width: 0; outline: none; }
.column { max-width: var(--column); margin-inline: auto; position: relative; }
.main.view-graph { padding: 0; overflow: hidden; }
.graph-column { height: 100%; }

/* sidebar */
.side {
  background: var(--shelf);
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.side-tools { display: flex; justify-content: space-between; align-items: center; font-size: var(--t-xs); color: var(--ink-3); padding: 12px 16px 6px; }
.side-tools .text-btn { font-size: var(--t-xs); color: var(--ink-3); font-weight: 400; }
.side-cards { overflow-y: auto; padding: 4px 12px 40px; display: flex; flex-direction: column; gap: 10px; }
.side-item { background: var(--paper); border: 1px solid var(--rule); border-radius: 9px; padding: 10px 14px 12px; }
.side-item header { display: flex; align-items: center; gap: 8px; }
.side-item h4 { flex: 1; min-width: 0; font-family: var(--font-note); font-size: 1.08rem; font-weight: 600; line-height: 1.3; }
.side-item h4 a:hover { color: var(--thread); }
.side-item .count { font-size: var(--t-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.card-kind { color: var(--ink-3); font-family: var(--font-ui); font-weight: 400; font-size: var(--t-sm); }
.side-btn { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px; color: var(--ink-3); flex: none; }
.side-btn:hover { color: var(--ink); background: var(--shelf); }
.side-item .page { margin-top: 6px; }
.side-item .row { font-size: .95rem; }
.side-item .refs { margin-top: 22px; }
.side-item .graph-wrap { height: 300px; margin-top: 8px; border-radius: 6px; }

.scrim { display: none; }

/* phones and small tablets */
@media (max-width: 760px) {
  .shell, .shell.with-side { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .shell.test { grid-template-rows: auto auto minmax(0, 1fr); }
  .shell > .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(6px, env(safe-area-inset-top)) 12px 6px;
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
  }
  .topbar .title { font-weight: 600; color: var(--ink); }
  .testbar { font-size: var(--t-xs); padding: 3px 12px; }
  .testbar span { display: none; }
  .nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 85vw);
    z-index: 30;
    transform: translateX(-102%);
    transition: transform .2s ease;
    padding-top: max(16px, env(safe-area-inset-top));
  }
  .shell.nav-open .nav { transform: none; box-shadow: var(--shadow-float); }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 25; }
  .main { padding: 20px 16px 140px 12px; }
  .side { position: fixed; inset: 0; z-index: 20; border-left: 0; padding-top: env(safe-area-inset-top); }
  .side-tools { padding: 14px 16px 8px; font-size: var(--t-sm); }
}
