:root {
  --accent: #ff2ee6;
  --accent-dim: #b91fb0;
  --bg: #030308;
  --surface: #0d0d17;
  --surface2: #14141f;
  --border: #232336;
  --text: #f8f8ff;
  --text-secondary: #9ca3d4;
  --success: #39ff88;
  --warning: #ffe600;
  --error: #ff2b5e;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  height: 100%;
}

body {
  background:
    radial-gradient(circle at 15% 0%, rgba(255,46,230,0.08), transparent 40%),
    radial-gradient(circle at 90% 20%, rgba(57,255,136,0.05), transparent 35%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login ---------- */
#login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 100;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 320px;
  text-align: center;
  box-shadow: 0 0 60px rgba(255,46,230,0.08);
}
.login-card h1 {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
  background: linear-gradient(90deg, var(--accent), #7c5cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-card p { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 1.5rem; }
.login-card input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 0.9rem;
}
.login-card input:focus { outline: 1px solid var(--accent); }
.login-card button {
  width: 100%;
  padding: 0.7rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #14000f;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}
.login-card button:hover { background: #ff53ea; }
#login-error { color: var(--error); font-size: 0.82rem; min-height: 1.2em; margin-top: 0.6rem; }

/* ---------- App layout ---------- */
#app { display: none; min-height: 100vh; }
#app.visible { display: flex; }

.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: rgba(13,13,23,0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem;
  z-index: 20;
}
.topbar .brand {
  font-weight: 700; font-size: 1.05rem;
  background: linear-gradient(90deg, var(--accent), #7c5cff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topbar .actions { display: flex; align-items: center; gap: 0.75rem; }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: 8px; padding: 0.4rem 0.6rem; cursor: pointer; font-size: 0.85rem;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }

.sidebar {
  position: fixed; top: 56px; bottom: 0; left: 0; width: 250px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem 0.6rem;
  transition: transform 0.2s ease;
  z-index: 15;
}
.sidebar a.section-link {
  display: block;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}
.sidebar a.section-link:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.sidebar a.section-link.active {
  background: rgba(255,46,230,0.12);
  color: var(--text);
  border-left: 3px solid var(--accent);
}

.main {
  margin-left: 250px;
  margin-top: 56px;
  padding: 1.8rem 2rem 4rem;
  flex: 1;
  width: 100%;
  min-width: 0;
}

.breadcrumbs { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 1.2rem; }
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs .sep { margin: 0 0.35rem; }

h1.page-title { font-size: 1.5rem; margin: 0 0 1.4rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.9rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  display: flex; flex-direction: column; gap: 0.4rem;
  position: relative;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .card-icon { font-size: 1.6rem; }
.card .card-thumb {
  width: 100%; height: 90px; object-fit: cover;
  border-radius: 6px; background: var(--surface2);
}
.card .card-preview {
  width: 100%; height: 90px;
  margin: 0; padding: 0.5rem 0.6rem;
  background: var(--surface2);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.62rem;
  line-height: 1.35;
  color: var(--text-secondary);
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  position: relative;
}
.card .card-preview::after {
  content: "";
  position: absolute; bottom: 0; left: 0; right: 0; height: 24px;
  background: linear-gradient(transparent, var(--surface2));
}
.card .card-name { font-size: 0.88rem; word-break: break-word; }
.card .card-meta { font-size: 0.72rem; color: var(--text-secondary); }
.card-delete {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(3,3,8,0.75); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer; font-size: 0.95rem;
  line-height: 1; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}
.card:hover .card-delete { opacity: 1; }
.card-delete:hover { color: var(--error); border-color: var(--error); }
@media (max-width: 860px) {
  .card-delete { opacity: 1; } /* always visible on touch devices */
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 3rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}
.empty-state .big { font-size: 2rem; margin-bottom: 0.6rem; }

.file-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.file-view pre {
  background: var(--surface2);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.file-view img { max-width: 100%; border-radius: 8px; }
.file-view.markdown h1, .file-view.markdown h2, .file-view.markdown h3 { color: var(--text); }
.file-view.markdown blockquote {
  border-left: 3px solid var(--accent);
  margin: 0; padding-left: 1em; color: var(--text-secondary);
}
.file-view.markdown code {
  background: var(--surface2); padding: 0.15em 0.4em; border-radius: 4px;
}
.file-view.markdown table { border-collapse: collapse; width: 100%; }
.file-view.markdown td, .file-view.markdown th { border: 1px solid var(--border); padding: 0.4em 0.7em; }

.toolbar { display: flex; gap: 0.6rem; margin-bottom: 1.2rem; flex-wrap: wrap; align-items: center; }
.btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 0.55rem 0.9rem; cursor: pointer; font-size: 0.85rem;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #14000f; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: #ff53ea; }
.btn.danger { color: var(--error); }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover { border-color: var(--accent); background: rgba(255,46,230,0.06); }
.dropzone .big { font-size: 2rem; margin-bottom: 0.5rem; }

#toast {
  position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 50;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.toast-item {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 0.7rem 1rem; border-radius: 8px; font-size: 0.85rem; min-width: 200px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.toast-item.success { border-color: var(--success); }
.toast-item.error { border-color: var(--error); }

/* mobile */
.hamburger { display: none; }
@media (max-width: 860px) {
  .hamburger { display: inline-block; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 1.4rem 1rem 4rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
