/* =============================================
   PROPOSAL AI — GitBook Style
   assets/style.css
   ============================================= */

/* RESET */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* DESIGN TOKENS */
:root {
  --brand: #346ddb;
  --brand-light: #eef3fd;
  --brand-subtle: #d4e2fb;

  --sidebar-w: 272px;
  --toc-w: 224px;
  --header-h: 52px;

  --bg: #ffffff;
  --bg-sidebar: #f7f9fb;
  --bg-hover: #eef1f5;
  --bg-active: #e5edfc;
  --bg-code: #1c2333;
  --bg-callout: #eef3fd;

  --text: #1c1e21;
  --text-2: #52555a;
  --text-muted: #8a8f99;
  --text-brand: #346ddb;

  --border: #e3e6ea;
  --border-light: #edf0f3;

  --shadow-sm: 0 2px 6px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.15);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-code: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Courier New', monospace;

  --r: 8px;
  --t: 200ms ease;
}

/* DARK THEME */
[data-theme="dark"] {
  --bg: #1a1d24;
  --bg-sidebar: #1e2230;
  --bg-hover: #252a3a;
  --bg-active: #1e2e50;
  --bg-code: #0d1117;
  --bg-callout: #1a2540;

  --text: #eaedf2;
  --text-2: #9ba3b4;
  --text-muted: #5c6578;
  --text-brand: #6b9ef8;

  --border: #2a3045;
  --border-light: #232840;

  --brand-light: #1a2845;
  --brand-subtle: #1e3060;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* BASE */
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background var(--t), color var(--t);
}
a { color: var(--text-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* PROGRESS BAR */
#progress {
  position: fixed;
  top: var(--header-h);
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--brand);
  z-index: 999;
  transition: width .1s ease;
  pointer-events: none;
}

/* ===================== HEADER ===================== */
.hdr {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 200;
  transition: background var(--t), border-color var(--t);
}
.hdr-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: calc(var(--sidebar-w) - 28px);
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  user-select: none;
}
.logo:hover { text-decoration: none; }
.logo-icon {
  width: 28px; height: 28px;
  background: var(--brand);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.logo-txt {
  font-size: 14px; font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
}
.hdr-center { flex: 1; display: flex; justify-content: center; }
.srch-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 7px 14px;
  cursor: pointer;
  width: 280px;
  transition: border-color .12s, box-shadow .12s;
}
.srch-bar:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.srch-ico { color: var(--text-muted); display: flex; }
.srch-txt { flex: 1; font-size: 13px; color: var(--text-muted); }
.srch-kbd {
  font-size: 11px; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}
.hdr-right { display: flex; align-items: center; gap: 6px; }
.ico-btn {
  width: 32px; height: 32px;
  border: none; background: transparent;
  border-radius: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background .12s, color .12s;
}
.ico-btn:hover { background: var(--bg-hover); color: var(--text); }
.mob-menu { display: none; }

/* ===================== LAYOUT ===================== */
.shell {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

/* ===================== SIDEBAR ===================== */
.sidebar {
  position: fixed;
  top: var(--header-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto; overflow-x: hidden;
  z-index: 150;
  transition: transform var(--t), background var(--t), border-color var(--t);
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sb-inner { padding: 12px 0 32px; }
.sb-space {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px 4px; margin-bottom: 4px;
}
.sb-space-ico {
  width: 22px; height: 22px;
  background: var(--brand); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; flex-shrink: 0;
}
.sb-space-name {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-section { margin-top: 18px; }
.sb-section:first-child { margin-top: 4px; }
.sb-sec-title {
  display: flex; align-items: center; gap: 5px;
  padding: 2px 14px 6px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .05em; text-transform: uppercase;
}
.sb-item {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  margin: 1px 6px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 13.5px; font-weight: 400;
  line-height: 1.4;
  transition: background .12s, color .12s;
  user-select: none;
  text-decoration: none;
  width: calc(100% - 12px);
  border: none; background: transparent;
}
.sb-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.sb-item.active {
  background: var(--bg-active);
  color: var(--text-brand);
  font-weight: 500;
}
.sb-item.active::before {
  content: '';
  position: absolute; left: 6px;
  width: 2px; height: 16px;
  background: var(--brand); border-radius: 2px;
}
.sb-ico { font-size: 13px; min-width: 17px; text-align: center; opacity: .75; }
.sb-item.active .sb-ico { opacity: 1; }

/* ===================== MAIN ===================== */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; justify-content: center; }
.article-wrap {
  flex: 1; max-width: 768px;
  padding: 48px 52px 80px;
  min-width: 0;
}

/* ===================== TOC ===================== */
.toc {
  width: var(--toc-w); flex-shrink: 0;
  padding: 52px 0 48px 20px;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  display: none;
}
@media (min-width: 1280px) {
  .toc { display: block; }
  .article-wrap { padding-right: 24px; }
}
.toc-title {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 10px; padding-left: 10px;
}
.toc-item {
  display: block;
  padding: 4px 10px;
  font-size: 12.5px; color: var(--text-muted);
  border-left: 2px solid var(--border);
  margin-bottom: 2px;
  cursor: pointer;
  transition: color .12s, border-color .12s;
  line-height: 1.45;
  text-decoration: none;
}
.toc-item:hover { color: var(--text); border-left-color: var(--text-2); text-decoration: none; }
.toc-item.h3 { padding-left: 20px; font-size: 12px; }
.toc-item.spy { color: var(--text-brand); border-left-color: var(--brand); font-weight: 500; }

/* ===================== PAGE CONTENT ===================== */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 16px; font-size: 12.5px; color: var(--text-muted);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text-brand); text-decoration: none; }
.breadcrumb .sep { opacity: .4; }

.page-title {
  font-size: 30px; font-weight: 700;
  color: var(--text);
  letter-spacing: -.4px; line-height: 1.25;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

/* BODY TYPOGRAPHY */
.body h2 {
  font-size: 20px; font-weight: 600; color: var(--text);
  margin: 36px 0 14px; letter-spacing: -.2px; line-height: 1.3;
  scroll-margin-top: 68px;
}
.body h3 {
  font-size: 16px; font-weight: 600; color: var(--text);
  margin: 26px 0 10px; line-height: 1.4;
  scroll-margin-top: 68px;
}
.body h4 {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  margin: 20px 0 8px; text-transform: uppercase; letter-spacing: .06em;
}
.body p { color: var(--text-2); margin-bottom: 14px; line-height: 1.75; }
.body strong { color: var(--text); font-weight: 600; }
.body em { font-style: italic; }

/* Links */
.body a { color: var(--text-brand); font-weight: 500; }
.body a:hover { text-decoration: underline; }
.body a.ilink {
  border-bottom: 1px solid var(--brand-subtle);
  padding-bottom: 1px;
  transition: border-color .12s;
}
.body a.ilink:hover { border-bottom-color: var(--brand); text-decoration: none; }

/* Inline code */
.body :not(pre) > code {
  font-family: var(--font-code); font-size: 13px;
  background: var(--bg-hover); color: var(--brand);
  padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--border);
}

/* Code blocks */
.body pre {
  background: var(--bg-code);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--r);
  margin: 18px 0; overflow: hidden;
}
.code-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,.05);
  background: rgba(255,255,255,.02);
}
.code-lang {
  font-family: var(--font-code); font-size: 11px;
  color: #6a7fa8; letter-spacing: .04em;
}
.copy-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px; font-size: 11px; font-family: var(--font);
  color: #7a8fa8;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 4px; cursor: pointer;
  transition: all .12s;
}
.copy-btn:hover { color: #c0d0e8; background: rgba(255,255,255,.1); }
.copy-btn.ok { color: #4ade80; border-color: rgba(74,222,128,.3); }
.code-body { padding: 16px 20px; overflow-x: auto; }
.code-body code {
  font-family: var(--font-code); font-size: 13px;
  line-height: 1.65; color: #c9d6e8;
  white-space: pre-wrap; word-break: break-word;
}

/* Lists */
.body ul, .body ol { margin: 10px 0 16px 22px; color: var(--text-2); }
.body li { margin-bottom: 6px; line-height: 1.7; }
.body li > div, .body li > p { display: inline; }

/* Tables */
.table-wrap {
  overflow-x: auto; margin: 18px 0;
  border-radius: var(--r); border: 1px solid var(--border);
}
.body table { width: 100%; border-collapse: collapse; font-size: 14px; }
.body thead tr { background: var(--bg-sidebar); }
.body th {
  padding: 10px 16px; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.body td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-2); line-height: 1.5;
}
.body tr:last-child td { border-bottom: none; }
.body tr:hover td { background: var(--bg-sidebar); }

/* Blockquote */
.body blockquote {
  margin: 16px 0; padding: 14px 18px;
  background: var(--bg-callout);
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--r) var(--r) 0;
  color: var(--text-2);
}
.body blockquote p { margin: 0; color: inherit; }

/* PAGE NAV */
.page-nav {
  display: flex; gap: 12px;
  margin-top: 56px; padding-top: 28px;
  border-top: 1px solid var(--border);
}
.nav-card {
  flex: 1; padding: 14px 18px;
  border: 1px solid var(--border); border-radius: var(--r);
  cursor: pointer; text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
  background: var(--bg);
  display: block;
}
.nav-card:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); text-decoration: none; }
.nav-card.right { text-align: right; }
.nav-dir {
  font-size: 11px; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px;
}
.nav-name { font-size: 14px; font-weight: 600; color: var(--text); }

/* ===================== SEARCH ===================== */
.srch-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: flex-start; justify-content: center;
  padding-top: 72px;
}
.srch-overlay.open { display: flex; }
.srch-modal {
  width: 580px; max-width: calc(100vw - 32px);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in .15s ease;
}
@keyframes modal-in { from { opacity: 0; transform: scale(.96) translateY(-8px); } to { opacity: 1; transform: none; } }
.srch-top {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.srch-top-ico { color: var(--text-muted); display: flex; }
.srch-input {
  flex: 1; border: none; outline: none;
  font-size: 15px; font-family: var(--font);
  color: var(--text); background: transparent;
}
.srch-input::placeholder { color: var(--text-muted); }
.srch-esc {
  font-size: 11px; color: var(--text-muted);
  background: var(--bg-sidebar); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 7px;
}
.srch-results { max-height: 380px; overflow-y: auto; }
.srch-empty { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 14px; }
.srch-result {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 18px; cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background .12s; text-decoration: none;
}
.srch-result:last-child { border-bottom: none; }
.srch-result:hover { background: var(--bg-hover); }
.sr-ico { font-size: 15px; margin-top: 2px; flex-shrink: 0; }
.sr-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.sr-excerpt { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 460px; }
.srch-footer {
  padding: 8px 18px; border-top: 1px solid var(--border-light);
  display: flex; gap: 16px; font-size: 11px; color: var(--text-muted);
}
.srch-footer kbd {
  display: inline-flex; align-items: center;
  background: var(--bg-sidebar); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 5px; margin-right: 4px;
}

/* SIDEBAR BACKDROP */
.sb-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 140; }
.sb-backdrop.open { display: block; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  .main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .mob-menu { display: flex; }
  .hdr-left { min-width: auto; }
  .logo-txt { max-width: 130px; }
  .article-wrap { padding: 28px 20px 60px; }
  .page-title { font-size: 24px; }
  .srch-bar { width: 200px; }
}
@media (max-width: 600px) {
  .srch-bar { display: none; }
  .article-wrap { padding: 20px 16px 60px; }
  .body h2 { font-size: 18px; }
  .page-nav { flex-direction: column; }
}
