:root{
  --ink:#0b0b0b;
  --muted: rgba(20,30,55,.62);

  /* HUB-like background */
  --bgA:#f8fbff;
  --bgB:#dfe8f5;
  --accent:#5aa7ff;
  --accent2:#9be2ff;

  /* Panels (save-point vibe) */
  --panel:#ffffff;
  --panel2:#fbfbfb;
  --line: rgba(0,0,0,.12);

  --shadow: 0 22px 70px rgba(7,16,30,.14);
  --shadow2: 0 10px 22px rgba(7,16,30,.10);

  --radius: 16px;

  --thumb: 170px; /* set by JS */
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  overflow:hidden;
  color:var(--ink);
  font-family:"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  background:
    radial-gradient(1200px 780px at 60% 8%, rgba(90,167,255,.20), transparent 66%),
    radial-gradient(900px 620px at 18% 40%, rgba(155,226,255,.16), transparent 64%),
    linear-gradient(180deg, var(--bgA), var(--bgB));
}

.bg:before{
  content:"";
  position:fixed; inset:0;
  pointer-events:none;
  opacity:.34;
  mix-blend-mode: overlay;
  z-index:0;
  background:
    repeating-linear-gradient(180deg,
      rgba(0,0,0,.02) 0px, rgba(0,0,0,.02) 1px,
      rgba(255,255,255,0) 6px, rgba(255,255,255,0) 12px
    );
}
.bg:after{
  content:"";
  position:fixed; inset:0;
  pointer-events:none;
  opacity:.10;
  mix-blend-mode: overlay;
  z-index:0;
  background-image:
    radial-gradient(circle at 12% 25%, rgba(0,0,0,.20) 0 1px, transparent 2px),
    radial-gradient(circle at 38% 65%, rgba(0,0,0,.14) 0 1px, transparent 2px),
    radial-gradient(circle at 76% 18%, rgba(0,0,0,.18) 0 1px, transparent 2px),
    radial-gradient(circle at 88% 72%, rgba(0,0,0,.12) 0 1px, transparent 2px),
    radial-gradient(circle at 55% 40%, rgba(0,0,0,.14) 0 1px, transparent 2px);
}

.scan{
  position:fixed; inset:0;
  pointer-events:none;
  opacity:.08;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,.06) 0px,
    rgba(0,0,0,.06) 1px,
    transparent 2px,
    transparent 6px
  );
  mix-blend-mode: multiply;
  z-index:0;
}

/* Topbar */
.topbar{
  position:fixed;
  top:14px; left:14px; right:14px;
  z-index:10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border:1px solid var(--line);
  box-shadow: var(--shadow);
}
.top-left, .top-mid, .top-right{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.top-mid{ gap:6px; justify-content:center; flex:1; }
.top-left{ min-width: 220px; }
.top-right{ min-width: 160px; justify-content:flex-end; }

.crumb{ font-size:11px; color: rgba(0,0,0,.55); letter-spacing:.08em; text-transform:uppercase; }
.crumb.active{ color: rgba(0,0,0,.9); }
.sep{ color: rgba(0,0,0,.25); }

.chip{
  font-size:10px;
  letter-spacing:.14em;
  text-transform:uppercase;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid var(--line);
  background: var(--panel2);
  white-space:nowrap;
}
.muted{ color: rgba(0,0,0,.55); font-size:11px; }

.btn{
  cursor:pointer;
  border:1px solid var(--line);
  background: var(--panel2);
  color: var(--ink);
  border-radius:999px;
  padding:7px 10px;
  font-size:11px;
  letter-spacing:.10em;
  text-transform:uppercase;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  box-shadow: 0 1px 0 rgba(0,0,0,.05);
  transition: transform 120ms ease, box-shadow 160ms ease, background 160ms ease;
}
.btn:hover{ background:#fff; box-shadow: var(--shadow2); }
.btn:active{ transform: translate3d(0,1px,0) scale(.99); }
.btn.small{ padding:6px 9px; font-size:10px; }
.btn[disabled]{ opacity:.55; cursor:default; box-shadow:none; }
.btn[disabled]:hover{ background: var(--panel2); }

.iconbtn{
  cursor:pointer;
  border:1px solid var(--line);
  background:#fff;
  color:#000;
  border-radius:10px;
  width:34px; height:30px;
  display:grid;
  place-items:center;
  font-size:14px;
  transition: transform 120ms ease, box-shadow 160ms ease;
}
.iconbtn:hover{ box-shadow: var(--shadow2); }
.iconbtn:active{ transform: translate3d(0,1px,0) scale(.99); }

/* Layout */
.layout{
  position:fixed;
  left:14px; right:14px;
  top: 84px;
  bottom: 14px;
  z-index:5;
  display:grid;
  grid-template-columns: 260px minmax(0,1fr) 340px;
  gap: 12px;
}

.panel{
  background: var(--panel);
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
  min-width:0;
}
.panel-hd{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid rgba(0,0,0,.08);
}
.panel-title{
  font-size:11px;
  letter-spacing:.10em;
  text-transform:uppercase;
  color: rgba(0,0,0,.70);
}
.panel-chip{
  font-size:10px;
  padding:3px 8px;
  border-radius:999px;
  border:1px solid rgba(0,0,0,.10);
  background: var(--panel2);
  color: rgba(0,0,0,.62);
}
.panel-bd{ padding:12px; }

/* Sidebar */
.folder-list{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.folder{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:9px 10px;
  border-radius: 12px;
  border:1px solid rgba(0,0,0,.10);
  background: var(--panel2);
  cursor:pointer;
  transition: transform 120ms ease, box-shadow 160ms ease, background 160ms ease;
}
.folder:hover{ background:#fff; box-shadow: var(--shadow2); transform: translateY(-1px); }
.folder.is-active{ background:#fff; box-shadow: var(--shadow2); border-color: rgba(0,0,0,.16); }
.folder .name{ font-size:11px; letter-spacing:.08em; text-transform:uppercase; color: rgba(0,0,0,.78); }
.folder .count{ font-size:10px; color: rgba(0,0,0,.55); border:1px solid rgba(0,0,0,.10); border-radius:999px; padding:2px 8px; background:#fff; }

.divider{
  height:1px;
  background: rgba(0,0,0,.10);
  margin:12px 0;
}

.mini-tools{ display:grid; gap:10px; }
.field{ display:grid; gap:6px; }
.label{ font-size:10px; letter-spacing:.12em; text-transform:uppercase; color: rgba(0,0,0,.55); }
.input{
  width:100%;
  border:1px solid rgba(0,0,0,.12);
  background:#fff;
  border-radius: 12px;
  padding:10px 10px;
  font-family:inherit;
  font-size:12px;
  outline:none;
}
.input:focus{ border-color: rgba(0,0,0,.22); }
.row{ display:flex; gap:8px; }

/* Grid */
.grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb), 1fr));
  gap: 10px;
}
.tile{
  border:1px solid rgba(0,0,0,.12);
  border-radius: 14px;
  background:#fff;
  overflow:hidden;
  cursor:pointer;
  box-shadow: var(--shadow2);
  transition: transform 140ms ease, box-shadow 160ms ease;
  display:grid;
  grid-template-rows: auto auto;
}
.tile:hover{ transform: translateY(-2px); box-shadow: 0 26px 75px rgba(0,0,0,.18); }
.tile:active{ transform: translateY(0px); }

.thumb{
  width:100%;
  aspect-ratio: 16/10;
  background: #f4f4f4;
  display:grid;
  place-items:center;
}
.thumb img{
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
}
.tile-bot{
  padding:10px 10px 11px;
  border-top:1px solid rgba(0,0,0,.08);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.tname{
  font-size:11px;
  letter-spacing:.06em;
  color: rgba(0,0,0,.72);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.tag{
  font-size:10px;
  padding:2px 8px;
  border-radius:999px;
  border:1px solid rgba(0,0,0,.10);
  background: var(--panel2);
  color: rgba(0,0,0,.55);
  text-transform:uppercase;
  letter-spacing:.12em;
  white-space:nowrap;
}
.tile.is-selected{ outline:2px solid rgba(0,0,0,.65); outline-offset:2px; }

/* Preview */
.preview-box{
  position:relative;
  width:100%;
  aspect-ratio: 16/10;
  border:1px solid rgba(0,0,0,.12);
  border-radius: 14px;
  overflow:hidden;
  background:#0b0b0b;
  box-shadow: var(--shadow2);
  display:grid;
  place-items:center;
}
.preview-box img{
  max-width:100%;
  max-height:100%;
  object-fit:contain;
  display:none;
}
.preview-empty{
  text-align:center;
  font-size:12px;
  color: rgba(255,255,255,.86);
  letter-spacing:.06em;
}
.meta{ margin-top:10px; }
.meta-title{
  font-size:12px;
  letter-spacing:.06em;
  color: rgba(0,0,0,.82);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.meta-sub{
  margin-top:4px;
  font-size:11px;
  color: rgba(0,0,0,.55);
}
.actions{
  margin-top:10px;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

/* Help modal */
.help{
  position:fixed; inset:0;
  z-index:60;
  display:none;
}
.help.is-open{ display:block; }
.help-backdrop{
  position:absolute; inset:0;
  background: rgba(0,0,0,.38);
}
.help-card{
  position:absolute;
  left:50%; top:50%;
  transform: translate(-50%,-50%);
  width:min(520px, 92vw);
  background:#fff;
  border:1px solid rgba(0,0,0,.14);
  border-radius: 18px;
  box-shadow: 0 30px 90px rgba(0,0,0,.25);
  overflow:hidden;
}
.help-hd{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid rgba(0,0,0,.10);
}
.help-bd{ padding:12px; color: rgba(0,0,0,.70); font-size:12px; }
.line{ display:flex; align-items:center; gap:10px; padding:6px 0; }
.kbd{
  display:inline-block;
  padding:2px 7px;
  border:1px solid rgba(0,0,0,.14);
  border-bottom-width:2px;
  border-radius:8px;
  background:#fff;
  font-size:10px;
  letter-spacing:.08em;
}

/* Viewer modal */
.viewer{
  position:fixed; inset:0;
  z-index:70;
  display:none;
}
.viewer.is-open{ display:block; }
.viewer-backdrop{
  position:absolute; inset:0;
  background: rgba(0,0,0,.72);
}
.viewer-card{
  position:absolute;
  left:50%; top:50%;
  transform: translate(-50%,-50%);
  width: min(980px, 92vw);
  height: min(720px, 82vh);
  background:#fff;
  border-radius: 18px;
  border:1px solid rgba(0,0,0,.14);
  box-shadow: 0 30px 90px rgba(0,0,0,.45);
  overflow:hidden;
  display:grid;
  grid-template-rows: auto 1fr auto;
}
.viewer-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid rgba(0,0,0,.12);
}
.viewer-title{ display:flex; align-items:center; gap:10px; min-width:0; }
.viewer-name{
  font-size:12px;
  letter-spacing:.06em;
  color: rgba(0,0,0,.65);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.viewer-actions{ display:flex; gap:8px; }
.viewer-body{
  background:#0b0b0b;
  display:grid;
  place-items:center;
}
.viewer-body img{
  max-width:100%;
  max-height:100%;
  object-fit:contain;
  display:block;
}
.viewer-bot{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-top:1px solid rgba(0,0,0,.12);
}
.viewer-meta{
  font-size:10px;
  color: rgba(0,0,0,.55);
  letter-spacing:.08em;
  text-transform:uppercase;
}
.viewer-bot-actions{ display:flex; gap:8px; }

/* Responsive */
@media (max-width:1100px){
  .layout{ grid-template-columns: 260px minmax(0,1fr); }
  .preview{ display:none; }
  .top-left{ min-width: 140px; }
}
@media (max-width:820px){
  .layout{ grid-template-columns: 1fr; top: 92px; }
  .sidebar{ order:2; }
  .main{ order:1; }
  .top-mid{ display:none; }
}
