/* ================================================================
       Documentation pages: /en/docs/ and its Markdown pages
       ================================================================ */

    /* ── Docs layout ─────────────────────────────────────────────── */
    .docs-layout {
      display: grid;
      grid-template-columns: var(--sidebar-width) 1fr;
      min-height: calc(100vh - 60px);
      max-width: var(--max-width);
      margin: 0 auto;
    }

    /* ── Sidebar ─────────────────────────────────────────────────── */
    .docs-sidebar {
      position: sticky;
      top: 60px;
      height: calc(100vh - 60px);
      overflow-y: auto;
      background: var(--surface);
      border-right: 1px solid var(--hairline);
      padding: var(--space-8) var(--space-5);
      scrollbar-width: thin;
      scrollbar-color: var(--hairline-strong) transparent;
    }
    .docs-sidebar::-webkit-scrollbar { width: 4px; }
    .docs-sidebar::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: var(--radius-sm); }

    .sidebar-section {
      margin-bottom: var(--space-8);
    }
    .sidebar-section-title {
      font-family: var(--font-body);
      font-size: 0.62rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--muted);
      margin-bottom: var(--space-3);
      padding-left: var(--space-3);
    }
    .sidebar-links {
      display: flex;
      flex-direction: column;
      gap: 1px;
    }
    .sidebar-links a {
      display: block;
      padding: var(--space-2) var(--space-3);
      font-family: var(--font-body);
      font-size: 0.82rem;
      color: var(--body);
      border-left: 2px solid transparent;
      border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
      transition: color var(--duration-fast) ease, background var(--duration-fast) ease, border-left-color var(--duration-fast) ease;
    }
    .sidebar-links a:hover {
      color: var(--ink);
      background: var(--surface-2);
    }
    .sidebar-links a.active {
      color: var(--accent);
      background: var(--accent-fog);
      border-left-color: var(--accent);
    }

    /* ── Content ─────────────────────────────────────────────────── */
    .docs-content {
      padding: var(--space-12) var(--space-12) var(--space-16);
      min-width: 0;
    }

    .docs-breadcrumb {
      font-family: var(--font-body);
      font-size: 0.72rem;
      letter-spacing: 0.04em;
      color: var(--muted);
      margin-bottom: var(--space-8);
      display: flex;
      align-items: center;
      gap: var(--space-2);
    }
    .docs-breadcrumb a { color: var(--accent); transition: color var(--duration-fast) ease; }
    .docs-breadcrumb a:hover { color: var(--accent-strong); }
    .docs-breadcrumb span { color: var(--muted); }

    /* Content typography */
    .docs-content h1 {
      font-family: var(--font-display);
      font-size: clamp(2rem, 3.5vw, 2.8rem);
      font-weight: 700;
      letter-spacing: -0.035em;
      line-height: 1.12;
      color: var(--ink);
      margin-bottom: var(--space-5);
      animation: rise 0.5s var(--ease-stiff) both;
    }

    .docs-lead {
      font-size: 1.05rem;
      font-weight: 300;
      color: var(--body);
      line-height: 1.75;
      max-width: 60ch;
      margin-bottom: var(--space-10);
      border-bottom: 1px solid var(--hairline);
      padding-bottom: var(--space-8);
      animation: rise 0.5s var(--ease-stiff) 0.1s both;
    }

    .docs-section {
      margin-bottom: var(--space-12);
      padding-bottom: var(--space-12);
      border-bottom: 1px solid var(--hairline);
    }
    .docs-section:last-child {
      border-bottom: none;
    }

    .docs-section h2 {
      font-family: var(--font-display);
      font-size: clamp(1.4rem, 2.5vw, 1.9rem);
      font-weight: 700;
      letter-spacing: -0.025em;
      color: var(--ink);
      margin-bottom: var(--space-5);
      line-height: 1.2;
    }

    .docs-section h3 {
      font-family: var(--font-display);
      font-size: 1.1rem;
      font-weight: 600;
      color: var(--ink);
      margin: var(--space-8) 0 var(--space-3);
    }

    .docs-section p {
      color: var(--body);
      font-size: 0.95rem;
      line-height: 1.8;
      margin-bottom: var(--space-4);
      max-width: 70ch;
    }

    .docs-section a {
      color: var(--accent);
      border-bottom: 1px solid var(--accent-dim);
      transition: border-bottom-color var(--duration-fast) ease;
    }
    .docs-section a:hover { border-bottom-color: var(--accent); }

    .docs-section ul, .docs-section ol {
      padding-left: var(--space-6);
      margin-bottom: var(--space-5);
    }
    .docs-section ul { list-style: disc; }
    .docs-section ol { list-style: decimal; }
    .docs-section li {
      color: var(--body);
      font-size: 0.95rem;
      line-height: 1.75;
      margin-bottom: var(--space-2);
      max-width: 68ch;
    }

    .docs-section code {
      font-family: var(--font-mono);
      font-size: 0.82em;
      background: var(--surface-3);
      box-shadow: 0 0 0 1px var(--hairline);
      padding: 1px 5px;
      border-radius: var(--radius-sm);
      color: var(--ink);
      /* A long path or setting name wraps on a phone instead of widening the page. */
      overflow-wrap: break-word;
    }

    /* Code block */
    .code-block {
      background: var(--inverse);
      box-shadow: 0 0 0 1px color-mix(in srgb, var(--inverse-ink) 6%, transparent);
      border-radius: var(--radius-md);
      overflow: hidden;
      margin: var(--space-5) 0;
    }
    .code-block-header {
      background: color-mix(in srgb, var(--inverse-ink) 3%, transparent);
      border-bottom: 1px solid color-mix(in srgb, var(--inverse-ink) 6%, transparent);
      padding: var(--space-2) var(--space-5);
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .code-block-lang {
      font-family: var(--font-mono);
      font-size: 0.65rem;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--inverse-muted);
    }
    .code-block pre {
      padding: var(--space-5) var(--space-6);
      overflow-x: auto;
      margin: 0;
    }
    /* A bare <pre> scrolls inside itself too: the webhook example's longer
       message line pushed the whole page sideways at 390 px. */
    pre { max-width: 100%; overflow-x: auto; }
    .code-block pre code {
      font-family: var(--font-mono);
      font-size: 0.82rem;
      line-height: 1.85;
      color: var(--inverse-ink);
      background: none;
      box-shadow: none;
      padding: 0;
    }
    /* Comment and output share --inverse-muted, the one secondary step DESIGN.md gives on inverse;
       italic (comment) and the smaller size (output) tell them apart. */
    .t-prompt { color: var(--inverse-accent); user-select: none; }
    .t-cmd    { color: var(--inverse-ink); }
    .t-comment { color: var(--inverse-muted); font-style: italic; }
    .t-str    { color: var(--inverse-warning); }
    .t-out    { color: var(--inverse-muted); font-size: 0.78rem; }


    /* Table scrolls horizontally inside its column at narrow widths instead
       of widening the page (390px layout check). */
    .table-scroll { overflow-x: auto; }
    .table-scroll .env-table { margin: var(--space-5) 0; }

    /* Env var table */
    .env-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.875rem;
    }
    .env-table thead th {
      font-family: var(--font-mono);
      font-size: 0.62rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--muted);
      padding: var(--space-3) var(--space-4);
      text-align: left;
      border-bottom: 2px solid var(--hairline);
      white-space: nowrap;
    }
    .env-table tbody td {
      padding: var(--space-3) var(--space-4);
      border-bottom: 1px solid var(--hairline);
      color: var(--body);
      vertical-align: top;
      line-height: 1.6;
    }
    .env-table tbody tr:last-child td { border-bottom: none; }
    .env-table tbody tr:hover td { background: var(--surface-3); }
    .env-key {
      font-family: var(--font-mono);
      font-size: 0.82rem;
      color: var(--ink);
      white-space: nowrap;
    }
    .env-required {
      font-family: var(--font-mono);
      font-size: 0.65rem;
      letter-spacing: 0.08em;
      padding: 2px 6px;
      border-radius: var(--radius-sm);
    }
    .env-req-yes { background: var(--danger-weak); color: var(--danger); box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 20%, transparent); }
    .env-req-no  { background: var(--surface); color: var(--muted); box-shadow: 0 0 0 1px var(--hairline); }

    /* Security layers */
    .security-layers {
      counter-reset: layer;
      display: flex;
      flex-direction: column;
      gap: 0;
    }
    .security-layer {
      display: grid;
      grid-template-columns: 3rem 1fr;
      gap: var(--space-5);
      padding: var(--space-5) 0;
      border-bottom: 1px solid var(--hairline);
      align-items: start;
    }
    .security-layer:last-child { border-bottom: none; }
    .security-layer-num {
      font-family: var(--font-display);
      font-size: 1.6rem;
      font-weight: 700;
      color: var(--accent);
      opacity: 0.4;
      letter-spacing: -0.05em;
      line-height: 1;
      padding-top: 4px;
    }
    .security-layer-title {
      font-family: var(--font-display);
      font-size: 1rem;
      font-weight: 600;
      color: var(--ink);
      margin-bottom: var(--space-2);
    }
    .security-layer-desc {
      font-size: 0.9rem;
      color: var(--body);
      line-height: 1.7;
    }

    /* Step list */
    .step-list {
      counter-reset: step;
      list-style: none !important;
      padding-left: 0 !important;
    }
    .step-list li {
      counter-increment: step;
      display: grid;
      grid-template-columns: 2rem 1fr;
      gap: var(--space-4);
      padding: var(--space-4) 0;
      border-bottom: 1px solid var(--hairline);
      max-width: 100% !important;
    }
    .step-list li:last-child { border-bottom: none; }
    .step-list li::before {
      content: counter(step);
      font-family: var(--font-display);
      font-size: 1.1rem;
      font-weight: 700;
      color: var(--accent);
      opacity: 0.5;
      line-height: 1.5;
    }

    /* ── Themed figures ─────────────────────────────────────────── */
    /* Every diagram and screenshot exists light and dark. CSS picks one from
       data-theme, the attribute the toggle sets; a <picture> media query
       would follow the OS instead (docs-tech/diagrams.md). */
    .diagram, .doc-shot { margin: var(--space-6) 0; }
    .diagram img { max-width: 100%; height: auto; margin: 0 auto; display: block; }
    .doc-shot img {
      width: 100%;
      height: auto;
      box-shadow: 0 0 0 1px var(--hairline);
      border-radius: var(--radius-md);
    }
    .shot-dark { display: none; }
    [data-theme="dark"] .shot-light { display: none; }
    [data-theme="dark"] .shot-dark { display: block; }

    /* ── Responsive ─────────────────────────────────────────────── */

    @media (max-width: 768px) {
      .docs-layout { grid-template-columns: 1fr; }
      .docs-sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--hairline);
      }
      .docs-content { padding: var(--space-8) var(--space-5) var(--space-12); }
      .env-table { font-size: 0.8rem; }
    }

    @media (max-width: 540px) {
      .security-layer { grid-template-columns: 2.5rem 1fr; }
    }

/* The Markdown pages under /en/docs/ have no sidebar: one column of the width the docs content has beside it. */
.docs-standalone { max-width: calc(var(--max-width) - var(--sidebar-width)); margin: 0 auto; }
/* Their Markdown gets the .docs-section type: lists, paragraphs, headings; tables are .env-table. */
.docs-standalone.docs-section { border-bottom: none; }
.docs-standalone hr { border: none; border-top: 1px solid var(--hairline); margin: var(--space-8) 0; }
