:root {
  --bg: #ffffff;
  --bg-soft: #f4f7fb;
  --text: #17202e;
  --muted: #566176;
  --line: #dfe5ee;
  --brand: #0b61d1;
  --brand-ink: #ffffff;
  --brand-soft: #e6f0fd;
  --nav-bg: #0f1b33;
  --nav-text: #c9d3e6;
  --nav-strong: #ffffff;
  --nav-line: #22314f;
  --tip: #0b7a4b;      --tip-bg: #e8f6ef;
  --note: #0b61d1;     --note-bg: #e6f0fd;
  --warning: #a35a00;  --warning-bg: #fff3df;
  --careful: #b3261e;  --careful-bg: #fdeceb;
  --example: #5b3fb0;  --example-bg: #efeafc;
  --code-bg: #eef2f8;
  --shadow: 0 8px 30px rgba(15, 27, 51, .14);
  --radius: 10px;
}
:root[data-theme="dark"] {
  --bg: #0d1424;
  --bg-soft: #141c30;
  --text: #e5eaf4;
  --muted: #9aa6bd;
  --line: #28344f;
  --brand: #5ea1ff;
  --brand-ink: #0d1424;
  --brand-soft: #172a4a;
  --nav-bg: #0a1121;
  --nav-line: #1c2a47;
  --tip: #5fd3a0;     --tip-bg: #102a21;
  --note: #7db4ff;    --note-bg: #12233f;
  --warning: #f1b565; --warning-bg: #33250f;
  --careful: #ff9c95; --careful-bg: #381614;
  --example: #b8a4f5; --example-bg: #221b3f;
  --code-bg: #1a2440;
  --shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1424; --bg-soft: #141c30; --text: #e5eaf4; --muted: #9aa6bd; --line: #28344f; --brand: #5ea1ff; --brand-ink: #0d1424; --brand-soft: #172a4a;
    --nav-bg: #0a1121; --nav-line: #1c2a47;
    --tip: #5fd3a0; --tip-bg: #102a21; --note: #7db4ff; --note-bg: #12233f; --warning: #f1b565; --warning-bg: #33250f;
    --careful: #ff9c95; --careful-bg: #381614; --example: #b8a4f5; --example-bg: #221b3f; --code-bg: #1a2440; --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.7 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Noto Sans Gujarati", "Noto Sans Tamil", "Noto Sans Telugu", "Noto Sans Arabic", Arial, sans-serif;
  top: 0 !important; /* Google Translate pushes the page down with an inline style */
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: var(--brand-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 30; height: 60px; display: flex; align-items: center; gap: 14px; padding: 0 20px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand img { display: block; height: 30px; width: auto; }
.brand .mark { display: none; border-radius: 8px; }
.brand .word { padding-left: 10px; border-left: 1px solid var(--line); line-height: 26px; }
/* colour logo on the light theme, white logo on the dark one */
.brand .logo .dark { display: none; }
:root[data-theme="dark"] .brand .logo .light { display: none; }
:root[data-theme="dark"] .brand .logo .dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo .light { display: none; }
  :root:not([data-theme="light"]) .brand .logo .dark { display: block; }
}
.menu-btn { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); cursor: pointer; padding: 0; }
.menu-btn span, .menu-btn span::before, .menu-btn span::after { display: block; width: 18px; height: 2px; background: var(--text); margin: 0 auto; position: relative; content: ""; }
.menu-btn span::before { position: absolute; top: -6px; left: 0; }
.menu-btn span::after { position: absolute; top: 6px; left: 0; }
.search { position: relative; flex: 1; max-width: 560px; margin: 0 auto 0 24px; }
.search input {
  width: 100%; height: 40px; padding: 0 14px 0 40px; font: inherit; font-size: 15px; color: var(--text); background: var(--bg-soft) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23788399' stroke-width='2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>") 13px center no-repeat;
  border: 1px solid var(--line); border-radius: 10px;
}
#results {
  position: absolute; top: 46px; left: 0; right: 0; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 70vh; overflow: auto; padding: 6px;
}
#results a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
#results a:hover, #results a.active { background: var(--brand-soft); }
#results strong { display: block; font-size: 15px; }
#results small { display: block; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
#results .none { padding: 12px; color: var(--muted); font-size: 15px; }
.lang select { height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: 15px; padding: 0 10px; max-width: 150px; }
.icon-btn { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); cursor: pointer; font-size: 18px; }
.icon-btn::before { content: "\25D0"; }

/* layout */
.shell { display: flex; min-height: calc(100vh - 60px); }
#sidebar {
  flex: 0 0 300px; width: 300px; background: var(--nav-bg); color: var(--nav-text); font-size: 15px; line-height: 1.4;
  position: sticky; top: 60px; align-self: flex-start; height: calc(100vh - 60px); overflow-y: auto; padding: 14px 10px 40px;
}
#sidebar ul { list-style: none; margin: 0; padding: 0; }
#sidebar summary { cursor: pointer; list-style: none; }
#sidebar summary::-webkit-details-marker { display: none; }
#sidebar details.area > summary {
  padding: 10px 12px; font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--nav-strong); border-radius: 8px;
  display: flex; justify-content: space-between;
}
#sidebar details.area > summary::after { content: "+"; color: var(--nav-text); }
#sidebar details.area[open] > summary::after { content: "\2212"; }
#sidebar a { display: block; padding: 7px 12px; color: var(--nav-text); text-decoration: none; border-radius: 8px; }
#sidebar a:hover { background: var(--nav-line); color: var(--nav-strong); }
#sidebar a.current { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
#sidebar .book > details > ul { margin: 2px 0 6px 14px; border-left: 1px solid var(--nav-line); }
#sidebar .book > details > ul a { font-size: 14px; padding: 5px 12px; }
#sidebar details.area { margin-bottom: 2px; }

main { flex: 1; min-width: 0; padding: 28px clamp(18px, 5vw, 72px) 60px; }
article, .foot, .crumbs, .pn { max-width: 780px; margin-left: auto; margin-right: auto; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--muted); }
h1 { font-size: clamp(30px, 4vw, 40px); line-height: 1.2; margin: 0 0 12px; letter-spacing: -.01em; }
h2 { font-size: 26px; line-height: 1.3; margin: 2.2em 0 .6em; padding-top: .4em; border-top: 1px solid var(--line); }
h3 { font-size: 20px; line-height: 1.35; margin: 1.8em 0 .5em; }
.lead { font-size: 20px; line-height: 1.6; color: var(--muted); margin: 0 0 22px; }
p, ul, ol { margin: 0 0 1em; }
li { margin: .3em 0; }
li > ul, li > ol { margin-top: .3em; }
strong.ui { font-weight: 600; background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; white-space: nowrap; font-size: .94em; }
code { background: var(--code-bg); border-radius: 6px; padding: 2px 6px; font-size: .92em; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
pre { background: var(--code-bg); border-radius: var(--radius); padding: 14px 16px; overflow: auto; }
pre code { background: none; padding: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

.glance { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0 0 28px; }
.glance div { background: var(--bg-soft); padding: 12px 16px; }
.glance dt { font-size: 12.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.glance dd { margin: 0; font-size: 16px; }

.table-wrap { overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 15.5px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg-soft); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

figure { margin: 1.6em 0; }
figure a.zoom { display: block; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 2px 14px rgba(15, 27, 51, .08); cursor: zoom-in; }
figure img { display: block; width: 100%; height: auto; }
figcaption { font-size: 14.5px; color: var(--muted); margin-top: 8px; text-align: center; }
.lightbox { position: fixed; inset: 0; background: rgba(8, 12, 22, .88); z-index: 80; display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: min(96vw, 1600px); max-height: 92vh; border-radius: 8px; background: #fff; }

blockquote.callout { margin: 1.4em 0; padding: 14px 18px; border-left: 5px solid var(--note); background: var(--note-bg); border-radius: 0 var(--radius) var(--radius) 0; }
blockquote.callout p:last-child { margin-bottom: 0; }
blockquote.callout .callout-title { color: var(--note); }
blockquote.tip { border-color: var(--tip); background: var(--tip-bg); } blockquote.tip .callout-title { color: var(--tip); }
blockquote.warning { border-color: var(--warning); background: var(--warning-bg); } blockquote.warning .callout-title { color: var(--warning); }
blockquote.careful { border-color: var(--careful); background: var(--careful-bg); } blockquote.careful .callout-title { color: var(--careful); }
blockquote.example { border-color: var(--example); background: var(--example-bg); } blockquote.example .callout-title { color: var(--example); }
blockquote:not(.callout) { margin: 1em 0; padding: 4px 18px; border-left: 4px solid var(--line); color: var(--muted); }

ul.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin: 1em 0 1.6em; }
ul.cards li { margin: 0; }
ul.cards a { display: block; height: 100%; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
ul.cards a:hover { border-color: var(--brand); box-shadow: 0 4px 18px rgba(11, 97, 209, .14); }
ul.cards strong { display: block; font-size: 17px; margin-bottom: 4px; color: var(--brand); }
ul.cards span { display: block; font-size: 15px; color: var(--muted); line-height: 1.5; }
.area-block h2 { border-top: 0; margin-top: 1.6em; }

.pn { display: flex; justify-content: space-between; gap: 16px; margin-top: 3em; }
.pn a { flex: 1; max-width: 48%; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); font-weight: 600; }
.pn a:hover { border-color: var(--brand); }
.pn small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.pn .next { text-align: right; margin-left: auto; }
.foot { margin-top: 3em; padding-top: 1.2em; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.foot p { margin: 0 0 6px; }

/* Google Translate: hide its own banner and widget; the language box above does the job */
.goog-te-banner-frame, .goog-te-balloon-frame, #goog-gt-tt, .goog-tooltip, .skiptranslate iframe { display: none !important; }
.goog-text-highlight { background: none !important; box-shadow: none !important; }

@media (max-width: 960px) {
  .menu-btn { display: block; }
  .search { margin-left: 0; }
  #sidebar { position: fixed; z-index: 40; top: 60px; left: 0; bottom: 0; height: auto; transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open #sidebar { transform: none; }
  .brand .logo, .brand .word { display: none; }
  .brand .mark { display: block; }
}
@media (max-width: 560px) {
  body { font-size: 16.5px; }
  .top { gap: 8px; padding: 0 12px; }
  .lang select { max-width: 96px; }
  .pn { flex-direction: column; } .pn a { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .top, #sidebar, .pn, .foot .rawlink { display: none !important; }
  main { padding: 0; } body { font-size: 12pt; }
  figure { break-inside: avoid; }
}
