/* =========================================
   SYSTEM DESIGN HANDWRITTEN NOTES - STYLES
   Tailored for Senior / Product Engineers
   Handwritten aesthetic matching @qa_insights style
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&family=Kalam:wght@300;400;700&family=Patrick+Hand&family=Fira+Code:wght@400;500;600&display=swap');

:root {
  --paper-bg: #fbf8f1;
  --paper-pattern: #ebd8bd;
  --paper-line: rgba(190, 165, 130, 0.22);
  --spiral-metal: #7a6e5d;
  --spiral-ring: #c4b59f;
  --hole-shadow: rgba(0, 0, 0, 0.45);
  
  --ink-primary: #1e2022;
  --ink-muted: #4a4d52;
  --ink-title: #0f172a;
  
  /* Handwritten highlight colors */
  --hl-red: #d9383a;
  --hl-red-bg: #fee2e2;
  --hl-blue: #1d6fe5;
  --hl-blue-bg: #dbeafe;
  --hl-green: #15803d;
  --hl-green-bg: #dcfce7;
  --hl-purple: #7e22ce;
  --hl-purple-bg: #f3e8ff;
  --hl-yellow: #b45309;
  --hl-yellow-bg: #fef3c7;
  --hl-cyan: #0284c7;
  --hl-cyan-bg: #e0f2fe;
  --hl-orange: #c2410c;
  --hl-orange-bg: #ffedd5;
  
  --shadow-sheet: 0 15px 45px rgba(0, 0, 0, 0.4), 0 5px 15px rgba(0, 0, 0, 0.2);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Kalam', cursive;
  background: radial-gradient(circle at 50% 20%, #1e293b 0%, #0f172a 60%, #020617 100%);
  min-height: 100vh;
  color: var(--ink-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Background floating particles */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: 
    radial-gradient(circle at 15% 25%, rgba(59, 130, 246, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(147, 51, 234, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ---- App Shell ---- */
.app {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 50px;
  z-index: 1;
}

/* ---- Sticky Top Navigation Bar ---- */
.topbar {
  width: 100%;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 28px;
  animation: floatBrand 3s ease-in-out infinite alternate;
}

@keyframes floatBrand {
  0% { transform: translateY(0px) rotate(0deg); }
  100% { transform: translateY(-3px) rotate(4deg); }
}

.topbar-title {
  font-family: 'Caveat', cursive;
  font-size: 24px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 10px;
}

.author-pill {
  font-family: 'Patrick Hand', cursive;
  font-size: 13px;
  font-weight: normal;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(168, 85, 247, 0.3));
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #e9d5ff;
  padding: 2px 10px;
  border-radius: 20px;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-indicator {
  font-family: 'Patrick Hand', cursive;
  font-size: 17px;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-btn {
  font-family: 'Patrick Hand', cursive;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.35);
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.home-link-btn {
  font-family: 'Caveat', cursive;
  font-size: 16px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 5px 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.home-link-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: #38bdf8;
  color: #38bdf8;
  transform: translateY(-1px);
}

.drawer-toggle-btn {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(168, 85, 247, 0.3));
  border-color: rgba(168, 85, 247, 0.45);
  color: #e9d5ff;
}

.drawer-toggle-btn:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.45), rgba(168, 85, 247, 0.45));
  border-color: #c084fc;
}

.pdf-btn {
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  border: none;
  font-weight: bold;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

.pdf-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #4338ca, #7e22ce);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.6);
}

/* =========================================
   TOPIC SIDENAV DRAWER (SLIDE-OVER)
   ========================================= */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 360px;
  max-width: 88vw;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(2, 6, 23, 0.98) 100%);
  border-right: 1px solid rgba(168, 85, 247, 0.25);
  box-shadow: 10px 0 40px rgba(0, 0, 0, 0.6);
  z-index: 999;
  transform: translateX(-100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  color: #f8fafc;
  overflow: hidden;
}

.sidebar-drawer.open {
  transform: translateX(0);
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
}

.sidebar-home-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #f8fafc;
  font-family: 'Caveat', cursive;
  font-size: 22px;
  font-weight: 700;
  transition: all 0.2s ease;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-home-link:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #38bdf8;
  transform: translateY(-1px);
}

.sidebar-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 22px;
  line-height: 1;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.sidebar-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.sidebar-section {
  padding: 14px 18px 6px;
}

.section-label {
  font-family: 'Patrick Hand', cursive;
  font-size: 12px;
  letter-spacing: 1px;
  color: #94a3b8;
  margin-bottom: 8px;
  font-weight: 600;
}

/* Notebook Switcher Grid */
.notebook-switcher-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.switcher-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  text-decoration: none;
  color: #e2e8f0;
  transition: all 0.2s ease;
}

.switcher-card:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.switcher-card.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(168, 85, 247, 0.35));
  border-color: #c084fc;
  color: #fff;
  box-shadow: 0 0 12px rgba(192, 132, 252, 0.25);
}

.switcher-icon {
  font-size: 20px;
}

.switcher-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.switcher-title {
  font-family: 'Caveat', cursive;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.switcher-pages {
  font-family: 'Patrick Hand', cursive;
  font-size: 11px;
  color: #94a3b8;
}

/* Search Box */
.sidebar-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.sidebar-search-box .search-icon {
  position: absolute;
  left: 10px;
  font-size: 14px;
  pointer-events: none;
  opacity: 0.6;
}

.sidebar-search-box input {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 32px 8px 32px;
  font-family: 'Kalam', cursive;
  font-size: 14px;
  color: #f8fafc;
  outline: none;
  transition: all 0.2s ease;
}

.sidebar-search-box input:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.clear-search-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

/* Topics List */
.sidebar-topics-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-topic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: #f1f5f9;
}

.sidebar-topic-item:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateX(4px);
}

.sidebar-topic-item.active {
  background: rgba(168, 85, 247, 0.2);
  border-color: #c084fc;
  box-shadow: 0 0 12px rgba(192, 132, 252, 0.25);
}

.topic-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topic-num-badge {
  font-family: 'Caveat', cursive;
  font-size: 14px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  color: #cbd5e1;
  flex-shrink: 0;
}

.sidebar-topic-item.active .topic-num-badge {
  background: #c084fc;
  color: #0f172a;
}

.topic-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topic-title {
  font-family: 'Caveat', cursive;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-subtitle {
  font-family: 'Patrick Hand', cursive;
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-tag-pill {
  font-family: 'Patrick Hand', cursive;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
  margin-left: 8px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.sidebar-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: 'Caveat', cursive;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-action-btn.pdf-btn {
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  color: #fff;
  border-color: #a855f7;
}

.sidebar-action-btn.home-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

.sidebar-action-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.15);
}

/* ---- Dot Navigation ---- */
.dot-nav {
  display: flex;
  gap: 8px;
  margin: 18px 0 10px;
}

.dot {
  width: 32px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.dot.active {
  background: #a855f7;
  width: 48px;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.6);
}

.dot:hover:not(.active) {
  background: rgba(255, 255, 255, 0.45);
}

/* ---- Table of Contents Modal ---- */
.toc-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.toc-modal.open {
  display: flex;
}

.toc-card {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  color: #f8fafc;
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.toc-header h3 {
  font-family: 'Caveat', cursive;
  font-size: 26px;
  color: #38bdf8;
}

.toc-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toc-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toc-item:hover {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.4);
  transform: translateX(4px);
}

.toc-num {
  font-family: 'Caveat', cursive;
  font-size: 20px;
  font-weight: bold;
  color: #c084fc;
  min-width: 36px;
}

.toc-text {
  font-family: 'Patrick Hand', cursive;
  font-size: 17px;
  color: #e2e8f0;
}

/* ---- Notebook Page Container ---- */
.notebook-container {
  width: 100%;
  max-width: 980px;
  margin-top: 10px;
}

.notebook-page {
  display: none;
  width: 100%;
  background: var(--paper-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-sheet);
  position: relative;
  overflow: hidden;
  border: 1px solid #d5c8b2;
}

.notebook-page.active {
  display: block;
  animation: pageSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pageSlideIn {
  0% { opacity: 0; transform: translateY(12px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.notebook-inner {
  display: flex;
  min-height: 1280px;
  position: relative;
}

/* Left Spiral Holes & Ring Binding */
.spiral-holes {
  width: 60px;
  background: #f4ede0;
  border-right: 2px solid #dfd3bf;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  padding: 30px 0;
  position: relative;
  flex-shrink: 0;
}

.hole {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1e1e24;
  box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.8), 0 0 0 3px #d8ccb8;
  position: relative;
}

.hole::after {
  content: '';
  position: absolute;
  top: -8px;
  left: 2px;
  width: 24px;
  height: 10px;
  border: 3px solid var(--spiral-ring);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  transform: rotate(-25deg);
  pointer-events: none;
}

/* Page Content on Ruled Paper */
.page-content {
  flex: 1;
  padding: 32px 38px 40px 32px;
  background-image: repeating-linear-gradient(
    transparent,
    transparent 31px,
    var(--paper-line) 31px,
    var(--paper-line) 32px
  );
  background-attachment: local;
  position: relative;
}

/* Header Elements */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.watermark-tag {
  font-family: 'Patrick Hand', cursive;
  font-size: 16px;
  color: #334155;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.04);
  padding: 2px 10px;
  border-radius: 6px;
  border: 1px dashed rgba(0, 0, 0, 0.15);
}

.page-num {
  font-family: 'Caveat', cursive;
  font-size: 17px;
  font-weight: 700;
  color: #475569;
  background: #e2e8f0;
  padding: 2px 12px;
  border-radius: 14px;
  box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.1);
}

/* Main Page Title */
.page-title {
  font-family: 'Caveat', cursive;
  font-size: 42px;
  font-weight: 700;
  color: var(--ink-title);
  text-align: center;
  margin: 4px 0 16px;
  position: relative;
  line-height: 1.15;
}

.title-underline {
  display: block;
  width: 220px;
  height: 4px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
  border-radius: 2px;
  margin: 4px auto 0;
}

/* Section Header with Circled Number */
.section-block {
  margin-bottom: 20px;
  position: relative;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sec-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Caveat', cursive;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  background: #0f172a;
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.sec-num.green { background: var(--hl-green); }
.sec-num.blue { background: var(--hl-blue); }
.sec-num.purple { background: var(--hl-purple); }
.sec-num.red { background: var(--hl-red); }
.sec-num.yellow { background: var(--hl-yellow); }

.section-title {
  font-family: 'Caveat', cursive;
  font-size: 26px;
  font-weight: 700;
  color: var(--ink-title);
  border-bottom: 2px dashed rgba(0, 0, 0, 0.12);
  padding-bottom: 2px;
  flex: 1;
}

/* Highlight Tokens */
.highlight-red { color: var(--hl-red); font-weight: 600; }
.highlight-blue { color: var(--hl-blue); font-weight: 600; }
.highlight-green { color: var(--hl-green); font-weight: 600; }
.highlight-purple { color: var(--hl-purple); font-weight: 600; }
.highlight-yellow { color: var(--hl-yellow); font-weight: 600; }
.highlight-cyan { color: var(--hl-cyan); font-weight: 600; }
.highlight-orange { color: var(--hl-orange); font-weight: 600; }

.badge-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 14px;
  font-family: 'Patrick Hand', cursive;
}
.badge-pill.blue { background: var(--hl-blue-bg); color: var(--hl-blue); border: 1px solid #93c5fd; }
.badge-pill.green { background: var(--hl-green-bg); color: var(--hl-green); border: 1px solid #86efac; }
.badge-pill.red { background: var(--hl-red-bg); color: var(--hl-red); border: 1px solid #fca5a5; }
.badge-pill.purple { background: var(--hl-purple-bg); color: var(--hl-purple); border: 1px solid #d8b4fe; }
.badge-pill.yellow { background: var(--hl-yellow-bg); color: var(--hl-yellow); border: 1px solid #fde68a; }

/* Handwritten Lists */
.handwritten-list {
  list-style: none;
  padding-left: 4px;
  font-family: 'Patrick Hand', cursive;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink-medium);
}

.handwritten-list li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 6px;
}

.handwritten-list li::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--hl-blue);
  font-size: 20px;
  line-height: 1;
}

.handwritten-list li.check::before {
  content: '✓';
  color: var(--hl-green);
  font-size: 15px;
  font-weight: bold;
}

/* Layout Columns */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.four-col {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

/* ---- Hand-Drawn Style Boxes & Diagrams ---- */
.hand-box {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 2px 3px 0px rgba(0, 0, 0, 0.06);
  position: relative;
}

.hand-box.glow-blue { border-color: #93c5fd; background: #f8fafc; }
.hand-box.glow-purple { border-color: #d8b4fe; background: #faf5ff; }
.hand-box.glow-green { border-color: #86efac; background: #f0fdf4; }
.hand-box.glow-amber { border-color: #fde68a; background: #fffbeb; }

.box-title {
  font-family: 'Caveat', cursive;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--ink-title);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Architecture Flow Components */
.arch-pipeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
}

.pipeline-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: 'Patrick Hand', cursive;
  font-size: 15px;
}

.pipeline-step.blue { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }
.pipeline-step.green { background: #f0fdf4; border-color: #86efac; color: #166534; }
.pipeline-step.purple { background: #faf5ff; border-color: #d8b4fe; color: #6b21a8; }
.pipeline-step.yellow { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.pipeline-step.red { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }

.flow-arrow-down {
  text-align: center;
  font-size: 16px;
  color: #64748b;
  font-weight: bold;
  margin: -4px 0;
}

/* Comparison Table with VS Badge */
.compare-container {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  margin: 8px 0;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
}

.compare-vs-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e11d48;
  color: #fff;
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 5;
  border: 2px solid #fff;
}

.compare-col {
  padding: 12px 14px;
}

.compare-col:first-child {
  border-right: 1.5px dashed #cbd5e1;
}

.compare-head {
  font-family: 'Caveat', cursive;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  padding-bottom: 6px;
  border-bottom: 1.5px solid #e2e8f0;
  margin-bottom: 8px;
}

.compare-head.blue { color: #1d4ed8; }
.compare-head.green { color: #15803d; }
.compare-head.purple { color: #7e22ce; }
.compare-head.red { color: #b91c1c; }

.compare-row {
  display: flex;
  justify-content: space-between;
  font-family: 'Patrick Hand', cursive;
  font-size: 14.5px;
  padding: 4px 0;
  border-bottom: 1px dotted #e2e8f0;
  color: #334155;
}

.compare-row:last-child {
  border-bottom: none;
}

/* Feature & Concept Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.feature-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s ease;
}

.feature-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
}

.card-icon {
  font-size: 26px;
  margin-bottom: 4px;
}

.card-title {
  font-family: 'Caveat', cursive;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-title);
  margin-bottom: 2px;
}

.card-desc {
  font-family: 'Patrick Hand', cursive;
  font-size: 13.5px;
  color: #64748b;
  line-height: 1.25;
}

/* Code & Command Snippet (Handwritten Style) */
.code-box {
  background: #1e293b;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  color: #e2e8f0;
  line-height: 1.45;
  margin: 6px 0;
  box-shadow: inset 1px 1px 4px rgba(0, 0, 0, 0.5);
  border: 1px solid #334155;
  overflow-x: auto;
}

.code-box .kw { color: #f43f5e; font-weight: 600; }
.code-box .fn { color: #38bdf8; }
.code-box .str { color: #a3e635; }
.code-box .num { color: #fbbf24; }
.code-box .cm { color: #94a3b8; font-style: italic; }

/* Remember Callout Box */
.remember-box {
  background: #fffbeb;
  border: 2px dashed #f59e0b;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 14px;
  position: relative;
}

.remember-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Caveat', cursive;
  font-size: 21px;
  font-weight: 700;
  color: #b45309;
  margin-bottom: 4px;
}

.remember-content {
  font-family: 'Patrick Hand', cursive;
  font-size: 15.5px;
  color: #78350f;
  line-height: 1.45;
}

/* Senior Interview Tip Callout */
.interview-tip {
  background: #ecfdf5;
  border: 2px solid #10b981;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 12px;
  position: relative;
}

.interview-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Caveat', cursive;
  font-size: 21px;
  font-weight: 700;
  color: #047857;
  margin-bottom: 4px;
}

.interview-body {
  font-family: 'Patrick Hand', cursive;
  font-size: 15px;
  color: #065f46;
  line-height: 1.45;
}

.interview-body strong {
  color: #047857;
}

/* Page Footer */
.page-footer {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1.5px solid rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Patrick Hand', cursive;
  font-size: 14px;
  color: #64748b;
}

/* ---- Print Styles for High-Res PDF Export ---- */
@media print {
  @page {
    size: A4 portrait;
    margin: 3mm 3mm;
  }
  
  html, body {
    background: #fff !important;
    color: #1a1a2e !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  body::before, body::after {
    display: none !important;
  }
  
  .topbar, .dot-nav, .toc-modal, .sidebar-backdrop, .sidebar-drawer {
    display: none !important;
  }
  
  .app, .notebook-container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  .notebook-page {
    display: block !important;
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    page-break-after: always !important;
    break-after: page !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    border: 1px solid #d5c8b2 !important;
    margin: 0 0 10px 0 !important;
    height: auto !important;
  }
  
  .notebook-page:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }
  
  .notebook-inner {
    min-height: auto !important;
    box-sizing: border-box !important;
  }
  
  .spiral-holes {
    width: 36px !important;
    padding: 10px 0 !important;
  }

  .hole {
    width: 11px !important;
    height: 11px !important;
  }

  .hole::after {
    width: 16px !important;
    height: 7px !important;
    top: -5px !important;
  }

  .page-content {
    padding: 8px 12px 8px 10px !important;
  }

  .page-header {
    margin-bottom: 1px !important;
  }

  .watermark-tag {
    font-size: 13px !important;
    padding: 1px 6px !important;
  }

  .page-num {
    font-size: 14px !important;
    padding: 1px 8px !important;
  }

  .page-title {
    font-size: 22px !important;
    margin: 0 0 4px !important;
    line-height: 1.05 !important;
  }

  .title-underline {
    height: 2.5px !important;
    width: 150px !important;
    margin: 1px auto 0 !important;
  }

  .section-block {
    margin-bottom: 5px !important;
  }

  .section-head {
    margin-bottom: 2px !important;
    gap: 6px !important;
  }

  .section-title {
    font-size: 17px !important;
    padding-bottom: 0 !important;
  }

  .sec-num {
    width: 18px !important;
    height: 18px !important;
    font-size: 12.5px !important;
  }

  .handwritten-list {
    font-size: 11.5px !important;
    line-height: 1.2 !important;
  }

  .handwritten-list li {
    margin-bottom: 1.5px !important;
    padding-left: 12px !important;
  }

  .handwritten-list li::before {
    font-size: 13px !important;
    left: 1px !important;
  }

  .two-col {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .three-col {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }

  .four-col {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
  }

  .feature-card {
    padding: 4px 5px !important;
    border-radius: 6px !important;
  }

  .card-icon {
    font-size: 14px !important;
    margin-bottom: 0px !important;
  }

  .card-title {
    font-size: 13px !important;
    margin-bottom: 0px !important;
  }

  .card-desc {
    font-size: 10.5px !important;
    line-height: 1.15 !important;
  }

  .remember-box, .interview-tip {
    margin-top: 4px !important;
    padding: 4px 8px !important;
    border-radius: 8px !important;
  }

  .remember-header, .interview-header {
    font-size: 14px !important;
    margin-bottom: 1px !important;
  }

  .remember-content, .interview-body {
    font-size: 11px !important;
    line-height: 1.2 !important;
  }

  .compare-container {
    border-radius: 8px !important;
    margin: 4px 0 !important;
  }

  .compare-col {
    padding: 6px 8px !important;
  }

  .compare-head {
    font-size: 13.5px !important;
    padding-bottom: 1px !important;
    margin-bottom: 2px !important;
  }

  .compare-row {
    font-size: 10.5px !important;
    padding: 1px 0 !important;
  }

  .compare-vs-badge {
    width: 20px !important;
    height: 20px !important;
    font-size: 10px !important;
  }

  .hand-box {
    padding: 5px 8px !important;
    border-radius: 8px !important;
  }

  .box-title {
    font-size: 13.5px !important;
    margin-bottom: 2px !important;
  }

  .arch-pipeline {
    gap: 2px !important;
    padding: 2px !important;
    border-radius: 6px !important;
  }

  .pipeline-step {
    padding: 2px 6px !important;
    font-size: 11px !important;
    border-radius: 6px !important;
  }

  .flow-arrow-down {
    font-size: 10.5px !important;
    margin: -1px 0 !important;
  }

  .page-footer {
    margin-top: 4px !important;
    padding-top: 2px !important;
    font-size: 10px !important;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .topbar {
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
  }

  .topbar-left {
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
  }

  .brand-icon {
    font-size: 22px;
  }

  .topbar-title {
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .author-pill {
    display: none;
  }

  .topbar-right {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
  }

  .topbar-center {
    order: 3;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .nav-btn {
    font-size: 14px;
    padding: 5px 10px;
    border-radius: 6px;
  }

  .page-indicator {
    font-size: 14px;
    padding: 3px 12px;
  }

  .notebook-container {
    padding: 6px 8px 30px;
  }

  .spiral-holes {
    width: 24px;
    min-width: 24px;
    padding: 12px 0;
  }

  .hole {
    width: 10px;
    height: 10px;
  }

  .hole::before {
    left: -6px;
    width: 14px;
    height: 4px;
  }

  .page-content {
    padding: 14px 10px 20px 12px;
  }

  .page-title {
    font-size: 24px;
  }

  .two-col, .three-col, .four-col {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .compare-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .arch-pipeline {
    flex-direction: column;
    gap: 4px;
  }

  .toc-card {
    padding: 18px;
    margin: 10px;
  }

  .toc-item {
    font-size: 15px;
    padding: 8px 10px;
  }
}

