/* DentaPlan 2.3 layout shell (VORAAA-88, ADR 0004; flag layout_v23). Every rule is scoped to
 * <html class="l23">, which shell23.js sets only when the flag is on and a user is logged in, so with
 * the flag off nothing here applies. Tier values (rail width, container, panel width, density) are
 * tokens in /design/tokens.css. The phone (< 600) is untouched; the tablet (600–1023) keeps the top
 * bar; from 1024 the side rail replaces it. Concept: docs/design/v2.3-desktop.md. No inline styles. */

.rail { display: none; }
kbd.k { font: 600 11px/1 var(--font-mono); padding: 3px 5px; border-radius: 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--card); color: var(--ink-2); white-space: nowrap; }
.btn-primary kbd.k { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .35); color: inherit; }
html.l23 kbd.k { display: none; } /* shortcut hints only with a mouse from 1024 (below) */

/* skip link: first focus stop, jumps over the rail to the content */
.skip23 { position: fixed; z-index: var(--z-toast); top: var(--sp-2); left: var(--sp-2); transform: translateY(-200%); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-md); background: var(--raised); color: var(--accent-text); font-weight: var(--fw-semi); }
.skip23:focus { transform: none; box-shadow: var(--shadow-lg); } /* no shadow while hidden: it would bleed into the top bar */

/* ============ laptop and wider: side rail instead of the top bar, fluid container ============ */
@media (min-width: 1024px) {
  html.l23 .topbar { display: none; }
  html.l23 body { padding-left: var(--rail-w); }
  html.l23 body.handover-mode { --rail-w: 0px; }
  html.l23 body.handover-mode .rail { display: none; }
  html.l23 main, html.l23 .main { max-width: var(--work-max); padding-top: var(--sp-5); }
  html.l23 body[data-page="read"] main { max-width: var(--read-max); }
  html.l23 .actionbar, html.l23 .flowbar { left: var(--rail-w); }
  html.l23 .actionbar .inner, html.l23 .flowbar .inner { max-width: var(--work-max); }
  html.l23 .toasts { left: calc(50% + var(--rail-w) / 2); }

  html.l23 .rail:not([hidden]) {
    display: flex; flex-direction: column; gap: var(--sp-2); position: fixed; z-index: var(--z-sticky); top: 0; left: 0; bottom: 0; width: var(--rail-w);
    box-sizing: border-box; padding: var(--sp-3) 10px; overflow-y: auto; overflow-x: hidden; background: var(--card); border-right: 1px solid var(--line);
  }
  .rail .rl { display: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rail .ico { width: 20px; height: 20px; flex: none; }
  .rail-brand { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--ink); min-height: 44px; margin-bottom: var(--sp-2); text-decoration: none; }
  .rail-brand:hover { text-decoration: none; }
  .rail-brand .rl b { display: block; font-size: 16px; letter-spacing: -.01em; }
  .rail-brand .rl small { display: block; font-size: var(--fs-xs); color: var(--ink-3); line-height: var(--lh-tight); overflow: hidden; text-overflow: ellipsis; }
  .rail .rail-new { width: 100%; justify-content: center; padding: 0; gap: var(--sp-2); }
  .rail-search { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); width: 100%; min-height: var(--btn-h); padding: 0; border: 1px solid var(--field-border); border-radius: var(--r-md); background: var(--field-bg); color: var(--ink-3); font: inherit; font-size: var(--fs-sm); cursor: pointer; }
  .rail-search:hover { border-color: var(--accent); }
  .rail ul { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: 2px; }
  .rail ul a, .rail ul button { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); width: 100%; min-height: var(--btn-h); padding: 0 12px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--ink-2); font: inherit; font-weight: var(--fw-semi); font-size: var(--fs-sm); text-decoration: none; cursor: pointer; }
  .rail ul a:hover, .rail ul button:hover { background: var(--sunk); text-decoration: none; }
  .rail ul a.on { background: var(--accent-50); color: var(--accent-text); }
  .rail-foot { margin-top: auto; display: grid; justify-items: center; gap: var(--sp-1); padding-top: var(--sp-3); }
  .rail-foot .rail-tool { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); width: 100%; min-height: 36px; padding: 0 12px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--ink-3); font: inherit; font-size: var(--fs-xs); cursor: pointer; }
  .rail-foot .rail-tool:hover { background: var(--sunk); color: var(--ink-2); }
  .rail-foot .avatar { margin-top: var(--sp-1); }
  .rail-me { display: flex; align-items: center; gap: var(--sp-2); width: 100%; justify-content: center; border: 0; background: transparent; padding: 2px; border-radius: var(--r-md); cursor: pointer; color: var(--ink); font: inherit; text-align: left; }
  .rail-me:hover { background: var(--sunk); }
  .rail-me .rl { font-size: var(--fs-sm); font-weight: var(--fw-semi); }
  .rail-me .avatar { margin: 0; }

  /* rail with labels (desktop/wide default, or "Leiste ausklappen") */
  html.rail-wide .rail { padding: var(--sp-4) var(--sp-3); }
  html.rail-wide .rail .rl { display: block; }
  html.rail-wide .rail-brand, html.rail-wide .rail ul a, html.rail-wide .rail ul button, html.rail-wide .rail-foot .rail-tool, html.rail-wide .rail-me { justify-content: flex-start; }
  html.rail-wide .rail .rail-new, html.rail-wide .rail-search { justify-content: flex-start; padding: 0 var(--sp-3); }
  html.rail-wide .rail-foot { justify-items: stretch; }
  .rail .rail-new kbd.k, .rail-search kbd.k, .rail ul kbd.k { margin-left: auto; }

  /* ---------- non-modal side panel (UI.panel): docked right, the content stays usable ---------- */
  html.l23.has-panel body { padding-right: var(--pane-w); }
  html.l23.has-panel .actionbar, html.l23.has-panel .flowbar { right: var(--pane-w); }
  .spanel { position: fixed; z-index: var(--z-sticky); top: 0; right: 0; bottom: 0; width: var(--pane-w); box-sizing: border-box; display: flex; flex-direction: column; background: var(--raised); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(15, 42, 51, .08); animation: panelIn var(--t) var(--ease); }
  .spanel-in { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-4) var(--sp-5) var(--sp-6); }
  .spanel-in > .sheet-head { position: sticky; top: calc(-1 * var(--sp-4)); z-index: 1; margin: calc(-1 * var(--sp-4)) calc(-1 * var(--sp-5)) var(--sp-3); padding: var(--sp-4) var(--sp-5) var(--sp-3); background: var(--raised); border-bottom: 1px solid var(--line); }
  .spanel-in h2:focus { outline: 0; }
  .spanel-in .sheet-foot { position: sticky; bottom: calc(-1 * var(--sp-6)); margin: var(--sp-4) calc(-1 * var(--sp-5)) calc(-1 * var(--sp-6)); padding: var(--sp-3) var(--sp-5); background: var(--raised); border-top: 1px solid var(--line); }
  .spanel-grip { display: none; }
  @keyframes panelIn { from { transform: translateX(16px); opacity: 0; } }
}
/* resizable only on wide screens: a separator on the panel's left edge (drag or ←/→) */
@media (min-width: 1920px) {
  .spanel-grip { display: block; position: absolute; top: 0; bottom: 0; left: -5px; width: 10px; cursor: col-resize; touch-action: none; }
  .spanel-grip::after { content: ""; position: absolute; top: 50%; left: 3px; width: 4px; height: 48px; margin-top: -24px; border-radius: 2px; background: var(--line-2); opacity: 0; transition: opacity var(--t-fast); }
  .spanel:hover .spanel-grip::after, .spanel-grip:focus-visible::after, .spanel.resizing .spanel-grip::after { opacity: 1; background: var(--accent); }
  .spanel-grip:focus-visible { outline: 0; }
  .spanel.resizing { animation: none; user-select: none; }
}
@media (min-width: 1024px) and (pointer: fine) { html.l23:not(.keys-off) kbd.k { display: inline-block; } }
@media (prefers-reduced-motion: reduce) { .spanel { animation: none; } }

/* ---------- global search (side panel; "/" or the rail's search) ---------- */
.s23-field { margin: 0 0 var(--sp-3); }
.s23-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.s23-list a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--sp-3); align-items: center; padding: 8px 10px; border-radius: var(--r-md); color: var(--ink); text-decoration: none; }
.s23-list a:hover, .s23-list a:focus-visible { background: var(--sunk); text-decoration: none; }
.s23-list a.first { background: var(--accent-50); }
.s23-list b { font-weight: var(--fw-semi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s23-list .tiny { grid-column: 1; }
.s23-list .chip { grid-column: 2; grid-row: 1 / span 2; }
.s23-h { margin: var(--sp-4) 0 var(--sp-2); font-size: var(--fs-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: var(--tracking-caps); }

/* ---------- "?" shortcut sheet ---------- */
.keys-sheet { width: min(760px, calc(100vw - 32px)); }
.keys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-4); margin: var(--sp-3) 0; }
.keys-grid h3 { font-size: var(--fs-sm); margin: 0 0 var(--sp-2); }
.keys-grid dl { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--sp-3); margin: 0; font-size: var(--fs-sm); align-items: center; }
.keys-grid dt { white-space: nowrap; color: var(--ink-3); font-size: var(--fs-xs); }
.keys-grid dd { margin: 0; color: var(--ink-2); }
html .keys-sheet kbd.k { display: inline-block; }

/* J/K: the row the keyboard is on */
html.l23 .krow-on { box-shadow: var(--focus); }
html.l23 main:focus { outline: 0; }
html.l23:not(.rail-wide) .rail kbd.k { display: none; } /* icon rail: hints only in the tooltip */
