:root {
  --bg: #0f1320;
  --panel: #1a1f2e;
  --panel-2: #222a3d;
  --border: #2f3950;
  --text: #eef1f7;
  --muted: #9aa3b8;
  --accent: #eab648;
  --accent-2: #6ea8fe;
  --danger: #e66767;
  --ok: #5dca9a;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }

#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 700; letter-spacing: .3px;
  font-size: 17px; color: var(--accent);
  cursor: pointer;
}
.bar-right { display: flex; gap: 8px; align-items: center; }
#userBadge {
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; color: var(--muted);
}

.btn {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 8px;
  font: inherit; font-size: 14px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #2a3248; border-color: #3f4b69; }
.btn.primary { background: var(--accent); color: #1a1f2e; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: #f3c15c; }
.btn.icon { padding: 6px 10px; min-width: 36px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #3a1f25; }

#app { padding: 18px 14px 60px; max-width: 1100px; margin: 0 auto; }
.screen { display: block; }

.hint { color: var(--muted); font-size: 14px; padding: 12px 2px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin: 12px 0 20px; }

.drop {
  display: block; width: 100%;
  border: 2px dashed #3f4b69; border-radius: 10px;
  padding: 28px 14px; text-align: center; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.drop:hover, .drop.dragover { background: #1f273a; border-color: var(--accent); }
.drop-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.drop-sub { color: var(--muted); font-size: 13px; }

.status { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.status.info { background: #1e2a40; color: #d7def0; }
.status.error { background: #3a1f25; color: #ffb4b4; }
.status.ok { background: #1f3b30; color: #bdf0d3; }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.file-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color .12s;
}
.file-card:hover { border-color: #3f4b69; }
.file-name { font-weight: 600; word-break: break-word; }
.file-meta { color: var(--muted); font-size: 12px; }
.file-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* VIEWER */
#viewerBar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.viewer-title { flex: 1; min-width: 150px; font-weight: 600; font-size: 15px; color: var(--muted); word-break: break-word; }
.viewer-nav { display: flex; gap: 6px; align-items: center; }
#slideCounter { padding: 0 8px; color: var(--muted); font-size: 14px; min-width: 60px; text-align: center; }

#slideStage {
  position: relative; width: 100%;
  background: #000;
  border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 16 / 9;
}
#slideStage .slide-layer {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 1;
  transition: opacity .35s ease;
}
#slideStage .slide-layer.fading-out { opacity: 0; }
#slideStage .slide-layer.fading-in { opacity: 0; }
#slideStage svg { width: 100%; height: 100%; display: block; }
#slideStage [data-clickable="1"] { cursor: pointer; }
#slideStage [data-clickable="1"]:hover { filter: brightness(1.15); }

/* Fullscreen */
#slideStage.fs {
  position: fixed; inset: 0; z-index: 100; border-radius: 0; aspect-ratio: auto;
}

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #222a3d; color: var(--text);
  padding: 10px 16px; border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
  font-size: 14px;
  max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }
#toast.error { border-color: var(--danger); color: #ffd3d3; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 0; box-shadow: var(--shadow); max-width: 90vw; }
dialog::backdrop { background: rgba(0,0,0,.5); }
.share-form { padding: 18px; display: flex; flex-direction: column; gap: 10px; min-width: 320px; }
.share-form h3 { margin: 0 0 4px; }
.share-form input { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font: inherit; }
.share-actions { display: flex; gap: 8px; justify-content: flex-end; }

@media (max-width: 640px) {
  .viewer-title { order: 3; flex-basis: 100%; }
  #app { padding: 12px 10px 60px; }
}
