:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-sidebar: #f8f9fb;
  --bg-code: #f4f5f7;
  --panel: #ffffff;
  --text: #1c2128;
  --text-soft: #57606a;
  --text-faint: #8b949e;
  --border: #e3e6ea;
  --border-soft: #eef0f3;
  --accent: #b5121b;         /* vermelho xHarbour */
  --accent-soft: #fbeaeb;
  --accent-text: #b5121b;
  --link: #0a5ad6;
  --kw: #b5121b;
  --str: #0a7d34;
  --com: #8b949e;
  --num: #8250df;
  --fn: #0a5ad6;
  --shadow: 0 1px 3px rgba(16,22,26,.08), 0 1px 2px rgba(16,22,26,.04);
  --mono: "SFMono-Regular", "JetBrains Mono", "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-sidebar: #0f141b;
  --bg-code: #161b22;
  --panel: #0d1117;
  --text: #e6edf3;
  --text-soft: #9da7b3;
  --text-faint: #6e7781;
  --border: #21262d;
  --border-soft: #1a1f26;
  --accent: #f0616d;
  --accent-soft: #2a1416;
  --accent-text: #f0616d;
  --link: #58a6ff;
  --kw: #f0616d;
  --str: #7ee787;
  --com: #6e7781;
  --num: #d2a8ff;
  --fn: #58a6ff;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100vh; overflow: hidden; }

header.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 18px; height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; white-space: nowrap; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  font-family: var(--mono);
}
.brand .titles b { font-size: 15px; display: block; line-height: 1.1; }
.brand .titles span { font-size: 11px; color: var(--text-faint); }

.search-wrap { position: relative; flex: 1; max-width: 620px; }
.search-wrap input {
  width: 100%; height: 38px; padding: 0 38px 0 36px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg-soft); color: var(--text); font-size: 14px;
  outline: none;
}
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-wrap .si { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.search-wrap .kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-faint); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; background: var(--panel);
}
.topbar .spacer { flex: 1; }
.credit { font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.iconbtn {
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text-soft);
  width: 38px; height: 38px; border-radius: 9px; cursor: pointer; display: grid; place-items: center;
  font-size: 16px;
}
.iconbtn:hover { color: var(--text); border-color: var(--text-faint); }
#menuToggle { display: none; }

.body { display: grid; grid-template-columns: 300px 1fr; min-height: 0; }

/* ---------- Sidebar ---------- */
aside.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto; padding: 14px 8px 60px;
}
.sec-group { margin-bottom: 4px; }
.sec-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 12px; border: none; background: none; cursor: pointer;
  color: var(--text); font-size: 13.5px; font-weight: 700; border-radius: 8px;
  text-align: left; font-family: var(--sans);
}
.sec-head:hover { background: var(--bg-soft); }
.sec-head .caret { color: var(--text-faint); transition: transform .15s; font-size: 11px; }
.sec-head.collapsed .caret { transform: rotate(-90deg); }
.sec-head .cnt { margin-left: auto; font-size: 11px; color: var(--text-faint); font-weight: 600; background: var(--bg-soft); border-radius: 20px; padding: 1px 8px; }
.sec-list { list-style: none; margin: 2px 0 8px; padding: 0; }
.sec-list.hidden { display: none; }
.sec-list li a {
  display: block; padding: 5px 12px 5px 30px; color: var(--text-soft);
  font-size: 13px; border-radius: 7px; font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sec-list li a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.sec-list li a.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* ---------- Main / content ---------- */
main.content { overflow-y: auto; padding: 0; scroll-behavior: smooth; }
.content-inner { max-width: 900px; margin: 0 auto; padding: 30px 40px 120px; }

.crumbs { font-size: 12.5px; color: var(--text-faint); margin-bottom: 14px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.crumbs a { color: var(--text-faint); }

.entry-head { border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 22px; }
.entry-title { font-size: 30px; font-weight: 800; margin: 0 0 6px; font-family: var(--mono); word-break: break-word; letter-spacing: -.5px; }
.entry-sum { font-size: 16px; color: var(--text-soft); margin: 0; }
.badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.badge {
  font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
  background: var(--bg-soft); color: var(--text-soft); border: 1px solid var(--border-soft);
}
.badge.section { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge.untranslated { background: transparent; color: var(--text-faint); border: 1px dashed var(--border); }

section.field { margin: 26px 0; }
section.field > h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--accent-text); font-weight: 700; margin: 0 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.field p { margin: 0 0 10px; }
.prose { white-space: pre-wrap; }
.prose.args .argname { display: block; font-family: var(--mono); font-weight: 700; color: var(--text); margin-top: 12px; font-size: 13.5px; }
.prose.args .argname:first-child { margin-top: 0; }

pre.code {
  background: var(--bg-code); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; overflow-x: auto;
  font-family: var(--mono); font-size: 13px; line-height: 1.55; margin: 0;
  white-space: pre;
}
pre.syntax { background: var(--bg-code); }
code.inline { font-family: var(--mono); background: var(--bg-soft); padding: 1px 5px; border-radius: 5px; font-size: .9em; }

/* syntax highlight tokens */
.tok-kw { color: var(--kw); font-weight: 600; }
.tok-str { color: var(--str); }
.tok-com { color: var(--com); font-style: italic; }
.tok-num { color: var(--num); }
.tok-fn { color: var(--fn); }

.seealso-list { display: flex; flex-wrap: wrap; gap: 8px; }
.seealso-list a, .seealso-list span.dead {
  font-family: var(--mono); font-size: 13px; padding: 4px 11px; border-radius: 7px;
  background: var(--bg-soft); border: 1px solid var(--border-soft);
}
.seealso-list a:hover { border-color: var(--accent); text-decoration: none; }
.seealso-list span.dead { color: var(--text-faint); }

.infotable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.infotable td { padding: 7px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.infotable td.k { color: var(--text-faint); width: 130px; font-weight: 600; }
.infotable td.v { font-family: var(--mono); color: var(--text); }

.note { background: var(--accent-soft); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 13.5px; color: var(--text-soft); }

/* ---------- Search results ---------- */
.results-head { font-size: 13px; color: var(--text-faint); margin-bottom: 14px; }
.result {
  display: block; padding: 12px 14px; border: 1px solid var(--border-soft);
  border-radius: 10px; margin-bottom: 8px; background: var(--panel);
}
.result:hover { border-color: var(--accent); text-decoration: none; }
.result .rname { font-family: var(--mono); font-weight: 700; font-size: 15px; color: var(--text); }
.result .rsec { font-size: 11px; color: var(--accent-text); font-weight: 600; margin-left: 8px; }
.result .rsum { color: var(--text-soft); font-size: 13.5px; margin-top: 3px; }
.result mark { background: #ffe58a; color: inherit; border-radius: 3px; padding: 0 1px; }
:root[data-theme="dark"] .result mark { background: #7a5b00; color: #fff; }

/* ---------- Home ---------- */
.home h1 { font-size: 28px; margin: 6px 0 8px; }
.home .lead { color: var(--text-soft); font-size: 16px; max-width: 680px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 14px; margin-top: 26px; }
.card {
  border: 1px solid var(--border); border-radius: 12px; padding: 18px; cursor: pointer;
  background: var(--panel); transition: border-color .12s, transform .12s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.card .cn { font-size: 16px; font-weight: 700; color: var(--text); }
.card .cc { font-size: 13px; color: var(--text-faint); margin-top: 4px; }
.card .cbig { font-size: 26px; font-weight: 800; color: var(--accent-text); }
.progress-note { margin-top: 30px; font-size: 13px; color: var(--text-faint); }

.empty { color: var(--text-faint); text-align: center; padding: 60px 20px; }

/* ---------- Responsive ---------- */
.backdrop { display: none; }
@media (max-width: 860px) {
  .body { grid-template-columns: 1fr; }
  aside.sidebar {
    position: fixed; top: 56px; bottom: 0; left: 0; width: 300px; z-index: 30;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  aside.sidebar.open { transform: translateX(0); }
  #menuToggle { display: grid; }
  .backdrop.show { display: block; position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,.35); z-index: 25; }
  .content-inner { padding: 22px 18px 100px; }
  .brand .titles span { display: none; }
  .search-wrap .kbd { display: none; }
  .credit { display: none; }
}
