:root {
    --primary-color: #3498db;
    --secondary-color: #2980b9;
    --bg-color: #f8f9fa;
    --text-color: #333;
    --sidebar-width: 300px;
    --header-height: 60px;
    --border-color: #ddd;
  }
  
  * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }
  
  header {
    background-color: var(--primary-color);
    color: white;
    padding: 0 20px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 10;
  }
  
  header h1 {
    font-size: 1.5rem;
    font-weight: 500;
  }

  /* Always hide raw filename in header to reduce clutter */
  #file-title {
    display: none !important;
  }

  /* Breadcrumbs */
  .breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
    overflow: hidden;
    white-space: nowrap;
  }
  .breadcrumb-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 0.9rem;
  }
  .breadcrumb-link:hover {
    text-decoration: underline;
  }
  .breadcrumb-sep {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
  }
  .breadcrumb-current {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    max-width: 35vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .search-container {
    display: flex;
    align-items: center;
  }
  
  #search {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    margin-right: 10px;
    width: 200px;
  }
  
  .main-container {
    display: flex;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
  }
  
  .sidebar {
    width: var(--sidebar-width);
    background-color: white;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 0;
    flex-shrink: 0;
  }
  
  .category {
    margin-bottom: 10px;
  }
  
  .category-header {
    padding: 10px 15px;
    background-color: #eee;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
  }
  
  .category-header:hover {
    background-color: #e0e0e0;
  }
  
  .category-content {
    display: block;
  }
  
  .file-item {
    padding: 8px 15px 8px 25px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: block;
    text-decoration: none;
    color: var(--text-color);
  }
  
  .file-item:hover {
    background-color: #f0f0f0;
  }
  
  .file-item.active {
    background-color: #e6f2ff;
    border-left: 4px solid var(--primary-color);
    padding-left: 21px;
  }
  
  .file-title {
    font-weight: 500;
    display: block;
  }
  
  .file-path {
    font-size: 0.8rem;
    color: #666;
    display: block;
    word-break: break-all;
  }
  
  .content {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: white;
  }
  
  .content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 10px 0;
  }
  
  .content .image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
  }
  
  .content .image-item {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    transition: box-shadow 0.3s ease;
  }
  
  .content .image-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  }
  
  .content .image-item img {
    width: 100%;
    max-width: 250px;
    height: auto;
    border-radius: 6px;
    margin-bottom: 10px;
    cursor: pointer;
  }
  
  .content .image-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    font-size: 14px;
  }
  
  .content .image-description {
    color: #666;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 8px;
  }
  
  .content .image-filename {
    color: #888;
    font-size: 12px;
    font-family: monospace;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
  }
  
  .content table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
  }
  
  /* Responsive tables: enable horizontal scroll without shifting header */
  .content .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .content th, .content td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
  }
  
  /* Better wrapping to avoid horizontal overflow on mobile */
  .content th,
  .content td {
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  
  .content th {
    background-color: #f2f2f2;
  }
  
  .content tr:nth-child(even) {
    background-color: #f9f9f9;
  }
  
  .content h1, .content h2, .content h3 {
    margin-top: 20px;
    margin-bottom: 10px;
  }
  
  .content p {
    margin-bottom: 15px;
  }
  
  .content ul, .content ol {
    margin-left: 20px;
    margin-bottom: 15px;
  }
  
  .content code {
    background-color: #f4f4f4;
    color: #333;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    border: 1px solid #e0e0e0;
  }
  
  .content pre {
    position: relative;
    background-color: #282c34;
    color: #abb2bf;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 15px;
    border: 1px solid #3e4451;
  }
  
  .content pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    border: none;
  }
  
  .hidden {
    display: none;
  }
  
  .toggle-icon {
    transition: transform 0.3s ease;
  }
  
  .toggle-icon.collapsed {
    transform: rotate(-90deg);
  }
  
  /* Copy button styles */
  .code-block-container {
    position: relative;
    margin-bottom: 15px;
  }
  
  .copy-button {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: #3e4451;
    border: 1px solid #5c6370;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    color: #abb2bf;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 5;
  }
  
  .copy-button:hover {
    background-color: #4b5363;
    color: #ffffff;
    border-color: #6c7583;
  }
  
  .copy-button.copied {
    background-color: #98c379;
    color: #282c34;
    border-color: #98c379;
  }
  
  .copy-button svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
  }
  
  /* Mermaid diagram styles */
  .mermaid-container {
    position: relative;
    margin-bottom: 15px;
  }
  
  .mermaid-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 10;
  }
  
  .mermaid-btn {
    background-color: #3e4451;
    border: 1px solid #5c6370;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    color: #abb2bf;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  
  .mermaid-btn:hover {
    background-color: #4b5363;
    color: #ffffff;
    border-color: #6c7583;
  }
  
  .mermaid-btn.active {
    background-color: #61afef;
    color: #282c34;
    border-color: #61afef;
  }
  
  .mermaid-diagram {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    display: none;
  }
  
  .mermaid-editor {
    background-color: #282c34;
    color: #abb2bf;
    border: 1px solid #3e4451;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    width: 100%;
    min-height: 200px;
    resize: vertical;
    display: none;
    outline: none;
  }
  
  .mermaid-error {
    background-color: #2d1b1b;
    color: #e06c75;
    border: 1px solid #5c2626;
    border-radius: 8px;
    padding: 16px;
    font-family: monospace;
    font-size: 14px;
    display: none;
  }
  
  /* Pulsing animation for save edits button */
  @keyframes pulse {
    0% {
      transform: scale(1);
      box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7);
    }
    70% {
      transform: scale(1.05);
      box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
    }
    100% {
      transform: scale(1);
      box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
    }
  }
  
  @media (max-width: 768px) {
    .main-container {
      flex-direction: row; /* keep default row so content fills height */
      height: calc(100vh - var(--header-height));
    }
    
    .sidebar {
      position: fixed;
      top: var(--header-height);
      left: 0;
      height: calc(100vh - var(--header-height));
      width: 85%;
      max-width: 320px;
      max-height: none;
      transform: translateX(-100%);
      transition: transform 0.3s ease;
      z-index: 9999;
      padding-bottom: 120px;
    }
    
    .content {
      max-height: none;
      height: calc(100vh - var(--header-height));
    }
    
    header {
      flex-direction: row;
      align-items: center;
      justify-content: flex-start;
      height: var(--header-height);
      padding: 0 10px;
      position: relative;
      width: 100vw;
      box-sizing: border-box;
    }
    
    header > div:first-child {
      width: auto;
      margin-bottom: 0;
      flex-wrap: nowrap;
      justify-content: flex-start;
    }
    
    #file-title {
      display: none !important; /* keep header compact on mobile */
    }

    /* Hide breadcrumbs on mobile to keep header compact */
    .breadcrumbs {
      display: none !important;
    }
    
    #edit-file {
      display: none !important; /* hide editing on mobile */
    }
    
    .search-container {
      width: 100%;
      margin-top: 0;
      flex-wrap: wrap;
      gap: 10px;
      justify-content: center;
    }
    
    #search {
      flex: 1;
      min-width: 200px;
    }
    
    #enable-editing {
      flex-shrink: 0;
    }
    
    #save-edits {
      flex-shrink: 0;
    }
    
    #file-editor {
      height: calc(100vh - var(--header-height) - 20px);
    }
    
    #file-content-editor {
      height: calc(100% - 60px);
    }
    
    .content .image-gallery {
      grid-template-columns: 1fr;
      gap: 15px;
    }
    
    .content .image-item {
      padding: 10px;
    }
    
    .content .image-item img {
      max-width: 200px;
    }
    
    /* Hide header search; drawer will contain it on mobile */
    header .search-container {
      display: none !important;
    }
    
    /* Show hamburger on mobile */
    #menu-toggle {
      display: inline-block;
      position: absolute;
      top: 8px;
      right: 10px;
    }
  }
  
  .content .gallery-view {
    max-width: 100%;
  }
  
  .content .gallery-view h1 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
  }
  
  .content .single-image-view {
    max-width: 100%;
  }
  
  .content .single-image-view h1 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    text-align: center;
  }
  
  .content .single-image-view .image-item {
    border: 2px solid var(--border-color);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  }
  
  .content .no-images {
    text-align: center;
    padding: 40px 20px;
    color: #666;
  }
  
  .content .no-images h1 {
    color: var(--primary-color);
  }
  
  .content .single-pdf-view {
    max-width: 100%;
  }
  
  .content .single-pdf-view h1 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    text-align: center;
  }
  
  .content .no-files {
    text-align: center;
    padding: 40px 20px;
    color: #666;
  }
  
  .content .no-files h1 {
    color: var(--primary-color);
  }
  
  #copy-markdown-btn {
    margin-left: 10px;
    padding: 8px 12px;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: none;
    transition: background-color 0.2s ease;
  }

  #copy-markdown-btn:hover {
    background-color: #34495e;
  }
  
  /* Open state for mobile drawer */
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  
  body.sidebar-open #sidebar-overlay {
    display: block;
  }
  
  .content a.internal-doc-link {
    color: #0056b3;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px dotted #0056b3;
    transition: all 0.2s ease-in-out;
  }
  
  .content a.internal-doc-link:hover {
    background-color: #e6f2ff;
    border-bottom-style: solid;
    color: var(--primary-color);
  }
  
  .inline-copy-btn {
    background: none;
    border: 1px solid #ccc;
    color: #555;
    cursor: pointer;
    padding: 1px 6px;
    font-size: 12px;
    border-radius: 4px;
    margin-right: 5px;
    vertical-align: middle;
    opacity: 0.6;
    transition: all 0.2s ease;
    line-height: 1;
  }

  .inline-copy-btn:hover {
    opacity: 1;
    background-color: #f0f0f0;
    border-color: #999;
  }

  .inline-copy-btn:disabled {
    cursor: default;
  }

  .inline-copy-btn.copied {
    opacity: 1;
    background-color: #28a745;
    color: white;
    border-color: #28a745;
  }
  
  /* Mobile hamburger + off-canvas sidebar */
  #menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 8px 10px;
    margin-left: 10px;
    z-index: 10000;
  }
  
  #sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9998;
  }
  
  .mobile-search {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 1;
  }
  
  .mobile-search input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
  }
  
  /* Hide editing controls in mobile drawer */
  .mobile-search #enable-editing,
  .mobile-search #save-edits {
    display: none !important;
  }