:root {
  --bg: #0b0d12;
  --bg-2: #11141b;
  --panel: rgba(22, 26, 35, 0.72);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #eef0f5;
  --muted: #8b93a7;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 14px;
  --font: "Inter", system-ui, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ---------------- home ---------------- */
#home { position: relative; height: 100%; overflow-y: auto; display: grid; place-items: center; padding: 32px 16px; }
.glow { position: fixed; inset: -20% -10% auto; height: 70%; pointer-events: none;
  background: radial-gradient(40% 50% at 30% 40%, rgba(124, 92, 255, 0.28), transparent 70%),
              radial-gradient(35% 45% at 72% 30%, rgba(34, 211, 238, 0.18), transparent 70%);
  filter: blur(20px); }
.home-inner { position: relative; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 14px; }
.mark { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 10px 30px -8px rgba(124, 92, 255, 0.6); }
.mark svg { width: 26px; height: 26px; stroke-width: 2; }
h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px;
  backdrop-filter: blur(18px); box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6); display: flex; flex-direction: column; }
.panel label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 8px; }
.panel input { width: 100%; height: 52px; padding: 0 16px; margin-bottom: 18px; border-radius: 12px; border: 1px solid var(--line-2);
  background: rgba(0, 0, 0, 0.25); color: var(--text); font-size: 20px; outline: none; transition: border-color .15s, box-shadow .15s; }
.panel input::placeholder { color: #4b5263; }
.panel input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18); }
.mono { font-family: var(--mono) !important; letter-spacing: 0.08em; }
.pin-wrap { position: relative; }
.pin-icon { position: absolute; right: 16px; top: 16px; color: var(--muted); }
.primary { height: 52px; border: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 600; font-size: 16px; color: #fff; background: linear-gradient(135deg, var(--accent), #5b7cff);
  box-shadow: 0 8px 24px -8px rgba(124, 92, 255, 0.7); transition: transform .1s, filter .15s; }
.primary:hover { filter: brightness(1.1); }
.primary:active { transform: translateY(1px); }
.primary:disabled { filter: grayscale(.5) brightness(.8); cursor: wait; }
.primary svg { transition: transform .15s; }
.primary:hover svg { transform: translateX(3px); }
.error:empty { display: none; }
.error { margin: 12px 0 0; color: var(--err); font-size: 14px; text-align: center; }

#recents h2 { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 10px; }
#recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.recent { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025); cursor: pointer; transition: background .15s, border-color .15s; }
.recent:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--line-2); }
.recent .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(124, 92, 255, 0.14); color: #b3a3ff; }
.recent .meta { flex: 1; min-width: 0; }
.recent .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent .id { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.recent .rm { border: 0; background: none; color: var(--muted); padding: 6px; border-radius: 8px; opacity: 0; transition: opacity .15s; }
.recent:hover .rm { opacity: 1; }
.recent .rm:hover { color: var(--err); background: rgba(248, 113, 113, 0.1); }
.recent .rm svg { width: 16px; height: 16px; }

.download { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; text-decoration: none; color: var(--text);
  border: 1px dashed rgba(124, 92, 255, 0.45); background: rgba(124, 92, 255, 0.06); transition: background .15s, border-color .15s; }
.download:hover { background: rgba(124, 92, 255, 0.12); border-color: var(--accent); }
.download .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; flex: none; }
.download .nm { font-weight: 600; font-size: 14px; }
.download .sub { color: var(--muted); font-size: 12px; }
footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #5d6578; font-size: 12px; }
.dot-label { display: inline-flex; align-items: center; gap: 6px; }
.dot-label i { width: 7px; height: 7px; border-radius: 50%; background: #5d6578; }
.dot-label.ok i { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot-label.err i { background: var(--err); }

/* ---------------- viewer ---------------- */
#viewer { position: fixed; inset: 0; background: #000; }
#screen { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; outline: none; touch-action: none; cursor: default; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(60% 60% at 50% 40%, #151927, #07080b); color: var(--muted); transition: opacity .3s; }
.overlay.gone { opacity: 0; pointer-events: none; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.08); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ghost { border: 1px solid var(--line-2); background: transparent; border-radius: 10px; padding: 8px 16px; color: var(--muted); }
.ghost:hover { color: var(--text); }

.toolbar { position: absolute; top: 12px; left: 50%; transform: translate(-50%, 0); z-index: 10; display: flex; align-items: center; gap: 4px;
  padding: 6px; border-radius: 16px; background: rgba(17, 20, 27, 0.82); border: 1px solid var(--line-2); backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px -10px rgba(0, 0, 0, 0.7); transition: transform .25s ease, opacity .25s ease; max-width: calc(100vw - 24px); }
.toolbar.hide { transform: translate(-50%, calc(-100% - 16px)); opacity: 0; }
#toolbar-hotzone { position: absolute; top: 0; left: 25%; right: 25%; height: 10px; z-index: 9; }
.tb-name { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 8px; font-weight: 600; font-size: 13px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qdot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.qdot.good { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.qdot.fair { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.qdot.poor { background: var(--err); box-shadow: 0 0 8px var(--err); }
.sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; }
.tb-group { display: flex; gap: 2px; }
.tb { height: 36px; min-width: 36px; padding: 0 8px; border: 0; border-radius: 10px; background: transparent; color: #c9cede;
  display: inline-flex; align-items: center; justify-content: center; gap: 2px; transition: background .12s, color .12s; }
.tb:hover, .tb.on { background: rgba(255, 255, 255, 0.08); color: #fff; }
.tb.danger { color: var(--err); }
.tb.danger:hover { background: rgba(248, 113, 113, 0.15); }
.tb-text { font-size: 12px; font-weight: 600; padding: 0 10px; letter-spacing: .02em; }
.tb svg { width: 19px; height: 19px; }
.tb .chev { width: 13px; height: 13px; opacity: .6; }
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%); min-width: 220px; padding: 6px; border-radius: 12px;
  background: rgba(20, 23, 31, 0.96); border: 1px solid var(--line-2); box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.8);
  display: none; flex-direction: column; }
.menu.open { display: flex; }
.menu button { text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 8px; font-size: 13px; color: #d5d9e5; }
.menu button:hover { background: rgba(255, 255, 255, 0.07); }
.menu button.cur { color: #fff; background: rgba(124, 92, 255, 0.2); }

.stats { position: absolute; right: 12px; bottom: 12px; z-index: 10; padding: 12px 14px; border-radius: 12px; font: 12px/1.7 var(--mono);
  background: rgba(10, 12, 16, 0.78); border: 1px solid var(--line); color: #b7bdcc; backdrop-filter: blur(10px); min-width: 210px; }
.stats b { color: #fff; font-weight: 600; float: right; margin-left: 20px; }

#toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 12px; background: rgba(22, 26, 35, 0.95); border: 1px solid var(--line-2); font-size: 14px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.7); animation: tin .2s ease; }
.toast.err { border-color: rgba(248, 113, 113, 0.4); color: #fecaca; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 560px) {
  .tb-name { display: none; }
  .tb-name + .sep { display: none; }
}
