/* /system/style.css */
/* Optional custom font (uncomment if you have system/melted.monster.ttf)
@font-face{
  font-family:"MeltedMonster";
  src:url("melted.monster.ttf") format("truetype");
  font-weight:normal;
  font-style:normal;
  font-display:swap;
}
*/
:root{
  --bg0:#05040a;
  --bg1:#0a0812;
  --panel:rgba(8,8,12,.62);
  --panel2:rgba(14,12,20,.72);
  --fg:rgba(245,245,255,.94);
  --muted:rgba(245,245,255,.66);
  --faint:rgba(245,245,255,.46);
  --line:rgba(255,255,255,.09);
  --line2:rgba(255,255,255,.14);
  --accent:#9b4dff;
  --accent2:#4b2bff;
  --accent3:#2a1a55;
  --r:14px;
  --pad:12px;
  --pad2:10px;
  --mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
  --ui:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  --logo:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  --shadow: 0 18px 60px rgba(0,0,0,.55);
}
*{box-sizing:border-box}
html,body{height:100%;width:100%;overflow:hidden}

body{
  margin:0;
  color:var(--fg);
  font-family:var(--ui);
  background:
    radial-gradient(1400px 900px at 20% 15%, rgba(155,77,255,.12), transparent 60%),
    radial-gradient(1200px 900px at 75% 75%, rgba(75,43,255,.10), transparent 62%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  background-image:
    url("bg-dystopia.png"),
    radial-gradient(1400px 900px at 20% 15%, rgba(155,77,255,.12), transparent 60%),
    radial-gradient(1200px 900px at 75% 75%, rgba(75,43,255,.10), transparent 62%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  background-repeat:no-repeat;
  background-size:cover;
  background-position:center;
  background-attachment:fixed;
  overflow:hidden;
  overscroll-behavior:none;
}
body.no-scroll{overflow:hidden}
@media (max-width: 900px), (hover: none){
  body{background-attachment:scroll}
}

.topload{
  position:fixed;
  top:0;
  left:0;
  right:0;
  z-index:60;
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  background:rgba(7,7,9,.90);
  border-bottom:1px solid rgba(255,255,255,.12);
  pointer-events:none;
  opacity:0;
  transform:translateY(-100%);
  transition:opacity .16s ease, transform .16s ease;
}
.topload.is-visible{
  opacity:1;
  transform:translateY(0);
}
.topload-track{
  flex:1;
  height:7px;
  border-radius:999px;
  background:#676a76;
  overflow:hidden;
}
.topload-bar{
  width:0%;
  height:100%;
  border-radius:inherit;
  background:#ffffff;
  transition:width .12s linear;
}
.topload-pct{
  color:#ffffff;
  font-size:11px;
  font-weight:800;
  letter-spacing:.3px;
  min-width:38px;
  text-align:right;
}

.fx{
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:1;
}
.fx-scan{
  opacity:.10;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(255,255,255,.06) 0px,
      rgba(255,255,255,.02) 1px,
      rgba(0,0,0,0) 2px,
      rgba(0,0,0,0) 5px
    );
  mix-blend-mode:overlay;
}
.fx-grain{
  opacity:.10;
  background:
    radial-gradient(circle at 15% 15%, rgba(255,255,255,.08), transparent 42%),
    radial-gradient(circle at 85% 25%, rgba(155,77,255,.08), transparent 46%),
    radial-gradient(circle at 35% 85%, rgba(75,43,255,.07), transparent 44%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0, rgba(255,255,255,0) 2px);
  filter: blur(.2px);
  animation: drift 10s linear infinite;
  mix-blend-mode:soft-light;
}
@keyframes drift{
  0%{transform:translate3d(0,0,0)}
  100%{transform:translate3d(-32px,18px,0)}
}

.app{
  position:fixed;
  inset:0;
  z-index:2;
  height:100vh;
  height:100dvh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.topbar{
  position:relative;
  top:0;
  z-index:30;
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px 10px;
  background:
    radial-gradient(900px 200px at 30% 0%, rgba(155,77,255,.18), transparent 58%),
    rgba(0,0,0,.42);
  border-bottom:1px solid rgba(255,255,255,.10);
  backdrop-filter:saturate(115%) blur(8px);
}

.brand{display:flex;flex-direction:column;min-width:0;gap:2px}
.brand-title{
  font-family:var(--logo);
  letter-spacing:1px;
  font-size:20px;
  line-height:1.1;
  text-transform:uppercase;
  color:rgba(245,245,255,.96);
  text-shadow: 0 12px 30px rgba(0,0,0,.70);
}

.mono{font-family:var(--mono)}

.stats{
  margin-left:auto;
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.stat{
  display:flex;
  align-items:baseline;
  gap:8px;
  padding:8px 10px;
  border-radius:12px;
  background:rgba(0,0,0,.28);
  border:1px solid var(--line);
}
.stat .k{
  font-size:11px;
  letter-spacing:1px;
  color:var(--faint);
}
.stat .v{font-weight:800; white-space:nowrap; max-width: 34vw; overflow:hidden; text-overflow:ellipsis}
.stat-folder{
  gap:6px;
  align-items:center;
  min-width:220px;
}

.shell{
  flex:1;
  display:grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap:10px;
  padding:10px;
  align-items:stretch;
  min-height:0;
  overflow:hidden;
}

.sidebar{
  border-radius:16px;
  border:1px solid var(--line);
  background:var(--panel);
  box-shadow: var(--shadow);
  overflow:hidden;
  min-height:0;
  display:flex;
  flex-direction:column;
}
.side-head{
  padding:10px 12px;
  border-bottom:1px solid rgba(255,255,255,.08);
  background:
    radial-gradient(700px 220px at 40% 0%, rgba(155,77,255,.16), transparent 60%),
    rgba(0,0,0,.20);
}
.side-title{
  font-size:12px;
  letter-spacing:1.2px;
  text-transform:uppercase;
  color:rgba(245,245,255,.86);
  font-weight:900;
}
.side-path{margin-top:4px;font-size:12px;color:var(--muted);opacity:.9;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.side-controls{padding:10px 12px;border-bottom:1px solid rgba(255,255,255,.08);background:rgba(0,0,0,.18)}
.select{
  width:100%;
  padding:10px 34px 10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background-color:#000000;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(245,245,255,.90) 50%),
    linear-gradient(135deg, rgba(245,245,255,.90) 50%, transparent 50%),
    linear-gradient(rgba(255,255,255,.20), rgba(255,255,255,.20));
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px),
    calc(100% - 28px) 50%;
  background-size:5px 5px, 5px 5px, 1px 16px;
  background-repeat:no-repeat;
  color:var(--fg);
  font-family:var(--ui);
  font-weight:800;
  letter-spacing:.2px;
  outline:none;
  appearance:none;
  -webkit-appearance:none;
  -moz-appearance:none;
  color-scheme: dark;
}
.select option{
  background:#000000;
  color:#ffffff;
}
.select.select-compact{
  width:min(260px, 52vw);
  padding:7px 34px 7px 9px;
  border-radius:10px;
  font-size:12px;
  font-weight:700;
}

.thumbs{
  padding:10px;
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  grid-auto-flow:row;
  gap:6px;
  overflow-y:auto;
  overflow-x:hidden;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  align-content:start;
  min-height:0;
}
.thumb{
  border-radius:12px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(0,0,0,.32);
  cursor:pointer;
  position:relative;
  min-height:76px;
}
.thumb::before{
  content:"";
  display:block;
  padding-top:100%;
}
.thumb img{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
  opacity:.88;
  transition: transform .12s ease, opacity .12s ease, filter .12s ease;
  filter:saturate(1.05) contrast(1.05);
}
.thumb:hover img{opacity:1; transform:scale(1.03)}
.thumb.is-active{border-color: rgba(155,77,255,.70)}
.thumb.is-active::after{
  content:"";
  position:absolute;
  inset:0;
  border:2px solid rgba(75,43,255,.50);
  border-radius:12px;
  pointer-events:none;
}

.viewer{
  border-radius:16px;
  border:1px solid var(--line);
  background:var(--panel2);
  box-shadow: var(--shadow);
  overflow:hidden;
  min-height:0;
  display:flex;
  flex-direction:column;
}
.stage{
  position:relative;
  flex:1;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:
    radial-gradient(900px 300px at 50% 0%, rgba(155,77,255,.10), transparent 65%),
    rgba(0,0,0,.32);
  border-bottom:1px solid rgba(255,255,255,.08);
}
#viewer{
  width:100%;
  height:100%;
  max-width:100%;
  max-height:100%;
  object-fit:contain;
  opacity:0;
  transition:opacity .16s ease;
  cursor:zoom-in;
  touch-action:none;
  -webkit-tap-highlight-color: transparent;
  user-select:none;
}
#viewer.ready{opacity:1}

.hud{
  position:absolute;
  left:10px;
  right:10px;
  bottom:10px;
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:10px;
}
.hud-left,
.hud-right{
  padding:8px 10px;
  border-radius:12px;
  background:rgba(0,0,0,.50);
  border:1px solid rgba(255,255,255,.12);
  color:rgba(245,245,255,.86);
}
.hud-left{
  flex:1;
  min-width:0;
  max-height:72px;
  overflow:hidden;
  transition:
    opacity .24s ease,
    transform .24s ease,
    max-height .24s ease,
    padding .24s ease,
    border-color .24s ease,
    background-color .24s ease;
}
.hud-right{
  flex:0 0 auto;
  max-width:52%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.loadbar-track{
  height:10px;
  border-radius:999px;
  background:rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.14);
  overflow:hidden;
}
.loadbar-fill{
  width:0%;
  height:100%;
  border-radius:inherit;
  background:linear-gradient(90deg, rgba(155,77,255,.92), rgba(75,43,255,.82));
  box-shadow: 0 0 18px rgba(155,77,255,.45);
  transition:width .16s ease;
}
.loadbar-meta{
  margin-top:6px;
  font-size:11px;
  letter-spacing:.35px;
  color:var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.hud-left.is-complete{
  opacity:0;
  transform:translateY(4px);
  max-height:0;
  padding-top:0;
  padding-bottom:0;
  border-color:transparent;
  background:transparent;
}

.controls{
  display:flex;
  gap:8px;
  padding:10px 10px 10px;
  align-items:center;
  justify-content:center;
}
.btn{
  appearance:none;
  border:none;
  cursor:pointer;
  border-radius:12px;
  padding:10px 14px;
  color:var(--fg);
  font-family:var(--ui);
  font-weight:900;
  letter-spacing:.2px;
  background: linear-gradient(135deg, rgba(155,77,255,.74), rgba(75,43,255,.52));
  border:1px solid rgba(255,255,255,.14);
  box-shadow: 0 14px 34px rgba(0,0,0,.45);
  transition: transform .10s ease, filter .10s ease, opacity .10s ease;
}
.btn:hover{filter:brightness(1.06)}
.btn:active{transform:translateY(1px)}
.btn:disabled{opacity:.55; cursor:not-allowed}
.btn.ghost{background:rgba(0,0,0,.22); border:1px solid rgba(255,255,255,.12)}

.note{
  padding:0 12px 12px;
  min-height:22px;
  color:var(--muted);
  font-size:13px;
}

/* mobile layout */
@media (max-width: 900px){
  .topbar{
    gap:8px;
    flex-wrap:wrap;
    align-items:flex-start;
    padding:8px 10px 8px;
  }
  .brand{flex:1 1 auto; min-width:130px}
  .stats{
    width:100%;
    margin-left:0;
    justify-content:space-between;
    gap:6px;
  }
  .select.select-compact{
    width:100%;
  }
  .stat{
    flex:1 1 calc(33.333% - 6px);
    min-width:0;
    justify-content:space-between;
    padding:7px 8px;
  }
  .stat-folder{
    flex:1 1 100%;
    min-width:0;
  }
  .stats .stat .v{max-width:100%; font-size:12px}
  .shell{
    grid-template-columns:1fr;
    padding:8px;
    gap:8px;
  }
  .sidebar{
    position:relative;
    width:100%;
    max-height:42vh;
    z-index:auto;
    transform:none;
    transition:none;
  }
  .viewer{border-radius:14px}
  .hud{
    left:8px;
    right:8px;
    bottom:8px;
  }
  .hud-right{max-width:58vw}
}
@media (max-width: 700px){
  .stat{flex:1 1 calc(50% - 6px)}
  .stat:last-child{flex-basis:100%}
  .stat-folder{flex-basis:100%}
  .hud{
    flex-direction:column;
    align-items:stretch;
  }
  .hud-right{
    align-self:flex-end;
    max-width:100%;
  }
  .controls{
    display:grid;
    grid-template-columns:repeat(3, minmax(0, 1fr));
    gap:6px;
    padding:8px 8px 10px;
  }
  .btn{
    width:100%;
    padding:10px 8px;
  }
}
@media (max-width: 520px){
  .topbar{
    gap:6px;
    padding:6px 8px 8px;
  }
  .brand-title{
    font-size:16px;
    letter-spacing:.9px;
  }
  .stats{gap:5px}
  .stat{
    padding:6px 7px;
    border-radius:10px;
  }
  .stat .k{
    font-size:9px;
    letter-spacing:.8px;
  }
  .stats .stat .v{font-size:11px}
  .thumbs{
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap:5px;
    padding:8px;
  }
  .hud{gap:6px}
  .hud-left,
  .hud-right{
    padding:7px 8px;
    border-radius:10px;
  }
  .loadbar-track{height:12px}
  .loadbar-meta{
    margin-top:5px;
    font-size:10px;
  }
  .controls{padding:8px 8px 10px}
  .btn{
    padding:10px 8px;
    font-size:13px;
  }
}

/* fullscreen overlay */
.lightbox{
  position:fixed;
  inset:0;
  z-index:9999;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.92);
  touch-action:none;
  -webkit-tap-highlight-color: transparent;
}
.lightbox[hidden]{display:none}
.lightbox img{
  width:100vw;
  height:100vh;
  max-width:100vw;
  max-height:100vh;
  object-fit:contain;
  object-position:center center;
  cursor: zoom-out;
  user-select:none;
  -webkit-user-drag:none;
  touch-action:none;
}
.lightbox .lb-close{
  position:fixed;
  top:12px;
  right:12px;
  z-index:10000;
  width:54px;
  height:54px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.40);
  color:rgba(255,255,255,.92);
  font-family:var(--ui);
  font-size:38px;
  font-weight:900;
  line-height:1;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow: 0 18px 40px rgba(0,0,0,.55);
  user-select:none;
  -webkit-tap-highlight-color: transparent;
}
.lightbox .lb-close:active{transform: translateY(1px)}
.lightbox .lb-close:focus{outline:none}
.lightbox .lb-nav{
  position:fixed;
  top:50%;
  transform:translateY(-50%);
  z-index:10000;
  width:56px;
  height:56px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.42);
  color:rgba(255,255,255,.94);
  font-family:var(--ui);
  font-size:40px;
  line-height:1;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow: 0 18px 40px rgba(0,0,0,.55);
  user-select:none;
  -webkit-tap-highlight-color: transparent;
}
.lightbox .lb-prev{left:12px}
.lightbox .lb-next{right:12px}
.lightbox .lb-nav:disabled{
  opacity:.45;
  cursor:default;
}
.lightbox.cover img{width:100vw;height:100vh;object-fit:cover}

@media (prefers-reduced-motion: reduce){
  .fx-grain{
    animation:none;
    filter:none;
    opacity:.06;
  }
  .thumb img,
  #viewer,
  .hud-left,
  .loadbar-fill,
  .btn,
  .sidebar{
    transition:none !important;
  }
}
