:root {
  --bg: #0f1720;
  --panel: #17212b;
  --panel-2: #1e2a37;
  --border: #2a3b4a;
  --text: #e6edf3;
  --muted: #90a4b7;
  --accent: #3aa0ff;
  --accent-2: #2ecf88;
  --danger: #ff5c5c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.3rem; margin: 0 0 6px; }
.login-card p.sub { color: var(--muted); margin: 0 0 22px; font-size: 0.9rem; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

input, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 16px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-primary { background: var(--accent); color: #04121f; width: 100%; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #200; }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; }

.error-msg { color: var(--danger); font-size: 0.85rem; margin: -8px 0 14px; min-height: 18px; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar .brand { font-weight: 700; }
.topbar .brand span { color: var(--accent); }
.topbar .user-info { display: flex; align-items: center; gap: 14px; font-size: 0.9rem; color: var(--muted); }
.pill {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
}

.container { max-width: 1000px; margin: 0 auto; padding: 28px 20px; }

.search-bar { display: flex; gap: 8px; margin-bottom: 18px; }
.search-bar input { margin-bottom: 0; flex: 1; min-width: 0; }
.search-bar button { width: auto; white-space: nowrap; flex-shrink: 0; }

.row .path-hint { color: var(--muted); font-size: 0.78rem; display: block; margin-top: 2px; }

.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 18px; font-size: 0.9rem; }
.breadcrumb .crumb { color: var(--muted); cursor: pointer; }
.breadcrumb .crumb:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .crumb.current { color: var(--text); cursor: default; }

.list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--panel-2); }
.row .icon { font-size: 1.1rem; width: 22px; text-align: center; }
.row .name { flex: 1; cursor: pointer; }
.row.folder .name:hover { color: var(--accent); }
.row .meta { color: var(--muted); font-size: 0.8rem; min-width: 100px; text-align: right; }

.empty-state { color: var(--muted); padding: 40px; text-align: center; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab-btn {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
}
.tab-btn.active { background: var(--accent); color: #04121f; border-color: var(--accent); }

.section-title { display: flex; justify-content: space-between; align-items: center; margin: 24px 0 12px; }
.section-title h2 { font-size: 1.05rem; margin: 0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 420px; }
.modal h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.hidden { display: none !important; }


/* ===== Login split layout (added) ===== */
.login-body { min-height: 100vh; }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.login-story {
  background:
    radial-gradient(circle at 15% 15%, rgba(58,160,255,0.10), transparent 45%),
    var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 48px;
}
.login-story-inner { max-width: 420px; }

.brand-mark { margin-bottom: 22px; }

.login-story h1 {
  font-size: 2rem;
  line-height: 1.15;
  font-weight: 650;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

.story-lead {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
  max-width: 34ch;
  margin: 0 0 32px;
}

.story-stats { display: flex; gap: 32px; margin-bottom: 36px; }
.story-stat { display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-size: 1.35rem; font-weight: 650; color: var(--text); }
.stat-label { font-size: 0.78rem; color: var(--muted); }

.story-stack { opacity: 0.9; }

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.login-card { width: 100%; max-width: 380px; padding: 32px; }
.login-card-head { margin-bottom: 26px; }
.login-card-head h2 { font-size: 1.25rem; margin: 0 0 6px; font-weight: 650; }
.login-card-head .sub { color: var(--muted); margin: 0; font-size: 0.88rem; line-height: 1.5; }

.field { margin-bottom: 16px; }
.field label { margin-bottom: 6px; }

.input-wrap { position: relative; }
.input-wrap .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.input-wrap input {
  padding-left: 36px;
  margin-bottom: 0;
}
.input-wrap input#password { padding-right: 40px; }

.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 6px;
  color: var(--muted);
  display: flex;
}
.pw-toggle:hover { color: var(--text); }

.error-msg:empty { min-height: 0; margin: 0; }
.error-msg:not(:empty) {
  background: rgba(255, 92, 92, 0.1);
  border: 1px solid rgba(255, 92, 92, 0.3);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 4px 0 16px;
  font-size: 0.83rem;
}

#submitBtn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-spinner {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(4, 18, 31, 0.35);
  border-top-color: #04121f;
  border-radius: 50%;
  margin-left: 8px;
  animation: spin 0.7s linear infinite;
}
#submitBtn.is-loading .btn-spinner { display: inline-block; }
#submitBtn.is-loading { opacity: 0.85; cursor: default; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-footnote {
  margin: 18px 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-story { display: none; }
  .login-panel { padding: 40px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-spinner { animation: none; }
}


/* ===== Explorer + Admin refinements (added) ===== */
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon { flex-shrink: 0; }

.user-info a { padding: 4px 2px; }
.user-info #userEmail { color: var(--text); }

.input-wrap { position: relative; }
.input-wrap .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-wrap { flex: 1; min-width: 0; }
.search-wrap input { padding-left: 34px; margin-bottom: 0; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .empty-spinner { animation: none; } }

.row { transition: background 0.12s ease; }
.row .icon { color: var(--muted); }
.row.folder .icon { color: var(--accent); opacity: 0.85; }

.breadcrumb .crumb { transition: color 0.12s ease; }

/* Tabs as segmented control */
.tabs {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  display: inline-flex;
  gap: 2px;
}
.tab-btn {
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.85rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab-btn.active { background: var(--accent); color: #04121f; border-color: transparent; }
.tab-btn:not(.active):hover { color: var(--text); }

.index-status { color: var(--muted); font-size: 0.85rem; margin: -4px 0 20px; }

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.table-wrap table { border: none; }
.table-wrap thead th {
  background: var(--panel-2);
  position: sticky;
  top: 0;
}
.table-wrap tbody tr:hover { background: var(--panel-2); }
.table-wrap tr:last-child td { border-bottom: none; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}
.checkbox-row input { width: auto; margin: 0; }

.pw-hint { color: var(--muted); font-weight: 400; font-size: 0.8rem; }

.modal-backdrop { backdrop-filter: blur(2px); }
.modal { box-shadow: 0 12px 40px rgba(0,0,0,0.35); }
.modal label { margin-top: 12px; }
.modal label:first-of-type { margin-top: 0; }

input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ===== Ambient canvas (login) ===== */
.login-story { position: relative; overflow: hidden; }
.story-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.login-story-inner { position: relative; z-index: 1; }

/* ===== Explorer file grid (header + rows share one CSS Grid template) ===== */
.file-grid { display: flex; flex-direction: column; }
.file-grid-header,
.file-grid .row {
  display: grid;
  grid-template-columns: 1fr 110px;
  align-items: center;
  column-gap: 12px;
  padding: 12px 16px;
}
.file-grid-header {
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}
.file-grid-body .row { border-bottom: 1px solid var(--border); }
.file-grid-body .row:last-child { border-bottom: none; }
.file-grid-body .row.folder { cursor: pointer; }
.file-grid-body .row.folder:hover { background: var(--panel-2); }
.file-grid-body .row.empty-state {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 40px 16px;
}

.name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.name-cell .icon { color: var(--muted); flex-shrink: 0; display: flex; }
.file-grid .row.folder .name-cell .icon { color: var(--accent); opacity: 0.9; }
.name-cell .name { display: flex; flex-direction: column; min-width: 0; }
.name-cell .name,
.name-cell .name-line,
.name-cell .path-hint { overflow-wrap: anywhere; }

.name-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.type-tag {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}

.action-cell { display: flex; justify-content: flex-end; }
.row-chevron { color: var(--muted); display: inline-flex; }



/* ===== Explorer full-page ambient background (restored) ===== */
.explorer-body { position: relative; }
.bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.explorer-body .topbar,
.explorer-body .container { position: relative; z-index: 1; }
.explorer-body .topbar { background: rgba(23, 33, 43, 0.85); backdrop-filter: blur(6px); }
.explorer-body .table-wrap { background: rgba(23, 33, 43, 0.55); backdrop-filter: blur(4px); }

/* ===== Breadcrumb with icons (restored) ===== */
.breadcrumb .crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb .crumb svg { flex-shrink: 0; opacity: 0.85; }
