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

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f1117;
  color: #e6edf3;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #30363d;
  background: #161b22;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: #8b949e;
  font-size: 0.875rem;
}

#menu-toggle {
  display: none;
  flex: none;
  background: #21262d;
  border: 1px solid #30363d;
  color: #e6edf3;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

#menu-toggle:hover {
  background: #30363d;
}

main {
  position: relative;
  display: grid;
  grid-template-columns: 260px 1fr;
  height: calc(100vh - 73px);
  min-height: 0;
}

#sidebar-overlay {
  display: none;
}

#sidebar {
  border-right: 1px solid #30363d;
  background: #161b22;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #30363d;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8b949e;
}

#refresh-btn {
  background: #21262d;
  border: 1px solid #30363d;
  color: #e6edf3;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

#refresh-btn:hover {
  background: #30363d;
}

#file-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
}

#file-list li button {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #e6edf3;
  cursor: pointer;
  font-size: 0.875rem;
  font-family: ui-monospace, monospace;
}

#file-list li button:hover {
  background: #21262d;
}

#file-list li button.active {
  background: #1f6feb;
  color: #fff;
}

#empty-state {
  padding: 1rem;
  color: #8b949e;
  font-size: 0.875rem;
}

#empty-state code {
  color: #79c0ff;
}

.hidden {
  display: none;
}

#sidebar,
#viewer {
  min-height: 0;
}

#viewer {
  position: relative;
  background: #fff;
  overflow: hidden;
}

#placeholder,
#preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #57606a;
  font-size: 0.95rem;
  background: #f6f8fa;
  z-index: 1;
}

#preview {
  display: block;
  border: none;
  z-index: 2;
}

@media (max-width: 768px) {
  header {
    padding: 0.75rem 1rem;
  }

  header h1 {
    font-size: 1.05rem;
  }

  .subtitle {
    font-size: 0.8rem;
  }

  #menu-toggle {
    display: block;
  }

  main {
    grid-template-columns: 1fr;
    height: calc(100vh - 65px);
  }

  #sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    z-index: 20;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4);
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
  }

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

  #sidebar-overlay {
    display: block;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-out;
  }

  #sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  #file-list li button {
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
  }
}
