@import url('https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@600;700;800&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #14181c;
  --surface: #1c2126;
  --surface-2: #23292f;
  --border: #2c3339;
  --accent: #ff7a30;
  --accent-dim: #ff7a3022;
  --text: #eef1f3;
  --muted: #8b949e;
  --danger: #e5534b;
  --radius: 10px;
  --grid-line: #ffffff08;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3 {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
  text-transform: uppercase;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

button {
  font-family: inherit;
}

::selection { background: var(--accent-dim); color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(20,24,28,0.97), rgba(20,24,28,0.88));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.topbar .brand .dot {
  width: 9px;
  height: 9px;
  background: var(--accent);
  border-radius: 2px;
  display: inline-block;
  transform: rotate(45deg);
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--muted);
  padding: 14px 18px 4px;
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .current { color: var(--text); }

/* ---------- Grid layout ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 4px 18px 60px;
}

.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 22px 2px 10px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

/* Folder card */
.folder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.folder-card:hover, .folder-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  outline: none;
}
.folder-card .icon {
  width: 34px; height: 26px;
  position: relative;
}
.folder-card .icon svg { width: 100%; height: 100%; }
.folder-card .name {
  font-weight: 600;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.folder-card .count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}

/* File card */
.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.file-card:hover, .file-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  outline: none;
}
.file-card .thumb {
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.file-card .thumb canvas { width: 100%; height: 100%; display: block; }
.file-card .thumb .loading-spin {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.file-card .meta {
  padding: 10px 12px 12px;
}
.file-card .name {
  font-weight: 500;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-card .size {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Buttons / inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0f06;
  font-weight: 600;
}
.btn-primary:hover { background: #ff8a48; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: #e5534b1a; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input[type="text"], input[type="password"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); color: #ffb4ae; }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
  .container { padding: 4px 12px 50px; }
  .topbar { padding: 12px 14px; }
}
