:root {
  color-scheme: dark;
  --bg: #0b0f17;
  --panel: #151a24;
  --panel-2: #111621;
  --surface: #1a2231;
  --muted: #7a889d;
  --text: #e2e8f0;
  --accent: #3b82f6;
  --accent-2: #1d4ed8;
  --danger: #ef4444;
  --chip: #172033;
  --border: rgba(148, 163, 184, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Manrope", sans-serif;
  margin: 0;
  background: radial-gradient(circle at top left, #0b1220, #090d15 45%, #0f172a 80%);
  color: var(--text);
}

.noise {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.mono {
  font-family: "Space Mono", monospace;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 11, 18, 0.9);
  backdrop-filter: blur(18px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.logo {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  padding: 10px 14px;
  border-radius: 14px;
  min-width: 320px;
  border: 1px solid var(--border);
}

.search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  width: 100%;
}

.search-icon {
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.chip {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
}

.icon-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.app-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  padding: 24px;
}

.sidebar {
  background: var(--panel);
  border-radius: 20px;
  padding: 18px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.sidebar-subtitle {
  margin-top: 6px;
  color: var(--text);
  font-weight: 600;
}

.sidebar-actions {
  display: grid;
  gap: 10px;
}

.sidebar-block {
  display: grid;
  gap: 8px;
}

.nav-link {
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
}

.nav-link:hover {
  background: var(--surface);
}

.primary,
.secondary,
.danger {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: white;
}

.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.danger {
  background: #2a1113;
  color: #fda4af;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.main {
  display: grid;
  gap: 18px;
}

.toolbar {
  background: var(--panel);
  border-radius: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.breadcrumb {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.title {
  font-size: 22px;
  font-weight: 600;
  margin-top: 6px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
}

.content-grid {
  background: var(--panel);
  border-radius: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  min-height: 260px;
}

.selection-bar {
  margin-top: 12px;
  background: var(--panel-2);
  border-radius: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.selection-actions {
  display: flex;
  gap: 10px;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.content-title {
  font-weight: 600;
}

.content-count {
  color: var(--muted);
  font-size: 14px;
}

.items {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  justify-items: start;
}

.item-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  display: grid;
  gap: 10px;
  text-align: left;
  position: relative;
  width: 100%;
  max-width: 220px;
}

.item-card:hover {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
}

.item-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.6);
}

.item-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: transparent;
}

.item-card.selected .item-check {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.item-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  font-size: 22px;
}

.item-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 200px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--muted);
  overflow: hidden;
}

.item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-name {
  font-weight: 600;
}

.item-meta {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  margin-top: 24px;
  color: var(--muted);
}

.context-menu {
  position: fixed;
  z-index: 40;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  display: grid;
  gap: 4px;
}

.context-menu button {
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.context-menu button:hover {
  background: var(--surface);
}

.context-menu button.danger {
  color: #fda4af;
}

.context-menu button.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.upload-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: min(320px, 90vw);
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 12px;
  z-index: 30;
  display: grid;
  gap: 10px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.upload-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.upload-list {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
}

.upload-item {
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  display: grid;
  gap: 6px;
}

.upload-name {
  font-size: 12px;
  color: var(--text);
}

.upload-bar {
  width: 100%;
  height: 6px;
  background: #0b1324;
  border-radius: 999px;
  overflow: hidden;
}

.upload-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width 0.2s ease;
}

.info-grid {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 18, 0.75);
  z-index: 20;
}

.modal-card {
  background: var(--panel);
  border-radius: 20px;
  padding: 24px;
  width: min(420px, 90vw);
  border: 1px solid var(--border);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
}

.modal-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.checkbox-row {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.error {
  color: #fca5a5;
  font-size: 12px;
}

.viewer {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.96);
  z-index: 30;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(10, 14, 22, 0.9);
  border-bottom: 1px solid var(--border);
}

.viewer-title {
  font-weight: 600;
}

.viewer-meta {
  color: var(--muted);
  font-size: 12px;
}

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

.viewer-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 36px;
  height: 36px;
}

.viewer-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.viewer-body img,
.viewer-body video,
.viewer-body iframe {
  max-width: 80vw;
  max-height: 70vh;
  border-radius: 12px;
}

.viewer:fullscreen .viewer-body {
  padding: 0;
  width: 100vw;
  height: 100vh;
}

.viewer:fullscreen .viewer-body video {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  object-fit: contain;
}

.viewer-controls {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: rgba(10, 14, 22, 0.9);
  z-index: 2;
}

.viewer.video-active .viewer-controls {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 24px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(10, 14, 22, 0.55);
  backdrop-filter: blur(10px);
}

.viewer.video-active .viewer-body {
  position: relative;
}

.viewer:fullscreen .viewer-controls {
  left: 32px;
  right: 32px;
  bottom: 32px;
}

.viewer:fullscreen .viewer-header {
  display: none;
}

.viewer-overlay {
  transition: opacity 0.3s ease;
}

.viewer.hide-overlays .viewer-overlay {
  opacity: 0;
  pointer-events: none;
}

.viewer-control {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 36px;
  height: 36px;
}

.viewer-time {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.viewer-time input,
.viewer-volume input {
  width: 100%;
}

.viewer-volume {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.viewer-toast {
  position: absolute;
  top: 90px;
  right: 32px;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.viewer-help {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.75);
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-help-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  width: min(360px, 90vw);
  color: var(--text);
}

.viewer-help-card ul {
  margin: 12px 0;
  padding-left: 18px;
  color: var(--muted);
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 42, 0.7);
  color: white;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.viewer-nav.left {
  left: 24px;
}

.viewer-nav.right {
  right: 24px;
}

.viewer-footer {
  padding: 12px 24px;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

@media (max-width: 1100px) {
  .app-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }
}
