:root {
  --bg:#0f1115; --panel:#171a21; --panel-2:#1b1f2a;
  --text:#e8eef5; --muted:#a7b0be; --accent:#7aa2f7;
  --border:#242a36; --shadow:rgba(0,0,0,.35);
  --sidebar:280px; --sidebar-collapsed:56px;
}
:root.light {
  --bg:#f6f7fb; --panel:#fff; --panel-2:#f2f4f8;
  --text:#1c2230; --muted:#5a6475; --accent:#335dff;
  --border:#dde3ef; --shadow:rgba(0,0,0,.08);
}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;background:var(--bg);color:var(--text)}

.shell{display:grid;grid-template-columns:var(--sidebar) 1fr;min-height:100vh;transition:grid-template-columns .25s ease}
.shell.collapsed{--sidebar:var(--sidebar-collapsed);grid-template-columns:var(--sidebar) 1fr}

/* Sidebar */
.sidebar{background:var(--panel);border-right:1px solid var(--border);padding:.75rem;overflow:hidden;display:flex;flex-direction:column}
.brand{display:flex;align-items:center;gap:.5rem;padding:.5rem;font-weight:600;opacity:.95}
.brand span{flex:1}
.section{margin-top:.75rem}
.section h4{margin:.5rem;font-size:.85rem;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)}
.nav{display:flex;flex-direction:column;gap:.25rem}
.nav button{padding:.6rem .65rem;border-radius:.6rem;border:1px solid transparent;background:transparent;color:var(--text);cursor:pointer;text-align:left}
.nav button.active,.nav button:hover{background:var(--panel-2);border-color:var(--border)}
.shell.collapsed .sidebar .section{display:none}
.shell.collapsed .sidebar .brand span{display:none}

/* Top tools */
.content{padding:1.25rem 1.25rem 2rem}
.board{max-width:1100px;margin:0 auto;background:var(--panel);border:1px solid var(--border);border-radius:1rem;box-shadow:0 10px 30px var(--shadow)}
.board-head{display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:1rem 1rem .5rem}
.board-title{font-size:1.6rem;font-weight:650;letter-spacing:.3px}
.tools{display:flex;gap:.5rem;align-items:center}
.icon-btn{width:36px;height:36px;display:grid;place-items:center;border-radius:.6rem;border:1px solid var(--border);background:var(--panel-2);cursor:pointer}
.search{display:flex;align-items:center;gap:.5rem;background:var(--panel-2);border:1px solid var(--border);border-radius:.6rem;padding:.4rem .6rem}
.search input{background:transparent;border:none;outline:none;color:var(--text);min-width:220px}

/* Filters */
.filters{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center;padding:.5rem 1rem;border-top:1px solid var(--border);border-bottom:1px solid var(--border);background:var(--panel)}
.segmented{display:flex;background:var(--panel-2);border:1px solid var(--border);border-radius:.6rem;padding:.25rem}
.seg-btn{border:none;background:transparent;color:var(--text);padding:.4rem .7rem;border-radius:.45rem;cursor:pointer}
.seg-btn[aria-selected="true"], .seg-btn:hover{background:var(--panel);border:1px solid var(--border)}
.filter-item{display:flex;gap:.5rem;align-items:center}
.filter-item select{background:var(--panel-2);color:var(--text);border:1px solid var(--border);border-radius:.6rem;padding:.4rem .5rem}

/* Grid */
.grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); /* column max width */
  gap:1rem;
  padding:.9rem 1rem 1.2rem;
}

/* Items: just image + title, centered */
.card{
  background:transparent;border:none;box-shadow:none;
  display:flex;flex-direction:column;align-items:center;
}

/* 🟢 Thumbnails
   - no fixed height → small images aren’t letterboxed
   - never upscale: width:auto; height:auto; max-width:100% of the column
   - larger images can show bigger (up to column width) */
.thumb{
  padding:0; height:auto;
  display:flex; align-items:flex-start; justify-content:center;
  background:transparent; color:var(--muted);
}
.thumb img{
  display:block;
  width:auto;             /* do not stretch */
  height:auto;            /* keep aspect ratio */
  max-width:100%;         /* cap at the column width */
  image-rendering:auto;
}
.thumb.no-img{display:flex;align-items:center;justify-content:center;min-height:40px}

/* Title */
.meta{padding:.45rem 0 0; width:100%; display:flex; justify-content:center}
.title{
  text-align:center;
  max-width:100%;         /* follow column width */
  margin:0 auto;
  font-weight:600;
  white-space:normal;
  word-break:break-word;
  line-height:1.25;
}

/* Pager */
.pager{display:flex;justify-content:center;align-items:center;gap:.5rem;padding:.6rem 1rem 1rem;color:var(--muted)}
.btn{padding:.4rem .7rem;border:1px solid var(--border);background:var(--panel-2);color:var(--text);border-radius:.6rem;cursor:pointer}
.btn:disabled{opacity:.55;cursor:not-allowed}
.page-size{display:flex;align-items:center;gap:.5rem;margin-right:auto;color:var(--muted)}
.page-size select{background:var(--panel-2);color:var(--text);border:1px solid var(--border);border-radius:.6rem;padding:.35rem .5rem}
