:root {
  /* Solriva Palette */
  --color-sun: #FDBB2D;
  --color-orange: #FF6A00;
  --color-gold: #F2A922;
  --color-terracotta: #C1440E;
  --color-rust: #9B3208;
  --color-dark: #2C1810;
  --color-tan: #D4B896;
  --color-sand: #F5ECD7;
  --color-sea-light: #6AAED6;
  --color-sea: #5BB8C4;
  --color-capri: #48C9B0;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  --sidebar-width: 300px;
  --content-max-width: 900px;
}

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

body {
  font-family: var(--font-body);
  color: var(--color-dark);
  background-color: var(--color-sand);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Sidebar (Mobile Default: Hidden Drawer) --- */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--color-sun) 0%, var(--color-orange) 100%);
  color: rgba(255, 255, 255, 0.9);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  box-shadow: 10px 0 30px rgba(0,0,0,0.1);
}

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

.sidebar-header {
  margin-bottom: 2rem;
  text-align: center;
  animation: rise 0.8s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo-s {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 3.5rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.3);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.sidebar-header h1 {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.5rem;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.5);
}

#nav-links {
  flex-grow: 1;
  overflow-y: auto;
}

.nav-item {
  display: block;
  padding: 0.8rem 1rem;
  margin-bottom: 0.4rem;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-left-color: white;
}

.sidebar-footer {
  margin-top: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  letter-spacing: 1px;
}

/* --- Content Area (Mobile First) --- */
#content-area {
  flex-grow: 1;
  padding: 1.5rem;
  width: 100%;
  max-width: 100%;
}

#markdown-content {
  background: white;
  padding: 2rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
  min-height: 70vh;
}

/* Markdown Elements */
#markdown-content h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--color-rust);
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-sand);
  padding-bottom: 0.5rem;
}

#markdown-content h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--color-terracotta);
  margin: 2rem 0 1rem;
}

#markdown-content p {
  margin-bottom: 1.2rem;
  font-size: 1rem;
}

#markdown-content a {
  color: var(--color-terracotta);
  text-decoration: none;
  border-bottom: 1px dotted var(--color-terracotta);
}

#markdown-content blockquote {
  border-left: 4px solid var(--color-tan);
  padding: 1rem 1.5rem;
  background: #fdfaf4;
  font-style: italic;
  margin: 1.5rem 0;
  border-radius: 0 8px 8px 0;
}

#markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  display: block;
  overflow-x: auto;
  font-size: 0.9rem;
}

#markdown-content th, #markdown-content td {
  padding: 0.75rem;
  border: 1px solid var(--color-sand);
  text-align: left;
  min-width: 120px;
}

#markdown-content pre {
  background: #282c34;
  padding: 1.2rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.5rem 0;
}

/* Pagination */
#doc-footer {
  margin-top: 2rem;
  padding: 1.5rem 0;
}

.pagination {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.nav-btn {
  padding: 1rem;
  background: white;
  color: var(--color-terracotta);
  text-decoration: none;
  border: 1px solid var(--color-tan);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-align: center;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--color-sand);
}

/* Mobile Toggle Button */
#mobile-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1100;
  background: var(--color-terracotta);
  border: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(193, 68, 14, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

#mobile-toggle:active {
  transform: scale(0.9);
}

#mobile-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: white;
  position: relative;
}

#mobile-toggle span::before,
#mobile-toggle span::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 2px;
  background: white;
  left: 0;
  transition: transform 0.3s;
}

#mobile-toggle span::before { top: -8px; }
#mobile-toggle span::after { bottom: -8px; }

#sidebar.open ~ #mobile-toggle span { background: transparent; }
#sidebar.open ~ #mobile-toggle span::before { transform: translateY(8px) rotate(45deg); }
#sidebar.open ~ #mobile-toggle span::after { transform: translateY(-8px) rotate(-45deg); }

.hidden { display: none; }

.error-card {
  text-align: center;
  padding: 3rem;
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: 12px;
  color: #c53030;
}

.error-card h1 {
  color: #c53030;
  margin-bottom: 1rem;
}

.error-detail {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: rgba(0,0,0,0.05);
  padding: 0.5rem;
  border-radius: 4px;
  margin: 1.5rem 0;
}

.error-card button {
  background: var(--color-terracotta);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-mono);
}

/* --- Tablet / Desktop Enhancements (Min-Width) --- */
@media (min-width: 769px) {
  #app {
    flex-direction: row;
  }

  #sidebar {
    transform: translateX(0);
    position: sticky;
    box-shadow: none;
    flex-shrink: 0;
  }

  #content-area {
    padding: 3rem;
    overflow-y: auto;
  }

  #markdown-content {
    padding: 4rem;
    max-width: var(--content-max-width);
    margin: 0 auto;
  }

  #markdown-content h1 {
    font-size: 2.8rem;
  }

  .pagination {
    flex-direction: row;
    justify-content: space-between;
    max-width: var(--content-max-width);
    margin: 0 auto;
  }

  .nav-btn {
    width: auto;
    min-width: 200px;
  }

  #mobile-toggle {
    display: none;
  }
}

@media (min-width: 1200px) {
  #sidebar {
    width: 350px;
    padding: 3rem;
  }
}
