:root {
  --accent: #ef5351;
  --accent-fade: #fff4f2;
  --accent-light: #f7f7f7;
  --bg: #fff;
  --sidebar-bg: #f0eee6;
  --sidebar-border: #e6e6e6;
  --sidebar-shadow: 0 2px 16px 0 rgba(0,0,0,0.04);
  --nav-bg: #fff;
  --nav-shadow: 0 1px 0 0 #e6e6e6;
  --text: #222;
  --text-soft: #888;
  --radius: 10px;
  --transition: 0.16s cubic-bezier(.4,0,.2,1);
}

body {
  font-family: Verdana, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.7;
}
img {
  max-width: 100%;
}
blockquote {
  margin-left: 0;
  padding: 10px;
  padding-left: 15px;
  background: var(--accent-light);
  border-left: 5px solid var(--accent);
}
nav {
  background: var(--nav-bg);
  box-shadow: var(--nav-shadow);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
nav .logo {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 1.15em;
  color: var(--accent);
  letter-spacing: 0.5px;
  margin-right: 2.2rem;
  gap: 0.5em;
}
nav .logo img {
  height: 1.6em;
  margin-right: 0.4em;
  vertical-align: middle;
}
nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  margin: 0 0.8em;
  padding: 4px 9px;
  border-radius: 8px;
  transition: background var(--transition);
  font-size: 1em;
}
nav a:hover, nav a.active {
  background: var(--accent-fade);
  color: var(--accent);
}

.container {
  display: flex;
  flex-direction: row;
  margin: 0 auto;
  align-items: flex-start;
}

.sidebar {
  width: 245px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: var(--sidebar-shadow);
  height: 100vh;
  overflow-y: auto;
  border-radius: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
  display: flex;
  flex-direction: column;
}
.sidebar .sidebar-container {
  padding: 2.2rem 1.1rem 2.2rem 2.1rem;
}
.sidebar .sidebar-logo {
  display: flex;
  align-items: center;
  margin-bottom: 2.2rem;
  font-size: 1.12em;
  font-weight: 700;
  color: var(--accent);
  gap: 0.5em;
}
.sidebar .sidebar-logo img {
  max-height: 2.5em;
  margin-right: 0.5em;
}
.sidebar-section {
  margin-bottom: 1em;
}
.sidebar-section-title {
  margin-bottom: 0.7em;
  color: #000;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.1px;
  margin-top: 2.1em;
  text-transform: uppercase;
}
.sidebar-section-title:first-child {
  margin-top: 0;
}
.sidebar ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.sidebar li {
  margin-bottom: 0.18em;
}
.sidebar a {
  color: var(--text);
  text-decoration: none;
  font-size: 1em;
  display: flex;
  align-items: center;
  padding: 7px 0 7px 0.8em;
  border-radius: 6px;
  position: relative;
  transition: background var(--transition), color var(--transition);
}
.sidebar a:hover {
  /* background: var(--accent-fade); */
  color: var(--accent);
}
.sidebar a.active {
  /* background: var(--accent-fade); */
  color: var(--accent);
  font-weight: 500;
}
.sidebar a.active, .sidebar a[aria-current="page"] {
  color: var(--accent);
  /* background: var(--accent-fade); */
  font-weight: 700;
}
.sidebar .sidebar-divider {
  border-bottom: 1px solid var(--sidebar-border);
  margin: 1.5em 0 1.5em 0;
}

main, .blog-post {
  flex: 1 1 0;
  min-width: 0;
  padding: 2.7rem 2.2rem 2.5rem 2.2rem;
  padding-top: 0;
  max-width: 780px;
  margin: 2.5rem auto 2.5rem auto;
  margin-top: 0;
  background: #fff;
  box-shadow: 0 2px 16px rgba(80,120,255,0.05);
  position: relative;
}

.toc {
  width: 230px;
  min-width: 180px;
  max-width: 260px;
  padding: 2.2rem 1.1rem 2.2rem 0.5rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  font-size: 0.9em;
  color: #333;
  background: none;
  z-index: 5;
  height: 100vh;
  overflow-y: auto;
  display: block;
}
.toc-title {
  font-weight: 700;
  margin-bottom: 1.1em;
  color: var(--accent);
}
.toc-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.toc-list li {
  padding: 0;
}
.toc-list > li {
  padding-left: 0;
  margin-bottom: 0.4em;
}
.toc-level2 {
  padding-left: 1.3em;
  margin-bottom: 0.2em;
  font-size: 0.97em;
}
.toc-level3 {
  padding-left: 2.2em;
  margin-bottom: 0.15em;
  font-size: 0.95em;
}
.toc a {
  color: #555;
  text-decoration: none;
  display: block;
  border-radius: 4px;
  padding: 2px 4px;
  transition: color 0.14s, background 0.14s;
}
.toc a:hover {
  color: var(--accent);
  text-decoration: underline;
  background: #fff4f2;
}
.toc a.active {
  color: var(--accent);
  background: #fff4f2;
  box-shadow: none;
}

@media (max-width: 1200px) {
  .toc { display: none; }
  main, .blog-post { max-width: 100%; }
}

h1, h2, h3, h4 {
  color: #23304e;
  font-weight: 700;
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  letter-spacing: 0.1px;
}
h1 {
  font-size: 2.2em;
}
h2 {
  font-size: 1.36em;
  color: var(--accent);
}
h3 {
  font-size: 1.13em;
  text-decoration: underline;
}
code {
  background: #ededed;
  padding: 2px 5px;
}
pre, pre > code {
  background: #f9f2f2;
  border-radius: 6px;
  font-family: 'JetBrains Mono', 'SFMono-Regular', 'Menlo', 'Monaco', monospace;
  font-size: 0.97em;
}
pre {
  padding: 1em;
  overflow-x: auto;
}
pre > code {
  font-family: 'JetBrains Mono', 'SFMono-Regular', 'Menlo', 'Monaco', monospace;
  font-size: 13px !important;
  line-height: 1.6;
  padding: 0;
  background: transparent;
}

/* Syntax highlighting */
pre code .comment { color: #6a9955; font-style: italic; }
pre code .string { color: #ce9178; }
pre code .keyword { color: #569cd6; font-weight: 500; }
pre code .variable { color: #9cdcfe; }
pre code .number { color: #b5cea8; }

/* Table */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 2em 0 1.5em 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(80,120,255,0.05);
  overflow: hidden;
  font-size: 1em;
}
thead {
  background: #fafbfc;
}
thead th {
  font-weight: 700;
  color: #23304e;
  padding: 0.9em 1em;
  text-align: left;
  border-bottom: 2px solid #f0f0f0;
}
tbody td {
  padding: 0.8em 1em;
  color: #222;
  border-bottom: 1px solid #f3f3f3;
}
tbody tr:nth-child(even) {
  background: #f8f8fb;
}
tbody tr:hover {
  background: #fff4f2;
  transition: background 0.18s;
}
table, th, td {
  border: none;
}
table code {
  background: #ededed;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.98em;
}
table th:first-child, table td:first-child {
  border-left: none;
}
table th:last-child, table td:last-child {
  border-right: none;
}
table th, table td {
  vertical-align: middle;
}

/* Hamburger button */
.hamburger {
  display: none;
  position: fixed;
  top: 11px;
  left: 14px;
  z-index: 200;
  background: none;
  border: 1.5px solid var(--sidebar-border);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), opacity 0.22s;
}
.hamburger:hover {
  background: var(--accent-fade);
  border-color: var(--accent);
}
.hamburger:hover span {
  background: var(--accent);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 45;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.open {
  display: block;
}

/* Responsive */
@media (max-width: 950px) {
  .hamburger {
    display: flex;
  }
  .container {
    padding: 0;
  }
  .sidebar {
    position: fixed !important;
    left: -280px;
    top: 0;
    padding-top: 4rem;
    width: 265px !important;
    height: 100vh !important;
    min-height: unset;
    box-shadow: 4px 0 28px rgba(0,0,0,0.18);
    border-radius: 0;
    transition: left 0.28s cubic-bezier(.4,0,.2,1);
    z-index: 50;
  }
  .sidebar.open {
    left: 0;
  }
  main, .blog-post {
    margin: 0;
    padding: 1.2rem 1rem;
    padding-top: 3.8rem;
    max-width: 100%;
  }
}

/* Theme toggle button */
.theme-toggle {
  position: fixed;
  top: 12px;
  right: 18px;
  z-index: 200;
  background: none;
  border: 1.5px solid var(--sidebar-border);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.theme-toggle:hover {
  background: var(--accent-fade);
  border-color: var(--accent);
  color: var(--accent);
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle {
  border-color: #333;
  color: #ccc;
}
[data-theme="dark"] .theme-toggle:hover {
  background: #1a1a1a;
  border-color: var(--accent);
  color: var(--accent);
}

/* Dark mode */
[data-theme="dark"] {
  --bg: #000;
  --text: #a9a9a9;
  --sidebar-bg: #000;
  --sidebar-border: #000;
  --nav-bg: #000;
  --text-soft: #999;
}

[data-theme="dark"] body,
[data-theme="dark"] .container,
[data-theme="dark"] .sidebar,
[data-theme="dark"] main {
  background: #000;
}

[data-theme="dark"] body {
  color: var(--text);
}

[data-theme="dark"] a {
  color: #c8c8c8;
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4 {
  color: #b93e3c;
  text-decoration: none;
}

[data-theme="dark"] :not(.sidebar-logo) > img {
  border-radius: 15px;
    padding: 15px;
    background: #fff;
}

[data-theme="dark"] .sidebar-section-title {
  color: #c9c9c9;
}

[data-theme="dark"] pre,
[data-theme="dark"] code,
[data-theme="dark"] :not(pre) > code {
  background-color: #262626;
  color: #c9c9c9;
}

[data-theme="dark"] .sidebar {
  border-right-color: #000;
}

[data-theme="dark"] .toc a.active {
  background: inherit;
}

[data-theme="dark"] hr {
  background: #222;
}

[data-theme="dark"] blockquote {
  background: #111;
}

[data-theme="dark"] thead {
  background: #111;
}

[data-theme="dark"] thead th {
  color: #ddd;
  border-bottom-color: #222;
}

[data-theme="dark"] tbody td {
  color: #ccc;
  border-bottom-color: #1a1a1a;
}

[data-theme="dark"] tbody tr:nth-child(even) {
  background: #0d0d0d;
}

[data-theme="dark"] tbody tr:hover {
  background: #1a1a1a;
}

[data-theme="dark"] table {
  background: #000;
  box-shadow: none;
}

[data-theme="dark"] .toc a,
[data-theme="dark"] .toc a:hover {
  background-color: inherit;
}

@media (max-width: 950px) {
  .theme-toggle {
    top: 10px;
    right: 12px;
  }
}

[data-theme="dark"] .hamburger span {
  background: #ccc;
}
[data-theme="dark"] .hamburger {
  border-color: #333;
}
[data-theme="dark"] .hamburger:hover {
  background: #1a1a1a;
  border-color: var(--accent);
}
[data-theme="dark"] .hamburger:hover span {
  background: var(--accent);
}
[data-theme="dark"] .sidebar-overlay {
  background: rgba(0,0,0,0.65);
}