/* ============================================================== */
/*  Cerulean, Main Viewer (Document Review) overrides             */
/*                                                                  */
/*  Extends kit.css. Layout now includes a far-left view switcher  */
/*  rail outside the DOCUMENTS panel; the right rail toggles       */
/*  between PAGES (default) and DOCUMENT INFO.                     */
/* ============================================================== */

/* ---- Workspace shell ----------------------------------------- */
html, body { margin: 0; padding: 0; min-height: 100%; background: var(--bg); }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.shell {
  position: relative;
  width: 1600px;
  min-height: 980px;
  margin: 0 auto;
  background: var(--bg);
  display: grid;
  grid-template-columns: 64px 1fr;
  grid-template-rows: 1fr;
}

/* Override the kit's .workspace to drop its outer padding on the
   left edge so the view switcher meets it cleanly. */
.shell .workspace {
  width: auto;
  margin: 0;
  padding: 32px 64px 40px 40px;
  grid-template-columns: 380px 1fr 180px;
  column-gap: 48px;
  min-height: 980px;
}

/* The right rail panel can be wider in Info mode, we use a CSS
   variable so the grid expands smoothly between states. */
.shell.is-info .workspace {
  grid-template-columns: 380px 1fr 280px;
}

/* Header column reach, match the new right column. */
.shell .header-bar {
  grid-template-columns: 380px minmax(620px, 1fr) 120px 32px;
}
/* Snippet row spans cols 2-3 of the workspace grid (centre + right);
   pad the right side enough to clear the rail in either state. */
.shell.is-pages .snippet-row { padding-right: 228px; }
.shell.is-info  .snippet-row { padding-right: 328px; }

/* ============================================================== */
/*  Document viewer, multi-page stack + sticky toolbar             */
/* ============================================================== */

/* Bound the centre pane so the viewer-stage can scroll. */
.shell .pane-center {
  min-height: 0;
  align-self: stretch;
  align-items: stretch;
  padding-top: 24px;
  padding-bottom: 16px;
}

.shell .viewer-stage {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 220px);
  /* When the workspace is taller than the viewport, anchor to a fixed
     height that still allows scrolling within the column. */
  min-height: 600px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0 0 12px;
  /* Quiet, custom scrollbar, fits the system's restraint. */
  scrollbar-width: thin;
  scrollbar-color: var(--ink-30) transparent;
}
.shell .viewer-stage::-webkit-scrollbar { width: 8px; }
.shell .viewer-stage::-webkit-scrollbar-track { background: transparent; }
.shell .viewer-stage::-webkit-scrollbar-thumb {
  background: var(--ink-30);
  border-radius: 4px;
}

.pages-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
  padding-bottom: 72px; /* leave room behind the sticky toolbar */
}

/* The kit's .doc-page is the right A4 sheet, just ensure it doesn't
   collapse in a flex container. */
.shell .doc-page {
  flex-shrink: 0;
}

/* Page foot, quiet "N / total" counter inside each sheet. */
.doc-page .page-foot {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
}
.doc-page .page-foot .mono {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* Running head for continuation pages, quiet centred line. */
.doc-page .doc-running-head {
  font-family: var(--font-serif);
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hairline);
}

/* Continuation body, abstract paragraph rules, not faked legal text.
   Reads as "body content continues below" without inventing it. */
.doc-body.continuation {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.continuation-block {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.continuation-block .rule {
  display: block;
  height: 6px;
  background: rgba(26, 31, 43, 0.06);
  border-radius: 1px;
  width: 100%;
}
.continuation-block .rule.short { width: 60%; }
.continuation-block .rule.mid   { width: 80%; }

/* Sticky toolbar at the bottom of the scrolling viewer column. */
.toolbar-dock {
  position: sticky;
  bottom: 12px;
  width: 100%;
  display: flex;
  justify-content: center;
  pointer-events: none;
  margin-top: -56px; /* float over the page-bottom area */
  z-index: 5;
}
.toolbar-dock > .toolbar {
  pointer-events: auto;
}

/* ============================================================== */
/*  View Switcher (far-left icon rail)                              */
/* ============================================================== */

.view-switcher {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 64px;
  height: 100%;
  padding: 28px 0 24px;
  background: var(--bg);
  /* Hairline divider on the right edge, very faint, matches the
     "alignment does the work" rule but the rail is OUTSIDE the
     three-zone workspace, so a single hairline is permitted to
     separate the navigation chrome from the content. */
  border-right: 1px solid var(--hairline);
}

.view-switcher .vs-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  margin-bottom: 28px;
}
.view-switcher .vs-dot {
  width: 10px;
  height: 10px;
  background: var(--accent);
  display: inline-block;
}

.view-switcher .vs-group {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.view-switcher .vs-spacer { flex: 1; min-height: 24px; }

.view-switcher .vs-group-settings {
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}

.view-switcher .vs-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  cursor: pointer;
  color: var(--ink-70);
  transition: color var(--dur-state) var(--ease);
}
.view-switcher .vs-item:hover { color: var(--ink); }
.view-switcher .vs-item.is-active { color: var(--accent); }

.view-switcher .vs-indicator {
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: transparent;
  transition: background var(--dur-state) var(--ease);
}
.view-switcher .vs-item.is-active .vs-indicator {
  background: var(--accent);
}

.view-switcher .vs-icon {
  display: inline-flex;
}

/* Hover tooltip, small caption beside the rail. */
.view-switcher .vs-tooltip {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  padding: 4px 8px;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-state) var(--ease),
              transform var(--dur-state) var(--ease);
  z-index: 20;
}
.view-switcher .vs-item:hover .vs-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ============================================================== */
/*  Tree header, Documents label + Upload / New folder actions   */
/* ============================================================== */

.tree-wrap .tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 4px;
  margin-bottom: 22px;
}
.tree-wrap .tree-header .panel-label {
  margin-bottom: 0;
  padding-left: 8px;
}
.tree-wrap .tree-actions {
  display: flex;
  gap: 2px;
}
.tree-wrap .tree-action {
  width: 24px;
  height: 24px;
  background: transparent;
  border: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  border-radius: 3px;
  transition: color var(--dur-state) var(--ease),
              background var(--dur-state) var(--ease);
}
.tree-wrap .tree-action:hover {
  color: var(--ink);
  background: #FFFFFF;
}
.tree-wrap .tree-action:focus { outline: none; }

/* Tree row, serials are displayed without their bundle prefix so we
   can tighten the serial column and give the title more room. */
.shell .tree-row {
  grid-template-columns: 16px 18px 104px 1fr;
  gap: 10px;
}

/* ============================================================== */
/*  Right rail, header with toggle, PAGES + DOCUMENT INFO          */
/* ============================================================== */

.right-rail { width: 100%; }
.right-rail .rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.right-rail.is-pages .rail-header {
  justify-content: center;
  position: relative;
}
.right-rail .rail-label {
  margin-bottom: 0;
  padding-left: 0;
}
.right-rail .rail-toggle {
  width: 24px;
  height: 24px;
  background: transparent;
  border: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  border-radius: 3px;
  transition: color var(--dur-state) var(--ease),
              background var(--dur-state) var(--ease);
}
.right-rail .rail-toggle:hover {
  color: var(--ink);
  background: #FFFFFF;
}
.right-rail .rail-toggle:focus { outline: none; }

.right-rail.is-pages .rail-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* PAGES rail spacing, tighter when contained in right-rail */
.right-rail .rail {
  align-items: center;
}
/* The PAGES rail scrolls when a document has many pages. */
.right-rail.is-pages .rail {
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-30) transparent;
}
.right-rail.is-pages .rail::-webkit-scrollbar { width: 6px; }
.right-rail.is-pages .rail::-webkit-scrollbar-thumb {
  background: var(--ink-30);
  border-radius: 3px;
}

/* ---- DOCUMENT INFO panel ------------------------------------ */

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.info-list {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--muted);
  margin: 0;
}

.info-value {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}
.info-value .mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  letter-spacing: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  background: #FFFFFF;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--ink);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.info-notes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}
.info-notes-body {
  font-family: var(--font-serif);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}
.info-notes-placeholder {
  color: var(--muted);
  font-style: italic;
}

.info-empty {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

/* ============================================================== */
/*  Frame jewellery, recolour bracket stroke to a true muted      */
/* ============================================================== */

/* Brackets stay at the FRAME (workspace) corners, not the shell, */
/* the kit's positioning targets .workspace already.               */

/* Katakana label, anchor to bottom of the right edge (above the
   lower-right registration bracket) instead of vertically centred. */
.shell .katakana {
  top: auto;
  bottom: 48px;
  transform: none;
}

/* ============================================================== */
/*  Settings screen (Settings destination in the view switcher)    */
/* ============================================================== */

/* When the workspace is in settings mode, it owns its own grid.
   We use a body-class hook so the workspace doesn't need a re-skin. */
.shell.is-settings .workspace {
  grid-template-columns: 280px minmax(520px, 880px) 220px;
  grid-template-rows: auto 1fr;
  column-gap: 64px;
  padding: 40px 64px 48px 56px;
}

.settings-screen {
  display: contents;
}

.settings-head {
  grid-column: 1 / -1;
  grid-row: 1;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.settings-crumb-sep {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--muted);
}
.settings-crumb-here {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink);
}
.settings-h1 {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.settings-nav {
  grid-column: 1;
  grid-row: 2;
}
.settings-nav .panel-label {
  margin-bottom: 18px;
  padding-left: 8px;
}
.settings-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.settings-nav-row {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: center;
  height: 32px;
  padding: 0 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--dur-state) var(--ease);
  border-radius: 2px;
}
.settings-nav-row:hover { background: #FFFFFF; }
.settings-nav-row .gly { color: var(--muted); display: inline-flex; }
.settings-nav-row.is-active { color: var(--accent); }
.settings-nav-row.is-active .gly { color: var(--accent); }
.settings-nav-row.is-active::before {
  content: '';
  position: absolute;
  left: -8px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--accent);
}

.settings-sheet {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--elev-page);
  padding: 56px 64px 56px;
  align-self: start;
  min-height: 600px;
}
.settings-sheet .ser-tag {
  position: absolute;
  top: 14px; right: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.settings-section-title {
  margin: 0 0 32px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: -0.005em;
}

.settings-side {
  grid-column: 3;
  grid-row: 2;
  align-self: start;
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-side-label { margin-bottom: 6px; padding-left: 0; }
.settings-side-name {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.settings-side-meta {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.settings-side-sep {
  height: 1px;
  background: var(--hairline);
  margin: 20px 0;
}
.settings-side-build {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  letter-spacing: 0;
}

/* ---- Settings rows (inside the sheet) ----------------------- */
.settings-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: flex-start;
  padding: 18px 0;
  border-bottom: 1px solid var(--hairline);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 460px;
}
.settings-row-label {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
}
.settings-row-desc {
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}
.settings-row-control {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.settings-static {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink);
  text-align: right;
}
.settings-static.is-mono { font-family: var(--font-mono); font-size: 12px; }
.settings-static.is-muted { color: var(--muted); }

/* Toggle */
.settings-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.settings-toggle:focus { outline: none; }
.settings-toggle .settings-toggle-track {
  position: absolute;
  inset: 0;
  background: #FFFFFF;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  transition: background var(--dur-state) var(--ease),
              border-color var(--dur-state) var(--ease);
}
.settings-toggle .settings-toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 12px; height: 12px;
  background: var(--ink-70);
  border-radius: 2px;
  transition: transform var(--dur-state) var(--ease),
              background var(--dur-state) var(--ease);
}
.settings-toggle.is-on .settings-toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}
.settings-toggle.is-on .settings-toggle-thumb {
  background: #FFFFFF;
  transform: translateX(16px);
}

/* Segment */
.settings-segment {
  display: inline-flex;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #FFFFFF;
}
.settings-segment button {
  min-width: 64px;
  padding: 6px 12px;
  height: 28px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--hairline);
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink-70);
  cursor: pointer;
  transition: color var(--dur-state) var(--ease),
              background var(--dur-state) var(--ease);
}
.settings-segment button:last-child { border-right: 0; }
.settings-segment button:hover { color: var(--ink); }
.settings-segment button.is-active {
  color: var(--accent);
  background: var(--accent-tint);
}
.settings-segment button:focus { outline: none; }

/* Select */
.settings-select {
  position: relative;
  min-width: 220px;
}
.settings-select select {
  width: 100%;
  height: 28px;
  padding: 0 28px 0 10px;
  appearance: none;
  -webkit-appearance: none;
  background: #FFFFFF;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--dur-state) var(--ease);
}
.settings-select select:hover { border-color: var(--ink-30); }
.settings-select select:focus { outline: none; border-color: var(--ink-30); }
.settings-select-chev {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

/* Buttons (ghost) */
.settings-actions {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.btn-ghost {
  height: 28px;
  padding: 0 14px;
  background: #FFFFFF;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--dur-state) var(--ease),
              color var(--dur-state) var(--ease);
}
.btn-ghost:hover { border-color: var(--ink-30); }
.btn-ghost:focus { outline: none; }
.btn-ghost.is-danger { color: var(--ink-70); }
.btn-ghost.is-danger:hover { color: var(--ink); }

/* Shortcuts */
.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}
.shortcuts-group .panel-label { margin-bottom: 12px; padding-left: 0; }
.shortcuts-list {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--hairline);
}
.shortcut-row {
  display: contents;
}
.shortcut-row dt,
.shortcut-row dd {
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-sans);
  font-size: 13px;
}
.shortcut-row dt { color: var(--ink); }
.shortcut-row dd { color: var(--ink); text-align: right; }
.shortcut-row dd.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0;
}

/* ============================================================== */
/*  Tweaks                                                          */
/* ============================================================== */

.tweaks-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 260px;
  background: #FFFFFF;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 24px rgba(26, 31, 43, 0.08);
  z-index: 100;
  font-family: var(--font-sans);
  color: var(--ink);
}
.tweaks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
}
.tweaks-title {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--muted);
}
.tweaks-close {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  width: 20px; height: 20px;
  align-items: center; justify-content: center;
}
.tweaks-close:hover { color: var(--ink); }
.tweaks-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tweak-group { display: flex; flex-direction: column; gap: 8px; }
.tweak-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--muted);
}
.tweak-segment {
  display: flex;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.tweak-segment button {
  flex: 1;
  padding: 6px 8px;
  background: #FFFFFF;
  border: 0;
  border-right: 1px solid var(--hairline);
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--ink-70);
  cursor: pointer;
  transition: color var(--dur-state) var(--ease),
              background var(--dur-state) var(--ease);
}
.tweak-segment button:last-child { border-right: 0; }
.tweak-segment button:hover { color: var(--ink); }
.tweak-segment button.is-active {
  color: var(--accent);
  background: var(--accent-tint);
}
.tweak-segment button:focus { outline: none; }
