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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-form {
  background: #16213e;
  padding: 2rem;
  border-radius: 8px;
  text-align: center;
}

.login-form h2 {
  margin-bottom: 1rem;
}

.login-form input {
  display: block;
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: none;
  border-radius: 4px;
  background: #1a1a2e;
  color: #eee;
}

.login-form button {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 4px;
  background: #e94560;
  color: #fff;
  cursor: pointer;
}

.login-form button:hover {
  background: #ff6b6b;
}

/* Main Layout */
.app {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 250px;
  background: #16213e;
  border-right: 1px solid #0f3460;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid #0f3460;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  background: #e94560;
  color: #fff;
  cursor: pointer;
}

.btn:hover {
  background: #ff6b6b;
}

.folder-tree {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.folder-item {
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.folder-item:hover {
  background: #0f3460;
}

.folder-item.active {
  background: #e94560;
}

.folder-children {
  margin-left: 1rem;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  padding: 1rem;
  border-bottom: 1px solid #0f3460;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.breadcrumb {
  display: flex;
  gap: 0.5rem;
}

.crumb {
  color: #aaa;
  cursor: pointer;
}

.crumb:hover {
  color: #fff;
}

.crumb:not(:last-child)::after {
  content: ' >';
  margin-left: 0.5rem;
}

.upload-zone {
  flex: 1;
  padding: 1rem;
  border: 2px dashed #0f3460;
  border-radius: 4px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: #e94560;
}

.file-grid {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  align-content: start;
}

.file-card {
  background: #16213e;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
}

.file-card:hover {
  transform: translateY(-2px);
}

.file-thumb {
  height: 100px;
  background: #0f3460;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-info {
  padding: 0.75rem;
}

.file-name {
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 0.75rem;
  color: #aaa;
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
}

.file-delete {
  color: #e94560;
  cursor: pointer;
}

.file-delete:hover {
  color: #ff6b6b;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #16213e;
  border-radius: 8px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 1;
}

#modal-body {
  padding: 2rem;
}

#modal-body img {
  max-width: 100%;
}

.markdown-preview {
  max-width: 800px;
  line-height: 1.6;
}

.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.markdown-preview code {
  background: #0f3460;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
}

.markdown-preview pre {
  background: #0f3460;
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
}

.code-preview {
  background: #0f3460;
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  max-width: 800px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -250px;
    height: 100%;
    z-index: 100;
    transition: left 0.3s;
  }

  .sidebar.open {
    left: 0;
  }
}
