/* Guide layout: flush TOC + edge tab + centered body (M1) */

:root {
  --guide-nav-offset: 4.5rem;
  --guide-toc-width-default: 36rem;
  --guide-toc-width: var(--guide-toc-width-user, var(--guide-toc-width-default));
  --guide-edge-width: 1.75rem;
  --guide-body-max: 1080px;
  --guide-accent: #6d28d9;
  --guide-accent-soft: #ede9fe;
  --guide-line: #e5e7eb;
}

.guide-layout {
  min-height: 100vh;
  background: #f9fafb;
  padding-top: var(--guide-nav-offset);
}

.guide-layout-row {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - var(--guide-nav-offset));
}

/* ── TOC ─────────────────────────────────────────── */
.guide-toc {
  width: var(--guide-toc-width);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--guide-line);
  position: sticky;
  top: var(--guide-nav-offset);
  height: calc(100vh - var(--guide-nav-offset));
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  z-index: 20;
}

.guide-toc-closed .guide-toc {
  width: 0;
  border-right: none;
  overflow: hidden;
}

.guide-toc-inner {
  min-width: var(--guide-toc-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem 1.25rem;
  overflow: hidden;
}

.guide-toc-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.guide-toc-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 0.75rem;
  padding: 0 0.25rem;
}

/* ── Edge rail / tab ─────────────────────────────── */
.guide-edge-rail {
  flex-shrink: 0;
  width: var(--guide-edge-width);
  position: sticky;
  top: var(--guide-nav-offset);
  height: calc(100vh - var(--guide-nav-offset));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
}

.guide-edge-tab {
  width: var(--guide-edge-width);
  height: 4.5rem;
  border: 1px solid var(--guide-line);
  border-left: none;
  border-radius: 0 0.5rem 0.5rem 0;
  background: #fff;
  color: var(--guide-accent);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  box-shadow: 2px 0 10px rgba(15, 23, 42, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-edge-tab:hover {
  background: var(--guide-accent-soft);
}

.guide-layout:not(.guide-toc-closed) .guide-edge-tab {
  border-left: 1px solid var(--guide-line);
  border-right: none;
  border-radius: 0.5rem 0 0 0.5rem;
  margin-left: -1px;
  box-shadow: -2px 0 10px rgba(15, 23, 42, 0.06);
}

/* ── Main column ─────────────────────────────────── */
.guide-main {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.guide-main-inner {
  width: 100%;
  max-width: var(--guide-body-max);
}

/* ── Tables (guide + API docs body) ──────────────── */
.guide-body table,
.doc-body table {
  width: auto !important;
  max-width: 100% !important;
  table-layout: auto !important;
  border-collapse: collapse;
}

.guide-body th,
.guide-body td,
.doc-body th,
.doc-body td {
  width: auto;
  vertical-align: top;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* ── Edge tab doubles as the resize grip (desktop) ── */
.guide-edge-tab {
  touch-action: none;
}

@media (min-width: 1024px) {
  .guide-layout:not(.guide-toc-closed) .guide-edge-tab {
    cursor: col-resize;
  }
}

.guide-edge-tab.is-dragging {
  background: var(--guide-accent-soft);
}

/* Disable text selection page-wide while dragging */
body.guide-toc-resizing,
body.guide-toc-resizing * {
  user-select: none !important;
  cursor: col-resize !important;
}

.guide-toc.is-resizing {
  transition: none;
}

/* ── Mobile: start closed via JS; keep edge tab ──── */
@media (max-width: 1023px) {
  .guide-toc {
    position: fixed;
    left: 0;
    top: var(--guide-nav-offset);
    z-index: 30;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
  }

  .guide-layout:not(.guide-toc-closed) .guide-toc {
    width: min(var(--guide-toc-width), 85vw);
  }

  .guide-edge-rail {
    position: fixed;
    left: 0;
    top: var(--guide-nav-offset);
    z-index: 31;
  }

  .guide-layout:not(.guide-toc-closed) .guide-edge-rail {
    left: min(var(--guide-toc-width), 85vw);
  }
}
