:root {
  --bg-primary: #0d1117;
  --bg-secondary: #151b23;
  --bg-elevated: #1c2430;
  --border: #2a3441;
  --border-hover: #3d4a5c;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --accent: #4f8cff;
  --accent-hover: #6b9fff;
  --accent-dim: rgba(79, 140, 255, 0.12);
  --danger: #f85149;
  --danger-dim: rgba(248, 81, 73, 0.12);
  --success: #3fb950;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, #16202e 0%, var(--bg-primary) 55%);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: rgba(21, 27, 35, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 19px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.3px;
}

.topbar h1 i {
  color: var(--accent);
  font-size: 18px;
}

/* ===== BUTTONS ===== */
.btn, .btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 140, 255, 0.25);
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79, 140, 255, 0.35);
}

.btn:active { transform: translateY(0); }

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: #232d3a;
}

/* ===== PANEL / TOOLBAR ===== */
.panel {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 28px 60px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 4px;
}

.breadcrumb span {
  cursor: pointer;
  padding: 4px 9px;
  border-radius: 6px;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb span:hover {
  background: var(--accent-dim);
  color: var(--accent-hover);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== FILE GRID ===== */
.glass-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.file-grid {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  min-height: 200px;
}

.file-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  text-align: center;
}

.file-item:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
  transform: translateY(-2px);
}

.file-item i.fa-folder {
  font-size: 32px;
  color: var(--accent);
}

.file-item i.fa-file-lines {
  font-size: 30px;
  color: var(--text-secondary);
}

.file-item span {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.item-menu {
  position: absolute;
  top: 6px;
  right: 6px;
  opacity: 0;
  transition: opacity var(--transition);
}

.file-item:hover .item-menu {
  opacity: 1;
}

.item-menu i {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  font-size: 12px;
  transition: all var(--transition);
}

.item-menu i:hover {
  color: var(--danger);
  background: var(--danger-dim);
}

.file-grid p {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px 20px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ===== MODALS ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 13, 0.65);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal.active {
  display: flex;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  animation: slideUp 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-content h3 {
  margin: 0 0 16px;
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-content input[type="text"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color var(--transition);
}

.modal-content input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 8px 2px 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.editor-content {
  max-width: 820px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

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

.editor-header-left i {
  font-size: 15px;
  color: var(--accent);
  flex-shrink: 0;
}

#editor-filename {
  font-family: 'Inter', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.editor-copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.editor-body {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
}

#editor-textarea {
  width: 100%;
  min-height: 320px;
  height: 55vh;
  padding: 16px 18px;
  background: var(--bg-primary);
  border: none;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: none;
  outline: none;
  tab-size: 2;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.editor-stats {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-family: 'Inter', monospace;
  display: flex;
  gap: 14px;
}

.editor-content .modal-actions {
  margin: 0;
  padding: 10px 20px 16px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .panel { padding: 20px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 16px; }
  .panel { padding: 14px; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .breadcrumb { font-size: 12px; overflow-x: auto; flex-wrap: nowrap; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
  .file-item { padding: 14px 6px 10px; }
  .file-item i.fa-folder, .file-item i.fa-file-lines { font-size: 26px; }
  .file-item span { font-size: 11.5px; -webkit-line-clamp: 2; }
  .item-menu { opacity: 1; top: 4px; right: 4px; }
  .item-menu i { width: 22px; height: 22px; font-size: 11px; }
  .actions { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .btn, .btn-ghost { justify-content: center; padding: 9px 6px; font-size: 12px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-content { max-width: 100%; border-radius: 16px 16px 0 0; animation: slideUpMobile 0.22s ease; }
  .editor-content { max-height: 92vh; }
  #editor-textarea { height: 45vh; font-size: 12.5px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn, .modal-actions .btn-ghost { width: 100%; }
}

@media (max-width: 380px) {
  .actions { grid-template-columns: repeat(2, 1fr); }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}

@keyframes slideUpMobile {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}
