﻿:root {
  color-scheme: dark;
  --bg: #141414;
  --panel: #1d1f21;
  --panel-raised: #242629;
  --line: #383b40;
  --text: #e6e1dc;
  --muted: #88847f;
  --purple: #c397d8;
  --cyan: #70c0b1;
  --orange: #f78c6c;
  --green: #b5bd68;
  --yellow: #e6c547;
  --red: #cc6666;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background: #0e0e0e;
  font-size: 14px;
}

button { font: inherit; }

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

/* ---- App shell ---- */

.app-shell {
  width: min(100%, 620px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 60px rgba(0,0,0,0.5);
}

.app-shell-wide {
  width: min(100%, 1100px);
}

/* ---- Titlebar ---- */

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #191919;
  font-size: 11px;
}

.titlebar-left, .titlebar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-icon { color: var(--purple); font-size: 12px; }

.nav-link {
  color: var(--cyan);
  font-size: 11px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
}
.nav-link:hover { background: var(--panel-raised); text-decoration: none; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.user-avatar {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  object-fit: cover;
}

.btn-icon {
  background: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 8px;
  font-size: 13px;
}
.btn-icon:hover { color: var(--red); border-color: var(--red); }

/* ---- Login page ---- */

.login-main { padding: 0 18px 58px; }

.prompt-block { padding: clamp(40px, 10vw, 70px) 4px 28px; }

.path { margin: 0 0 14px; color: var(--cyan); font-size: 11px; }
.path::before { content: "$ "; color: var(--green); }

h1 {
  max-width: 18ch;
  margin: 0 0 12px;
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.05em;
}

.prompt { color: var(--purple); }
.cursor { color: var(--orange); animation: blink 1.1s step-end infinite; }
.comment { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

@keyframes blink { 50% { opacity: 0; } }

.command-button {
  display: grid;
  grid-template-columns: 36px 1fr 32px;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--purple);
  border-radius: 4px;
  color: var(--text);
  background: #211d25;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  text-align: left;
  cursor: pointer;
}
.command-button:active { transform: translateY(1px); }
.command-button:disabled { opacity: 0.5; cursor: wait; }
.command-button svg { width: 25px; fill: none; stroke: var(--purple); stroke-width: 1.8; }
.command-button strong, .command-button small { display: block; }
.command-button strong { color: var(--purple); font-size: 13px; }
.command-button small { margin-top: 4px; color: var(--muted); font-size: 10px; }

kbd {
  justify-self: end;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  background: var(--bg);
  font-size: 11px;
}

.login-panel { margin-top: 8px; }

.login-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  font-size: 11px;
}

.login-cancel { margin-left: auto; color: var(--red); font-size: 10px; }

.login-error {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--red);
  border-radius: 4px;
  background: #2a1d1d;
  color: var(--red);
  font-size: 11px;
}

/* ---- Panels ---- */

.panel {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: #a09b96;
  background: var(--panel-raised);
  font-size: 10px;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 7px var(--green);
}
.status-dot.pulsing { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

.muted { color: var(--muted); }
.mono { color: var(--cyan); font-size: 12px; }

.output-copy { padding: 10px 0; }
.output-copy p { margin: 0; padding: 6px 14px; color: #b8b2ad; font-size: 10px; line-height: 1.5; }
.line-number { display: inline-block; width: 28px; color: #5f5b57; user-select: none; }

/* ---- Pending page ---- */

.pending-panel { margin-top: 8px; }
.pending-body { padding: 16px; font-size: 12px; line-height: 1.6; }
.pending-body p { margin: 0 0 10px; }

/* ---- File manager layout ---- */

.fm-layout {
  display: flex;
  min-height: calc(100vh - 76px);
}

.fm-sidebar {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  background: #191919;
  display: flex;
  flex-direction: column;
}

.fm-sidebar-header {
  padding: 12px 14px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line);
}

.fm-library-nav { flex: 1; overflow-y: auto; padding: 8px; }

.lib-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 3px;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  margin-bottom: 2px;
}
.lib-item:hover { background: var(--panel-raised); }
.lib-item.active { background: #2a2230; color: var(--purple); }

.lib-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 3px;
  background: var(--panel-raised);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 600;
}
.lib-item.active .lib-icon { background: #3a2a40; color: var(--purple); }

.fm-sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---- Buttons ---- */

.fm-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}
.fm-action-btn:hover { border-color: var(--muted); background: var(--panel-raised); }
.fm-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.fm-action-btn.primary { border-color: var(--purple); color: var(--purple); }
.fm-action-btn.primary:hover { background: #2a2230; }
.fm-action-btn.small { padding: 5px 10px; font-size: 14px; }

.icon-sm { width: 16px; height: 16px; }

/* ---- File manager main area ---- */

.fm-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.fm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  gap: 10px;
}

.fm-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  overflow-x: auto;
  white-space: nowrap;
  flex: 1;
}

.crumb, .crumb-root {
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  color: var(--muted);
}
.crumb:hover, .crumb-root:hover { background: var(--panel-raised); color: var(--text); }
.crumb-sep { color: #4a4a4a; margin: 0 2px; }
.crumb.current { color: var(--cyan); cursor: default; }

.fm-toolbar-actions { display: flex; gap: 4px; }

/* ---- Drop zone & file list ---- */

.fm-dropzone {
  flex: 1;
  position: relative;
  overflow-y: auto;
  padding-bottom: 64px;
}

.fm-drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(195, 151, 216, 0.1);
  border: 2px dashed var(--purple);
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}
.fm-dropzone.dragover .fm-drop-overlay { display: flex; }

.drop-text { text-align: center; color: var(--purple); }
.drop-text p { margin-top: 12px; font-size: 14px; }

.fm-file-list { padding: 4px 0; }

.fm-loading {
  padding: 30px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.fm-item {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 1px solid #222;
  font-size: 12px;
}
.fm-item:hover { background: var(--panel-raised); }
.fm-item.selected { background: #2a2230; }

.fm-item-icon { font-size: 16px; text-align: center; }
.fm-item-icon.dir { color: var(--cyan); }
.fm-item-icon.file { color: var(--muted); }

.fm-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-item-size { color: var(--muted); font-size: 10px; white-space: nowrap; }
.fm-item-date { color: #5f5b57; font-size: 10px; white-space: nowrap; }

.fm-item-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.fm-item:hover .fm-item-actions { opacity: 1; }

.fm-item-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 6px;
  font-size: 11px;
}
.fm-item-btn:hover { color: var(--text); border-color: var(--muted); }
.fm-item-btn.danger:hover { color: var(--red); border-color: var(--red); }

/* ---- Upload queue ---- */

.fm-upload-queue {
  border-top: 1px solid var(--line);
  background: #191919;
  max-height: 200px;
  overflow-y: auto;
}

.fm-upload-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 10px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.upload-item {
  padding: 8px 14px;
  border-bottom: 1px solid #222;
  font-size: 11px;
}

.upload-item-name {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.upload-progress-bar {
  height: 4px;
  background: var(--panel-raised);
  border-radius: 2px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  background: var(--purple);
  transition: width 0.2s;
}
.upload-progress-fill.done { background: var(--green); }
.upload-progress-fill.error { background: var(--red); }

.upload-item-info { color: var(--muted); font-size: 10px; margin-top: 3px; }

/* ---- Status bar ---- */

.statusbar {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  height: 28px;
  padding: 7px 14px;
  border-top: 1px solid #44635d;
  color: #b9d5cf;
  background: #254641;
  font-size: 9px;
}
.statusbar span:first-child { margin-right: auto; color: #d5e8ad; }

/* ---- Admin panel ---- */

.admin-main { padding: 18px; display: flex; flex-direction: column; gap: 24px; }

.admin-section {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  overflow: hidden;
}

.admin-section-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-raised);
}
.admin-section-header h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text); }

.admin-user-list, .admin-lib-list { padding: 4px 0; }

.admin-user {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #222;
  font-size: 12px;
}
.admin-user:last-child { border-bottom: none; }

.admin-user img {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  object-fit: cover;
}

.admin-user-info { min-width: 0; }
.admin-user-name { font-weight: 600; }
.admin-user-meta { color: var(--muted); font-size: 10px; }

.admin-badge {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 9px;
  border: 1px solid var(--line);
}
.admin-badge.allowed { color: var(--green); border-color: var(--green); }
.admin-badge.pending { color: var(--orange); border-color: var(--orange); }
.admin-badge.admin { color: var(--purple); border-color: var(--purple); }

.admin-user-actions { display: flex; gap: 4px; }

.admin-lib-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #222;
  font-size: 12px;
}
.admin-lib-row:last-child { border-bottom: none; }

.admin-lib-row input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 11px;
  font-family: inherit;
  width: 100%;
}
.admin-lib-row input:focus { outline: none; border-color: var(--purple); }

.admin-add-lib {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.admin-add-lib input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 11px;
  font-family: inherit;
}
.admin-add-lib input:focus { outline: none; border-color: var(--purple); }

.admin-settings {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-settings label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.admin-settings input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
}
.admin-settings input:focus { outline: none; border-color: var(--purple); }

.admin-settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

/* ---- Floating action bar ---- */

.fm-action-bar {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(29, 31, 33, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.fab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-raised);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.15s, background 0.15s;
}
.fab-btn:hover { border-color: var(--muted); background: #2d2f33; }
.fab-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.fab-btn.primary { border-color: var(--purple); color: var(--purple); }
.fab-btn.primary:hover { background: #2a2230; border-color: var(--purple); }
.fab-btn.icon-only { padding: 8px 12px; font-size: 16px; }
.fab-btn .icon-sm { width: 16px; height: 16px; }

.fab-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 4px;
}

/* ---- Context menu ---- */

.ctx-menu {
  position: fixed;
  z-index: 1000;
  min-width: 160px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-raised);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  font-size: 12px;
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 3px;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}
.ctx-item:hover { background: #2a2230; color: var(--purple); }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: #2a1d1d; color: var(--red); }
.ctx-item.hidden { display: none; }

.ctx-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--line);
}

/* ---- Empty folder tag ---- */

.fm-empty-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(136, 132, 127, 0.15);
  color: var(--muted);
  font-size: 9px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---- Responsive ---- */

@media (max-width: 720px) {
  .fm-sidebar { width: 56px; }
  .fm-sidebar-header { display: none; }
  .lib-item { padding: 10px; justify-content: center; }
  .lib-item span:last-child { display: none; }
  .fab-btn span { display: none; }
  .fab-btn { padding: 8px 10px; }
  .fab-btn.icon-only { padding: 8px 10px; }
  .admin-lib-row { grid-template-columns: 1fr auto; }
  .admin-lib-row input:nth-child(2), .admin-lib-row input:nth-child(3) { display: none; }
}

@media (max-width: 390px) {
  .app-shell { padding: 0; }
  .fm-item { grid-template-columns: 24px 1fr auto; }
  .fm-item-date { display: none; }
  .admin-add-lib { flex-direction: column; }
}

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