:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #111827;
  --muted: #4b5563;
  --line: #dbe2ea;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #2563eb;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --container: 1160px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container {
  width: min(var(--container), calc(100% - 32px));
  margin: 0 auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: rgba(245, 247, 251, 0.92);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.nav-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--primary);
  font-size: 14px;
}

.nav-links {
  display: flex;
  gap: 18px;
  font-weight: 600;
  color: var(--muted);
}
.nav-links a:hover { color: var(--ink); }

/* Dashboard Grid */
.hero {
  padding: 60px 0 30px;
  text-align: center;
}
.hero h1 { font-size: 2.8rem; margin: 0 0 12px; letter-spacing: -0.03em; }
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 60ch; margin: 0 auto 30px; }

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  padding-bottom: 60px;
}

.topic-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.topic-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.topic-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #eef8f7;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 24px;
  margin-bottom: 16px;
}

.topic-card h2 { margin: 0 0 8px; font-size: 1.4rem; letter-spacing: -0.02em; }
.topic-card p { color: var(--muted); margin: 0 0 20px; flex-grow: 1; }
.topic-card .btn {
  align-self: flex-start;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Content Pages */
.page-header {
  padding: 40px 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  margin-bottom: 40px;
}
.page-header h1 { margin: 0 0 8px; font-size: 2.4rem; letter-spacing: -0.03em; }
.page-header p { margin: 0; color: var(--muted); font-size: 1.1rem; }

.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
  padding-bottom: 60px;
}

@media(min-width: 980px) {
  .content-grid {
    grid-template-columns: 2fr 1fr;
    align-items: start;
  }
}

.article-body h2 { font-size: 1.8rem; margin: 40px 0 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.article-body h3 { font-size: 1.4rem; margin: 30px 0 12px; }
.article-body p { margin: 0 0 16px; }
.article-body ul { padding-left: 20px; margin: 0 0 16px; }

/* Code Tabs */
.code-section {
  background: #1e1e1e;
  border-radius: 12px;
  overflow: hidden;
  margin: 24px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.code-tabs {
  display: flex;
  background: #2d2d2d;
  border-bottom: 1px solid #404040;
}

.code-tab {
  padding: 10px 20px;
  color: #a3a3a3;
  font-family: monospace;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  background: none;
}

.code-tab.active {
  background: #1e1e1e;
  color: #fff;
  border-top: 2px solid var(--accent);
}

.code-pane {
  display: none;
  padding: 20px;
  overflow-x: auto;
}

.code-pane.active {
  display: block;
}

pre { margin: 0; }
code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.9rem;
  color: #d4d4d4;
}

/* Inline Code */
p code, li code {
  background: #e2e8f0;
  color: #b91c1c;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* Mermaid Wrapper */
.diagram-wrapper {
  background: var(--surface);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin: 24px 0;
  text-align: center;
  overflow-x: auto;
}

/* Sidebar */
.toc {
  background: var(--surface);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--line);
  position: sticky;
  top: 90px;
}
.toc h3 { margin: 0 0 16px; font-size: 1.1rem; }
.toc ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.toc a { color: var(--muted); font-size: 0.95rem; }
.toc a:hover { color: var(--primary); font-weight: 600; }

/* Cheatsheet */
.cheatsheet {
  background: #eef8f7;
  border-left: 4px solid var(--primary);
  padding: 16px 20px;
  border-radius: 0 12px 12px 0;
  margin: 20px 0;
  list-style: none;
}
.cheatsheet li {
  margin-bottom: 12px;
  color: var(--primary-dark);
  line-height: 1.6;
}
.cheatsheet li:last-child {
  margin-bottom: 0;
}
.cheatsheet code {
  background: rgba(15, 118, 110, 0.1);
  color: var(--primary-dark);
}

/* =========================================================
   LeetCode Explorer
   ========================================================= */

.lc-explorer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  margin-top: 40px;
}

.lc-header {
  padding: 30px 30px 20px;
  background: linear-gradient(135deg, #0f766e12 0%, #2563eb08 100%);
  border-bottom: 1px solid var(--line);
}

.lc-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.lc-title {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.lc-icon { font-size: 1.3rem; }

.lc-badge {
  background: var(--primary);
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}

.lc-subtitle {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 0.95rem;
}

.lc-controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.lc-search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.lc-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  pointer-events: none;
}

.lc-search {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s;
}

.lc-search:focus { border-color: var(--primary); }

.lc-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lc-filter {
  padding: 7px 14px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.18s;
}

.lc-filter:hover { border-color: var(--primary); color: var(--primary); }
.lc-filter.active { background: var(--primary); color: white; border-color: var(--primary); }

.lc-table-wrap {
  overflow-x: auto;
  padding: 0 20px;
}

.lc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.lc-table thead th {
  text-align: left;
  padding: 14px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1.5px solid var(--line);
}

.lc-row {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s;
}

.lc-row:hover { background: #f0faf9; }
.lc-row:last-child { border-bottom: none; }

.lc-table td {
  padding: 13px 12px;
  vertical-align: middle;
}

.lc-id {
  font-weight: 700;
  color: var(--muted);
  width: 60px;
  font-variant-numeric: tabular-nums;
}

.lc-prob-title { font-weight: 500; }

.diff-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-easy   { background: #dcfce7; color: #15803d; }
.badge-medium { background: #fef9c3; color: #a16207; }
.badge-hard   { background: #fee2e2; color: #b91c1c; }

.lang-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-right: 4px;
}

.lang-java { background: #fef3c7; color: #92400e; }
.lang-py   { background: #e0f2fe; color: #0369a1; }
.lang-py3  { background: #ede9fe; color: #6d28d9; }

.lc-view-btn {
  padding: 5px 12px;
  border: 1.5px solid var(--primary);
  border-radius: 7px;
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.lc-view-btn:hover { background: var(--primary); color: white; }

.lc-empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  font-size: 1rem;
}

.lc-error {
  text-align: center;
  color: #b91c1c;
  padding: 32px;
}

.lc-pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 20px;
  flex-wrap: wrap;
}

.pg-btn {
  padding: 6px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  min-width: 36px;
}

.pg-btn:hover:not([disabled]) { border-color: var(--primary); color: var(--primary); }
.pg-active { background: var(--primary); color: white !important; border-color: var(--primary); }
.pg-btn[disabled] { opacity: 0.35; cursor: not-allowed; }
.pg-ellipsis { color: var(--muted); padding: 0 4px; }

/* Modal */
.lc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lc-modal {
  background: #1a1a2e;
  border-radius: 18px;
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 40px 80px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.08);
}

.lc-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.lc-modal-id {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lc-modal-title {
  margin: 0;
  font-size: 1.25rem;
  color: #f1f5f9;
  font-weight: 700;
}

.lc-modal-close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 16px;
  transition: background 0.15s, color 0.15s;
}

.lc-modal-close:hover { background: rgba(255,255,255,0.16); color: #f1f5f9; }

.lc-modal-tabs {
  display: flex;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.modal-tab {
  padding: 12px 18px;
  border: none;
  background: transparent;
  color: #64748b;
  font-family: 'SFMono-Regular', monospace;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: -1px;
}

.modal-tab:hover { color: #cbd5e1; }
.modal-tab.active { color: #7dd3fc; border-bottom-color: #7dd3fc; }

.lc-modal-code {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.lc-modal-code pre {
  margin: 0;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.65;
}

.lc-modal-code pre[class*="language-"] {
  background: #0d1117 !important;
  border: 1px solid rgba(255,255,255,0.06);
}

.lc-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

.lc-modal-leetcode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 9px;
  background: var(--primary);
  color: white;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s;
}

.lc-modal-leetcode-btn:hover { background: var(--primary-dark); }

@media (max-width: 640px) {
  .lc-header { padding: 20px; }
  .lc-table-wrap { padding: 0 8px; }
  .lc-modal-header { padding: 16px; }
  .lc-modal-code { padding: 12px 14px; }
  .lc-modal-footer { padding: 12px 14px; }
  .lc-modal-tabs { padding: 0 14px; }
}

