/* ALYSSIUN VIEWER — premium dark theme */
:root {
  --bg: #08080a;
  --panel: #0f0f12;
  --panel-2: #16161a;
  --text: #eaeaea;
  --muted: rgba(255, 255, 255, .56);
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .14);
  --accent: #00e0ff;
  --ok: #28d07a;
  --warn: #ffb020;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #14141a 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}
body.in-viewer { overflow: hidden; }

.view { position: fixed; inset: 0; display: none; flex-direction: column; }
.view.is-on { display: flex; }
.view--viewer { background: #0a0a0a; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 28px; border-bottom: 1px solid var(--line);
}
.brand { height: 30px; user-select: none; -webkit-user-drag: none; }
.topbar__tag {
  font-weight: 800; letter-spacing: .32em; font-size: 12px;
  color: var(--accent); padding-left: 2px;
}
.privacy-chip {
  margin-left: auto; font-size: 12px; font-weight: 700; color: var(--ok);
  border: 1px solid rgba(40, 208, 122, .35); background: rgba(40, 208, 122, .08);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}

/* ---------- library ---------- */
.lib { flex: 1; overflow: auto; padding: 28px clamp(16px, 5vw, 56px) 60px; }
.lib__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; margin-bottom: 26px;
}
.lib__title { font-size: clamp(22px, 3vw, 30px); margin: 0 0 6px; font-weight: 800; }
.lib__sub { margin: 0; color: var(--muted); max-width: 60ch; line-height: 1.5; }
.lib__sub b { color: var(--text); }
.lib__actions { display: flex; gap: 12px; align-items: center; }
.lib__count { color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line-2); cursor: pointer;
  font-family: var(--font); font-weight: 700; letter-spacing: .04em;
  padding: 11px 18px; border-radius: 11px; background: var(--panel-2); color: var(--text);
  transition: transform .12s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #04141a; border-color: transparent; }
.btn--ghost { background: rgba(20, 20, 24, .72); backdrop-filter: blur(8px); }
.btn--danger { background: transparent; color: #ff7a6b; border-color: rgba(255, 122, 107, .4); }
.btn--danger:hover { background: #c0392b; color: #fff; border-color: transparent; }
.btn[hidden] { display: none; }

/* ---------- empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 8px; padding: 64px 20px; cursor: pointer;
  border: 1.5px dashed var(--line-2); border-radius: 22px; color: var(--muted);
  margin-top: 6px; transition: border-color .2s ease, background .2s ease;
}
.empty:hover, .empty:focus-visible {
  border-color: var(--accent); background: rgba(0, 224, 255, .03); outline: none;
}
.empty h2 { color: var(--text); margin: 6px 0 2px; font-size: 22px; }
.empty__sub { margin: 0; font-size: 14px; }
.empty__formats { margin: 2px 0 6px; display: flex; gap: 8px; }
.empty__formats b {
  color: var(--text); font-size: 12.5px; letter-spacing: .04em;
  border: 1px solid var(--line-2); border-radius: 8px; padding: 4px 10px;
}
.empty .btn { margin: 6px 0 4px; }
.empty__note { font-size: 12.5px; opacity: .85; margin-top: 4px; }

/* ---------- card grid ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.card {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: transform .14s ease, border-color .2s ease, box-shadow .2s ease;
}
.card:hover, .card:focus-visible {
  transform: translateY(-3px); border-color: var(--accent);
  box-shadow: var(--shadow); outline: none;
}
.card__thumb {
  height: 130px; display: grid; place-items: center;
  background: radial-gradient(120px 80px at 50% 40%, #20202a, #101014);
  border-bottom: 1px solid var(--line);
}
.card__ext {
  font-weight: 800; letter-spacing: .14em; font-size: 22px; color: var(--accent);
  border: 1.5px solid var(--line-2); padding: 8px 14px; border-radius: 10px;
}
.card__body { padding: 13px 14px 15px; }
.card__name {
  font-weight: 700; font-size: 14px; margin-bottom: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card__meta { display: flex; gap: 12px; color: var(--muted); font-size: 12.5px; }
.card__deps {
  margin-top: 6px; font-size: 11px; font-weight: 700; color: var(--accent);
  letter-spacing: .02em;
}
.card__local {
  margin-top: 10px; font-size: 11px; letter-spacing: .06em;
  color: var(--ok); font-weight: 700;
}
.card__remove {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px;
  border: 0; border-radius: 8px; cursor: pointer; font-size: 17px; line-height: 1;
  background: rgba(0, 0, 0, .55); color: #fff; opacity: 0; transition: opacity .15s ease;
}
.card:hover .card__remove, .card:focus-within .card__remove { opacity: 1; }
.card__remove:hover { background: #c0392b; }

/* ---------- viewer view ---------- */
#viewer-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud {
  position: absolute; left: 0; right: 0; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 16px 18px; pointer-events: none;
  flex-wrap: wrap;
}
/* Legibility gradient behind the top bar over bright models */
.hud--top { top: 0; }
.hud--top::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .55), rgba(0, 0, 0, 0));
}
.hud .btn { pointer-events: auto; }
.hud__title {
  flex: 1; text-align: center; font-weight: 700; font-size: 14px; min-width: 120px;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* bottom:96px clears the bottom-center ALYSSIUN OS launcher button */
.hud__hint {
  position: absolute; bottom: 96px; left: 50%; transform: translate(-50%, 8px);
  background: rgba(15, 15, 18, .8); backdrop-filter: blur(8px);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 8px 16px;
  font-size: 12.5px; color: var(--muted); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .3s ease, transform .3s ease;
}
.hud__hint.is-on { opacity: 1; transform: translate(-50%, 0); }
.viewer-loading {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 12px; color: var(--text);
  font-weight: 600; font-size: 15px; z-index: 5;
}
.viewer-loading[hidden] { display: none; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.statspanel {
  position: absolute; left: 18px; bottom: 18px; min-width: 210px;
  background: rgba(15, 15, 18, .78); backdrop-filter: blur(10px);
  border: 1px solid var(--line-2); border-radius: var(--radius); padding: 14px 16px;
}
.statspanel__title {
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.statspanel dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; }
.statspanel dt { color: var(--muted); font-size: 13px; }
.statspanel dd {
  margin: 0; text-align: right; font-weight: 700; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.statspanel__local { margin-top: 12px; font-size: 11px; color: var(--ok); font-weight: 700; }

/* ---------- drop overlay ---------- */
.dropoverlay {
  position: fixed; inset: 0; z-index: 2000; display: none;
  align-items: center; justify-content: center;
  background: rgba(0, 224, 255, .08); backdrop-filter: blur(3px);
}
.dropoverlay.is-on { display: flex; }
.dropoverlay__inner {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 50px 70px; border: 2.5px dashed var(--accent); border-radius: 24px;
  background: rgba(8, 8, 10, .6);
}
.dropoverlay__ring {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--accent); color: var(--accent); font-size: 30px;
}
.dropoverlay__text { font-weight: 800; letter-spacing: .04em; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px);
  z-index: 2200; max-width: 90vw; padding: 12px 18px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  font-size: 13.5px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast--ok { border-left: 3px solid var(--ok); }
.toast--warn { border-left: 3px solid var(--warn); }

/* ---------- confirm modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 2400;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal__backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px);
}
.modal__card {
  position: relative; width: min(420px, 100%);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px;
  box-shadow: var(--shadow); padding: 24px;
  animation: modalIn .18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px); } }
.modal__title { margin: 0 0 8px; font-size: 19px; font-weight: 800; }
.modal__msg { margin: 0 0 20px; color: var(--muted); line-height: 1.5; font-size: 14px; }
.modal__msg b { color: var(--text); }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Keep the OS launcher button clear of the bottom-left stats panel */
.statspanel { z-index: 1; }

@media (max-width: 600px) {
  .topbar { padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
  .privacy-chip { margin-left: 0; }
  .lib { padding: 22px 16px 50px; }
  .lib__head { gap: 14px; }
  .lib__actions { width: 100%; justify-content: space-between; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .hud { padding: 12px; }
  .hud__title { order: 3; flex-basis: 100%; text-align: center; margin-top: 2px; }
  /* lift the stats panel above the bottom-center OS launcher button */
  .statspanel { left: 12px; right: 12px; bottom: 96px; min-width: 0; }
  .hud__hint { bottom: auto; top: 64px; font-size: 11.5px; max-width: 92vw; white-space: normal; text-align: center; }
}
