:root {
  color-scheme: dark;
  --bg: #07090f;
  --panel: #121826;
  --card: #171f30;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef3fb;
  --muted: #8b9bb8;
  --pine: #3ee6b0;
  --ember: #ff6a3d;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Noto Sans Thai", "Sarabun", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1000px 420px at 8% -8%, rgba(62, 230, 176, 0.12), transparent 50%),
    radial-gradient(800px 380px at 100% 0%, rgba(255, 106, 61, 0.1), transparent 46%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.screen { min-height: 100vh; }

.card, aside, header, .selection, .uploads, .modal > div, .disk {
  background: rgba(24, 32, 50, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(16px);
}
.card {
  width: min(420px, calc(100% - 32px));
  margin: 12vh auto;
  padding: 28px;
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.brand { display: flex; gap: 12px; align-items: center; }
.app-mark {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}
.app-title {
  font-family: Orbitron, "Segoe UI", sans-serif;
  letter-spacing: 0.1em;
  font-size: 17px;
  color: var(--text);
  font-weight: 700;
}
.app-mark .login-mark-orbit { opacity: 0.28; animation-duration: 9s; }
.app-mark .login-mark-orbit.alt { opacity: 0.22; animation-duration: 14s; }
.app-mark .login-mark-core { animation-duration: 4.8s; opacity: 0.85; }
h1 { margin: 0; font-size: 28px; }
.card p, small { color: var(--muted); }
label { display: block; margin: 14px 0; color: var(--muted); font-size: 14px; }
input, select {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--line); background: #0c1018;
  outline: none;
}
input:focus, select:focus { border-color: var(--pine); }
.card button[type="submit"] {
  width: 100%; border: 0; border-radius: 12px; padding: 11px 16px;
  background: var(--pine); color: #07090f; font-weight: 700;
}
button.primary {
  --login-angle: 0deg;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid rgba(124, 247, 255, 0.55);
  border-radius: 12px; padding: 9px 16px;
  background: linear-gradient(180deg, #9ffff8, #7cf7ff 18%, var(--pine) 52%, #1a8f72);
  color: #07090f; font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
  box-shadow:
    0 0 0 1px rgba(62, 230, 176, 0.35),
    0 0 22px rgba(62, 230, 176, 0.55),
    0 0 48px rgba(255, 106, 61, 0.18);
  animation: btn-glow 2.2s ease-in-out infinite;
}
button.primary::before {
  content: "";
  position: absolute;
  inset: -40% -20%;
  background: conic-gradient(from var(--login-angle), transparent 30%, rgba(255,255,255,0.55), transparent 48%, var(--ember), transparent 70%);
  animation: login-angle 4.2s linear infinite;
  opacity: 0.45;
  z-index: -1;
}
button.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255,255,255,0.7), transparent 48%);
  transform: translateX(-130%);
  animation: btn-sheen 2.4s ease-in-out infinite;
  pointer-events: none;
}
.app-body .tools button,
.app-body .nav,
.app-body header .ghost,
.app-body .selection button,
.app-body .view-toggle button {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(62, 230, 176, 0.28);
  box-shadow: 0 0 14px rgba(62, 230, 176, 0.12);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}
.app-body .tools button::after,
.app-body .nav::after,
.app-body header .ghost::after,
.app-body .selection button::after,
.app-body .view-toggle button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 18%, rgba(255,255,255,0.38), transparent 46%);
  transform: translateX(-130%);
  animation: btn-sheen 3.4s ease-in-out infinite;
  pointer-events: none;
}
.app-body .tools button:nth-child(2)::after { animation-delay: 0.4s; }
.app-body .tools button:nth-child(3)::after { animation-delay: 0.8s; }
.app-body .tools button:hover,
.app-body .sidebar-nav .nav:hover,
.app-body header .ghost:hover,
.app-body .selection button:hover,
.app-body .view-toggle button:hover {
  border-color: var(--pine);
  box-shadow: 0 0 22px rgba(62, 230, 176, 0.5);
  transform: translateY(-1px);
}
.app-body .selection .danger {
  border-color: rgba(255, 106, 61, 0.4);
}
.app-body .selection .danger:hover {
  border-color: var(--ember);
  box-shadow: 0 0 22px rgba(255, 106, 61, 0.5);
}
.view-toggle button.on {
  background: rgba(62, 230, 176, 0.22);
  color: var(--pine);
  box-shadow: 0 0 16px rgba(62, 230, 176, 0.35);
}
#app {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #07090f;
}
.app-fx {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
#app-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.app-aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  mix-blend-mode: screen;
}
.app-aurora.a1 {
  width: 180px; height: 180px; left: -48%; top: 12%;
  background: radial-gradient(circle, rgba(62, 230, 176, 0.14), transparent 70%);
  animation: aurora-drift 28s ease-in-out infinite;
}
.app-scan {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(0,0,0,0.08) 3px 4px);
  opacity: 0.1;
  mix-blend-mode: overlay;
}
.app-body {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 252px 1fr;
  height: 100%;
  min-height: 0;
}
aside {
  display: none; padding: 16px; border-right: 1px solid rgba(255, 255, 255, 0.08);
  flex-direction: column; gap: 12px; min-height: 0;
  position: relative;
  overflow: hidden;
  background: rgba(8, 12, 20, 0.92);
}
aside > *:not(.app-fx) { position: relative; z-index: 1; }
aside .brand { flex-shrink: 0; }
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  width: 100%;
}
aside .nav {
  display: block;
  width: 100%;
  flex-shrink: 0;
  margin: 0;
}
@media (min-width: 960px) {
  aside { display: flex; }
}
@media (max-width: 959px) {
  .app-body { grid-template-columns: 1fr; }
}
#app main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: #07090f;
  isolation: isolate;
}
.opt {
  display: flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 13px; white-space: nowrap;
  user-select: none;
}
.opt input { width: auto; margin: 0; accent-color: var(--pine); }
header input, header select { width: auto; margin-top: 0; }
.search input { width: 100%; }
#sort {
  min-width: 150px;
  border: 1px solid rgba(62, 230, 176, 0.32);
  box-shadow: 0 0 16px rgba(62, 230, 176, 0.18);
  background: rgba(8, 12, 22, 0.88);
}
.nav, .tools button:not(.primary), .selection button, .ghost, .view-toggle button {
  background: rgba(255,255,255,0.05); border-radius: 12px; padding: 8px 12px;
}
.nav { text-align: left; }
.nav.on {
  background: rgba(62, 230, 176, 0.12);
  border: 1px solid rgba(62, 230, 176, 0.45);
  color: var(--pine);
  font-weight: 700;
}
.sysmon {
  margin-top: auto;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px;
  border-radius: 14px;
  background: rgba(10, 14, 24, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.sysmon-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px;
  font-family: Orbitron, "Segoe UI", sans-serif;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--muted);
}
.sysmon-head small { letter-spacing: 0; font-family: inherit; font-size: 10px; }
.gauge { margin: 0 0 10px; }
.gauge-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; color: var(--muted); letter-spacing: 0.04em;
}
.gauge-row b {
  font-family: Orbitron, "Segoe UI", sans-serif;
  font-size: 12px; color: var(--text); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.gauge .bar { height: 5px; margin: 5px 0 0; background: rgba(255,255,255,0.08); }
.gauge .bar span { transition: width 0.45s ease, background 0.3s ease; }
.bar.warn span, .gauge.warn .bar span { background: #e7b14a; }
.bar.hot span, .gauge.hot .bar span { background: var(--ember); }
.sys-meta { display: block; margin-top: 2px; font-size: 11px; line-height: 1.45; }
.devices { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); }
.device-list { margin-top: 8px; display: grid; gap: 6px; max-height: 132px; overflow: auto; }
.device-row {
  display: flex; justify-content: space-between; gap: 8px; align-items: flex-start;
  font-size: 11px; color: var(--muted); min-width: 0;
}
.device-row > span:first-child { min-width: 0; flex: 1; }
.device-row b {
  color: var(--text); font-weight: 600; font-size: 11px;
  flex-shrink: 0; white-space: nowrap; text-align: right;
}
.device-row .dot {
  width: 7px; height: 7px; border-radius: 99px; background: var(--pine);
  box-shadow: 0 0 8px rgba(62, 230, 176, 0.7); flex-shrink: 0;
  display: inline-block; margin-right: 6px; vertical-align: middle;
}
.dev-name-btn {
  margin-top: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}
.dev-name-btn:hover { color: var(--text); border-color: rgba(62, 230, 176, 0.4); }
.funnel-box {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.funnel-box #funnel-state.hot { color: var(--ember); }
.funnel-url {
  display: block;
  margin: 6px 0 4px;
  font-size: 10px;
  line-height: 1.4;
  word-break: break-all;
  color: var(--pine);
  cursor: pointer;
}
.funnel-hint {
  margin: 0;
  font-size: 10px;
  line-height: 1.45;
  color: var(--muted);
}
.funnel-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(62, 230, 176, 0.35);
  background: rgba(62, 230, 176, 0.1);
  color: var(--pine);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.funnel-btn:hover {
  background: rgba(62, 230, 176, 0.18);
  border-color: rgba(62, 230, 176, 0.55);
}
.funnel-btn.hot {
  border-color: rgba(255, 106, 61, 0.45);
  background: rgba(255, 106, 61, 0.12);
  color: #ffb89a;
}
.funnel-btn.hot:hover {
  background: rgba(255, 106, 61, 0.2);
}
.funnel-btn.share {
  margin-top: 6px;
  border-color: rgba(120, 180, 255, 0.4);
  background: rgba(120, 180, 255, 0.12);
  color: #b8d4ff;
}
.funnel-btn.share:hover {
  background: rgba(120, 180, 255, 0.2);
  border-color: rgba(120, 180, 255, 0.55);
}
.funnel-pill.share {
  border-color: rgba(120, 180, 255, 0.45);
  background: rgba(120, 180, 255, 0.12);
  color: #b8d4ff;
}
.funnel-pill.share:hover {
  border-color: rgba(120, 180, 255, 0.65);
  background: rgba(120, 180, 255, 0.2);
}
.share-link-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: stretch;
}
.share-link-input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  font-size: 13px;
  color: var(--pine);
}
.share-copy-btn {
  flex-shrink: 0;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--pine);
  color: #07090f;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.share-copy-btn:hover { filter: brightness(1.08); }
.share-copy-btn.done {
  background: rgba(62, 230, 176, 0.25);
  color: var(--pine);
  border: 1px solid rgba(62, 230, 176, 0.45);
}
.share-copy-status {
  margin: 8px 0 0;
  color: var(--pine);
  font-size: 13px;
}
.funnel-pill {
  flex-shrink: 0;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}
.funnel-pill.on {
  border-color: rgba(255, 106, 61, 0.5);
  background: rgba(255, 106, 61, 0.14);
  color: #ffb89a;
}
.funnel-pill.off:hover { border-color: rgba(62, 230, 176, 0.4); color: var(--pine); }
.funnel-warn { color: var(--ember); margin-top: 0; }
.logs {
  flex: 1; min-height: 0; min-width: 0;
  overflow: auto; padding: 8px 16px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.logs-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.logs-toolbar select { width: auto; margin: 0; min-width: 180px; }
.log-list { display: grid; gap: 8px; }
.log-item {
  display: grid; grid-template-columns: 150px 1fr;
  gap: 4px 12px;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 13px;
}
.log-item time { color: var(--muted); font-size: 12px; }
.log-item strong { color: var(--pine); }
.log-item.bad strong { color: var(--ember); }
.log-item .sub { color: var(--text); font-size: 13px; grid-column: 1 / -1; word-break: break-word; white-space: normal; }
.log-item .log-device {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
  white-space: normal;
}
.gauge small { display: block; margin-top: 4px; font-size: 11px; }
.disk { margin-top: auto; padding: 14px; border-radius: 16px; background: rgba(12, 18, 30, 0.82); }
.bar { height: 8px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.bar span { display: block; height: 100%; width: 0; background: var(--pine); }
header { flex-shrink: 0; z-index: 5; padding: 10px 14px 8px; display: grid; gap: 8px; }
.top, .tools, .selection { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { flex: 1; min-width: 0; }
.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tools-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.tools-actions { flex: 1 1 auto; min-width: 0; }
.tools-meta {
  flex: 0 1 auto;
  margin-left: auto;
}
.pathbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.pathbar .crumbs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding: 2px 0;
}
.pathbar .crumbs::-webkit-scrollbar { height: 4px; }
.pathbar .crumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 99px;
}
.crumbs .crumb {
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(220px, 42vw);
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.crumbs button.crumb:hover,
.crumbs .crumb-menu:hover {
  color: var(--pine);
  background: rgba(62, 230, 176, 0.08);
}
.crumbs .crumb.current {
  color: var(--text);
  font-weight: 600;
  cursor: default;
  flex-shrink: 1;
}
.crumbs .crumb-menu {
  flex: 0 0 auto;
  max-width: none;
  min-width: 28px;
  padding-inline: 10px;
  letter-spacing: 0.12em;
}
.crumbs .sep {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.22);
  font-size: 12px;
  line-height: 1;
  user-select: none;
  padding: 0 1px;
}
.crumb-pop {
  position: fixed;
  z-index: 60;
  min-width: 180px;
  max-width: min(320px, 90vw);
  max-height: 240px;
  overflow: auto;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 24, 38, 0.98);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}
.crumb-pop button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crumb-pop button:hover { background: rgba(62, 230, 176, 0.1); color: var(--pine); }
.path-count {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.view-toggle {
  margin-left: 0; display: flex; padding: 4px; background: #0c1018; border-radius: 12px; flex-shrink: 0;
  border: 1px solid rgba(62, 230, 176, 0.25);
  box-shadow: 0 0 16px rgba(62, 230, 176, 0.12);
}
.selection { margin: 8px 14px 0; padding: 6px 10px; border-radius: 16px; flex-shrink: 0; }
.danger { color: var(--ember) !important; background: rgba(255, 106, 61, 0.12) !important; }
.ghost { background: transparent; color: var(--muted); }
.error { color: var(--ember); padding: 0 16px; }
.files {
  padding: 8px 16px 20px;
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
}
.files.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 110px), 120px));
  grid-auto-rows: max-content;
  grid-auto-flow: row;
  align-content: start;
  align-items: start;
  justify-content: start;
  gap: 8px;
}
.tile {
  text-align: left; border: 1px solid var(--line); background: var(--card);
  border-radius: 10px; overflow: hidden; padding: 0;
  width: 100%;
  height: auto;
  min-width: 0;
  max-width: 100%;
  align-self: start;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.tile:hover {
  transform: translateY(-3px);
  border-color: rgba(62, 230, 176, 0.45);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 0 24px rgba(62, 230, 176, 0.12);
}
.tile.selected { border-color: var(--pine); background: rgba(62, 230, 176, 0.1); }
.tile.locked { border-color: rgba(255, 180, 80, 0.35); }
.tile.locked.selected { border-color: rgba(255, 180, 80, 0.55); background: rgba(255, 180, 80, 0.08); }
.lock-badge {
  font-size: 11px;
  opacity: 0.85;
  vertical-align: middle;
}
.selection button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.row.locked .name { color: #ffc896; }
.thumb {
  width: 100%;
  flex: 0 0 auto;
  aspect-ratio: 16 / 10;
  height: auto;
  min-height: 68px;
  background:
    radial-gradient(circle at 50% 40%, rgba(62, 230, 176, 0.16), transparent 55%),
    #0c1018;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.thumb img, .thumb-video {
  width: 100%; height: 100%; object-fit: cover;
  position: absolute; inset: 0;
  pointer-events: none;
}
.thumb-video { z-index: 0; background: #0c1018; }
.thumb img { z-index: 1; }
.thumb img:not(.ready) { opacity: 0; }
.meta { padding: 6px 8px; flex: 0 0 auto; }
.meta strong, .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.meta small { font-size: 10px; }
.check {
  position: absolute; top: 5px; left: 5px; width: 16px; height: 16px; z-index: 3;
  border-radius: 4px; border: 1px solid rgba(255,255,255,0.35); background: rgba(0,0,0,0.35);
}
.tile.selected .check { background: var(--pine); border-color: var(--pine); }
.files.list { display: block; }
.row {
  display: grid; grid-template-columns: 28px 1fr 120px 110px;
  gap: 10px; width: 100%; align-items: center;
  padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; text-align: left;
}
.row.selected { background: rgba(62, 230, 176, 0.08); }
.empty { color: var(--muted); padding: 12vh 0; text-align: center; }
.uploads {
  position: fixed; right: 16px; bottom: 16px; width: min(320px, calc(100vw - 24px)); padding: 12px 14px; border-radius: 16px; z-index: 20;
}
.uploads-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.uploads-head .ghost { padding: 4px 8px; }
#uploads-list { max-height: 220px; overflow: auto; }
.prog { height: 6px; background: rgba(255,255,255,0.1); border-radius: 99px; overflow: hidden; margin: 6px 0 10px; }
.prog span { display: block; height: 100%; background: var(--pine); }
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.72); z-index: 30;
  display: grid; place-items: center; padding: 16px;
}
.preview {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  padding: 0; background: #000;
  width: 100%; height: 100%;
  height: 100dvh;
  overflow: hidden;
}
.preview-stage {
  flex: 1; min-height: 0; width: 100%; height: auto;
  overflow: hidden; background: #000;
  position: relative;
}
.preview-stage video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain; background: #000;
}
.preview-zoom {
  position: absolute; inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: zoom-in;
}
.preview-zoom.panning { cursor: grabbing; }
.preview-zoom img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  object-fit: contain; object-position: center;
  background: #000;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}
.modal > div { width: min(480px, 100%); padding: 18px; border-radius: 18px; position: relative; z-index: 1; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.modal .actions button { position: relative; z-index: 2; }
.modal-ok {
  border: 0;
  border-radius: 12px;
  padding: 9px 16px;
  background: var(--pine);
  color: #07090f;
  font-weight: 700;
}
.modal-ok:disabled { opacity: 0.65; cursor: wait; }
.modal-err {
  margin: 8px 0 0;
  color: var(--ember);
  font-size: 13px;
  line-height: 1.45;
}
.folder-list { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.folder-list button { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 10px 12px; }
.preview-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 8;
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 12px;
  background: rgba(0, 0, 0, 0.82);
  pointer-events: none;
}
.preview-bar .preview-title {
  min-width: 0; flex: 1 1 80px;
  color: var(--text);
}
.preview-bar .preview-title strong {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px;
}
.preview-bar > * { pointer-events: auto; }
.preview-bar button {
  border: 0; border-radius: 10px; padding: 8px 12px;
  background: rgba(255,255,255,0.16); color: var(--text);
  min-height: 40px;
}
.preview-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center; justify-content: flex-end;
  margin-left: auto;
}
.preview-dock {
  display: none;
}
.preview-action-btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  min-height: 40px;
  font-weight: 600;
  white-space: nowrap;
}
.preview-actions .preview-action-btn {
  color: var(--text);
}
.preview-action-btn.primary {
  background: rgba(62, 230, 176, 0.22);
  color: #d8fff0;
}
@media (max-width: 720px) {
  .preview-bar {
    flex-direction: row;
    align-items: center;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px;
  }
  .preview-actions { display: none !important; }
  .preview-dock {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9;
    gap: 8px;
    pointer-events: none;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.94) 55%, rgba(0, 0, 0, 0.5) 85%, transparent);
    box-sizing: border-box;
    max-width: 100vw;
  }
  .preview-dock .preview-action-btn {
    flex: 1;
    min-width: 0;
    pointer-events: auto;
    border-radius: 12px;
    padding: 12px 8px;
    min-height: 46px;
    font-size: 14px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .preview .preview-stage {
    padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  }
}
.drop { outline: 2px solid var(--pine); }
.play {
  position: absolute; left: 50%; top: 50%; z-index: 2; pointer-events: none;
  width: 28px; height: 28px; border-radius: 99px;
  display: grid; place-items: center; color: white;
  background: radial-gradient(circle at 35% 30%, rgba(124, 247, 255, 0.35), rgba(0, 0, 0, 0.62));
  border: 1.5px solid rgba(62, 230, 176, 0.85);
  box-shadow: 0 0 12px rgba(62, 230, 176, 0.4);
  font-size: 11px;
  animation: play-pulse 2.4s ease-in-out infinite;
}
@media (max-width: 959px) {
  .app-body { grid-template-columns: 1fr; }
  .row { grid-template-columns: 28px 1fr 80px; }
  .row .mtime { display: none; }
}

@property --login-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.login-screen {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 100%;
  height: 100%;
  background: #02040a;
  perspective: 1400px;
}
#login-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
.login-aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: screen;
}
.login-aurora.a1 {
  width: 52vw; height: 52vw; max-width: 640px; max-height: 640px;
  left: -8%; top: -12%;
  background: radial-gradient(circle, rgba(62, 230, 176, 0.55), transparent 68%);
  animation: aurora-drift 14s ease-in-out infinite;
}
.login-aurora.a2 {
  width: 46vw; height: 46vw; max-width: 560px; max-height: 560px;
  right: -10%; top: 8%;
  background: radial-gradient(circle, rgba(255, 106, 61, 0.42), transparent 70%);
  animation: aurora-drift 18s ease-in-out infinite reverse;
}
.login-aurora.a3 {
  width: 38vw; height: 38vw; max-width: 420px; max-height: 420px;
  left: 32%; bottom: 6%;
  background: radial-gradient(circle, rgba(124, 247, 255, 0.28), transparent 68%);
  animation: aurora-drift 16s ease-in-out infinite 1s;
}
.login-horizon {
  position: absolute;
  left: -25%;
  right: -25%;
  bottom: -18%;
  height: 52vh;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(rgba(62, 230, 176, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(62, 230, 176, 0.18) 1px, transparent 1px);
  background-size: 56px 56px;
  transform: perspective(480px) rotateX(64deg);
  transform-origin: center top;
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent 78%);
  animation: grid-rush 9s linear infinite;
}
.login-spot {
  position: absolute;
  width: min(52vw, 520px);
  height: min(52vw, 520px);
  border-radius: 50%;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(circle, rgba(62, 230, 176, 0.2), transparent 66%);
  transform: translate(-50%, -50%);
  left: 50%;
  top: 38%;
}
.login-scan {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    rgba(0, 0, 0, 0.08) 2px 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.35;
}
.login-stage {
  position: relative;
  z-index: 3;
  transform-style: preserve-3d;
  transition: transform 0.12s ease-out;
}
.login-card {
  position: relative;
  margin: 0;
  overflow: visible;
  background: rgba(8, 12, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.55),
    0 0 90px rgba(62, 230, 176, 0.12);
  animation: card-rise 1.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.login-card::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 26px;
  background: conic-gradient(
    from var(--login-angle),
    transparent 0 55%,
    var(--pine) 62%,
    #7cf7ff 70%,
    var(--ember) 78%,
    transparent 88%
  );
  z-index: -2;
  animation: login-angle 5.5s linear infinite;
  filter: blur(0.4px);
}
.login-card::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 23px;
  background: linear-gradient(165deg, rgba(18, 26, 40, 0.92), rgba(7, 10, 16, 0.88));
  z-index: -1;
}
.login-card h1 {
  font-family: Orbitron, "Segoe UI", sans-serif;
  letter-spacing: 0.14em;
  font-size: 30px;
  background: linear-gradient(100deg, #ffffff, var(--pine) 35%, #7cf7ff 55%, var(--ember) 75%, #ffffff);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: title-shine 5s linear infinite;
  filter: drop-shadow(0 0 16px rgba(62, 230, 176, 0.35));
}
.login-mark {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 18px;
  overflow: visible;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.35), transparent 32%),
    linear-gradient(160deg, #1c3d34, #0a1018);
  box-shadow: inset 0 0 0 2px var(--pine), 0 0 28px rgba(62, 230, 176, 0.5);
}
.login-mark-core {
  position: absolute;
  inset: 17px;
  border-radius: 8px;
  background: linear-gradient(145deg, #7cf7ff, var(--pine) 45%, #1a8f72);
  box-shadow: 0 0 18px rgba(62, 230, 176, 0.85);
  animation: core-pulse 2.2s ease-in-out infinite;
}
.login-mark-orbit {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  border-top-color: var(--pine);
  border-right-color: rgba(124, 247, 255, 0.7);
  animation: orbit-spin 3.6s linear infinite;
}
.login-mark-orbit.alt {
  inset: -18px;
  border-top-color: var(--ember);
  border-right-color: transparent;
  border-bottom-color: rgba(255, 106, 61, 0.65);
  animation: orbit-spin 5.4s linear infinite reverse;
}
.login-card button[type="submit"] {
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 28px rgba(62, 230, 176, 0.38);
  letter-spacing: 0.04em;
}
.login-card button[type="submit"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.5), transparent 48%);
  transform: translateX(-130%);
  animation: btn-sheen 3.4s ease-in-out infinite;
}
.login-card.shake {
  animation: login-shake 0.45s ease-in-out;
}
.login-card .error {
  padding: 0;
}

@keyframes aurora-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8%, 10%) scale(1.12); }
}
@keyframes grid-rush {
  from { background-position: 0 0; }
  to { background-position: 0 56px; }
}
@keyframes login-angle {
  to { --login-angle: 360deg; }
}
@keyframes orbit-spin {
  to { transform: rotate(360deg); }
}
@keyframes card-rise {
  from { opacity: 0; transform: translateY(28px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes title-shine {
  to { background-position: 220% center; }
}
@keyframes core-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.86); opacity: 0.75; }
}
@keyframes play-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.82; }
}
@keyframes btn-sheen {
  0%, 55% { transform: translateX(-130%); }
  100% { transform: translateX(130%); }
}
@keyframes btn-glow {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(62, 230, 176, 0.35),
      0 0 18px rgba(62, 230, 176, 0.4),
      0 0 36px rgba(255, 106, 61, 0.12);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(124, 247, 255, 0.7),
      0 0 32px rgba(62, 230, 176, 0.75),
      0 0 56px rgba(255, 106, 61, 0.28);
  }
}
@keyframes login-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

@media (max-width: 720px) {
  .log-item { grid-template-columns: 1fr; }
  header { padding: 6px 10px 4px; gap: 4px; }
  .top {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .search {
    flex: 1;
    min-width: 0;
  }
  .search input {
    padding: 9px 10px;
    font-size: 15px;
    border-radius: 12px;
  }
  #who {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--muted);
    max-width: 4.2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #logout {
    flex-shrink: 0;
    padding: 7px 10px;
    font-size: 13px;
    min-height: 36px;
  }
  .tools {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
  }
  .tools-row {
    display: grid;
    gap: 6px;
    width: 100%;
    min-width: 0;
  }
  .tools-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .tools-actions button {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 6px 4px;
    font-size: 11px;
    line-height: 1.25;
    white-space: normal;
    text-align: center;
  }
  .tools-actions button.primary {
    font-size: 11px;
    font-weight: 700;
    padding: 6px 4px;
    min-height: 40px;
  }
  .tools-meta {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-left: 0;
    align-items: stretch;
  }
  .tools-meta #sort {
    width: 100%;
    min-width: 0;
    padding: 8px 8px;
    font-size: 13px;
  }
  .tools-meta .view-toggle button {
    min-height: 38px;
    padding: 6px 10px;
    font-size: 12px;
  }
  .tools-meta .view-toggle {
    margin-left: 0;
    flex-shrink: 0;
  }
  .pathbar {
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding-top: 2px;
  }
  .pathbar .crumbs {
    flex: 1 1 100%;
    order: 1;
  }
  .pathbar .funnel-pill,
  .pathbar .path-count {
    order: 2;
  }
  .path-count {
    font-size: 12px;
    margin-left: auto;
  }
  .funnel-pill {
    padding: 6px 12px;
    font-size: 12px;
    min-height: 32px;
  }
  .files {
    padding: 8px 10px calc(14px + env(safe-area-inset-bottom, 0px));
  }
  .files.grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    justify-content: stretch;
    width: 100%;
  }
  .tile { border-radius: 10px; min-width: 0; }
  .thumb { min-height: 56px; }
  .meta { padding: 5px 3px 6px; }
  .meta strong, .row .name { font-size: 10px; line-height: 1.3; }
  .meta small { font-size: 9px; }
  .selection {
    margin: 8px 10px 0;
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .selection::-webkit-scrollbar { display: none; }
  .selection #sel-count {
    flex-shrink: 0;
    font-size: 13px;
    white-space: nowrap;
  }
  .selection button {
    flex-shrink: 0;
    padding: 9px 14px;
    font-size: 14px;
    min-height: 42px;
  }
  .crumbs .crumb { font-size: 14px; max-width: min(280px, 55vw); }
}

@media (prefers-reduced-motion: reduce) {
  .login-aurora, .login-horizon, .login-card, .login-card::before,
  .login-mark-orbit, .login-mark-core, .login-card h1,
  .login-card button[type="submit"]::after,
  .app-aurora, .app-title, button.primary, button.primary::before,
  button.primary::after, .app-body .tools button::after, .app-body .nav::after,
  .app-body header .ghost::after, .app-body .selection button::after,
  .app-body .view-toggle button::after, .play {
    animation: none;
  }
  .play { transform: translate(-50%, -50%); }
  .login-horizon { transform: none; opacity: 0.25; }
}
