:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e7e9ee;
  --border-strong: #d6d9e0;
  --text: #1a1d23;
  --muted: #6b7280;
  --faint: #9aa1ad;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-ring: rgba(79,70,229,.35);
  --danger: #e5484d;
  --danger-hover: #cf3438;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08), 0 2px 4px rgba(16,24,40,.04);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14);
  --ease: cubic-bezier(.22,1,.36,1);
}
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { margin: 0; font: 14px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; }
::selection { background: var(--primary-soft); }

/* scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #d3d7df; border-radius: 8px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: #b9bfca; }

/* ---------- buttons: clear hierarchy + emphasis ---------- */
button, .btn {
  cursor: pointer; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 15px; font-weight: 600; font-size: 13px; font-family: inherit;
  background: var(--primary); color: #fff; line-height: 1;
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  box-shadow: 0 1px 2px rgba(79,70,229,.25); transition: background .15s, box-shadow .15s, border-color .15s, color .15s;
}
button:hover, .btn:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(79,70,229,.3); }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
button.sec { background: #eef0f4; color: #363b45; box-shadow: none; border-color: var(--border); }
button.sec:hover { background: #e4e7ec; box-shadow: none; }
button.warn { background: var(--danger); box-shadow: 0 1px 2px rgba(229,72,77,.25); }
button.warn:hover { background: var(--danger-hover); box-shadow: 0 4px 12px rgba(229,72,77,.3); }
button.ghost { background: transparent; color: var(--muted); box-shadow: none; border-color: transparent; padding: 7px 9px; }
button.ghost:hover { background: #f1f2f4; color: var(--text); }

/* ---------- inputs ---------- */
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 11px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover { border-color: #c2c7d0; }
select { cursor: pointer; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
aside#sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; color: var(--primary); padding: 4px 10px 20px; letter-spacing: -.01em; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius); color: #454b56; text-decoration: none; font-weight: 600; margin-bottom: 3px; transition: background .15s, color .15s; position: relative; }
.nav a .ico { width: 20px; text-align: center; font-size: 16px; }
.nav a:hover { background: #f3f4f6; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }

main.content { padding: 26px 30px; max-width: 1400px; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0; font-weight: 750; letter-spacing: -.02em; }
.page-head .spacer { flex: 1; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar input.search { flex: 1; padding: 11px 14px; border-radius: var(--radius); }

/* ---------- categories + grid ---------- */
.work { display: grid; grid-template-columns: 232px 1fr; gap: 22px; align-items: start; }
.cats { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; box-shadow: var(--shadow-sm); }
.cats-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 14px; }
.cats-head button { padding: 5px 10px; font-size: 12px; }
.cat { display: flex; justify-content: space-between; align-items: center; padding: 9px 11px; border-radius: var(--radius-sm); cursor: pointer; color: #454b56; font-weight: 600; transition: background .15s, color .15s; }
.cat:hover { background: #f3f4f6; }
.cat.active { background: var(--primary-soft); color: var(--primary); }
.cat .cnt { color: var(--faint); font-size: 12px; font-weight: 700; }
.cat .x { color: var(--danger); font-size: 12px; margin-left: 8px; opacity: 0; transition: opacity .15s; }
.cat:hover .x { opacity: 1; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; position: relative; }
.card .thumb { aspect-ratio: 1/1; background: conic-gradient(#eef0f3 25%, #fff 0 50%, #eef0f3 0 75%, #fff 0) 0/22px 22px; display: flex; align-items: center; justify-content: center; }
.card .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card .body { padding: 13px 15px; }
.card .body .name { font-weight: 700; color: var(--primary); word-break: break-all; letter-spacing: -.01em; }
.card .body .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.card .actions { display: flex; gap: 8px; padding: 0 15px 14px; }
.card .actions button { flex: 1; padding: 8px; font-size: 12px; }
.empty { color: var(--muted); padding: 44px; text-align: center; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-2); }

/* kebab overlay on cards */
.card .kmenu { position: absolute; top: 10px; right: 10px; z-index: 6; }
.card .kmenu .menu-pop { top: 38px; right: 0; }
.kebab { width: 30px; height: 30px; padding: 0; border-radius: 8px; background: rgba(255,255,255,.92); color: #4b5563; box-shadow: var(--shadow-sm); border: 1px solid var(--border); font-size: 17px; line-height: 1; }
.kebab:hover { background: #fff; color: var(--text); }

/* ---------- dropdown menu (click) ---------- */
.menu { position: relative; }
.menu-pop { position: absolute; z-index: 40; min-width: 168px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; }
.menu-pop.right { right: 0; }
.menu-pop.open { display: block; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 9px 11px; border-radius: var(--radius-sm); background: none; color: var(--text); font-weight: 600; font-size: 13px; box-shadow: none; border: 0; }
.menu-item:hover { background: #f3f4f6; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ---------- image zoom (in-card) + lightbox ---------- */
.imgzoom { position: relative; cursor: zoom-in; display: block; }
.imgzoom .zoombadge { position: absolute; right: 8px; bottom: 8px; background: rgba(17,24,39,.82); color: #fff; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 99px; opacity: 0; transition: opacity .15s; pointer-events: none; }
.imgzoom:hover .zoombadge { opacity: 1; }

#lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(12,14,18,.9); display: none; align-items: center; justify-content: center; overflow: hidden; }
#lightbox.open { display: flex; }
#lightbox .lb-img { max-width: 92vw; max-height: 92vh; user-select: none; -webkit-user-drag: none; will-change: transform; cursor: zoom-in; image-rendering: auto; }
#lightbox .lb-img.zoomed { cursor: grab; }
#lightbox .lb-close { position: fixed; top: 18px; right: 22px; width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 18px; box-shadow: none; }
#lightbox .lb-close:hover { background: rgba(255,255,255,.26); }
#lightbox .lb-bar { position: fixed; top: 18px; left: 22px; display: flex; gap: 8px; align-items: center; color: #e5e7eb; font-size: 13px; }
#lightbox .lb-bar .pct { min-width: 54px; font-weight: 700; }
#lightbox .lb-bar button { background: rgba(255,255,255,.14); color: #fff; box-shadow: none; padding: 6px 10px; }
#lightbox .lb-hint { position: fixed; bottom: 16px; left: 0; right: 0; text-align: center; color: #cbd0d8; font-size: 12px; }

/* ---------- fonts list ---------- */
.list { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.list .item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow-sm); }
.list .item .fname { font-weight: 700; width: 200px; }
.list .item .sample { flex: 1; font-size: 27px; color: var(--text); overflow: hidden; white-space: nowrap; }

/* ---------- user box + menu ---------- */
.userbox { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.userchip { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px; border-radius: var(--radius); background: none; color: var(--text); box-shadow: none; border: 1px solid transparent; }
.userchip:hover { background: #f3f4f6; }
.userchip .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: 0 0 auto; }
.userchip .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; overflow: hidden; }
.userchip .who b { font-size: 13px; }
.userchip .who .role { font-size: 11px; color: var(--muted); font-weight: 600; }
.userchip .caret { margin-left: auto; color: var(--faint); }

/* ---------- mobile / responsive ---------- */
@media (max-width: 860px) {
  /* sidebar becomes a sticky horizontal top bar, links scroll sideways */
  .layout { grid-template-columns: 1fr; }
  aside#sidebar { flex-direction: row; align-items: center; gap: 6px; padding: 8px 10px;
    border-right: none; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .brand { padding: 0 6px 0 2px; font-size: 16px; flex: 0 0 auto; white-space: nowrap; }
  .nav { display: flex; gap: 4px; flex: 0 0 auto; }
  .nav a { margin-bottom: 0; padding: 8px 11px; white-space: nowrap; }
  .nav a.active::before { display: none; }
  .userbox { margin-top: 0; margin-left: auto; padding-top: 0; border-top: none; flex: 0 0 auto; }
  .userchip { padding: 5px; }
  .userchip .who { display: none; }   /* keep avatar, drop name to save room */

  main.content { padding: 14px 12px; }
  .page-head { flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
  .page-head h1 { font-size: 20px; }
  .toolbar { flex-wrap: wrap; gap: 8px; }

  /* artworks: stack category rail above the grid; denser thumbnails */
  .work { grid-template-columns: 1fr; gap: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }

  /* fonts list wraps instead of fixed-width columns */
  .list .item { flex-wrap: wrap; gap: 8px; }
  .list .item .fname { width: auto; }
  .list .item .sample { font-size: 20px; flex-basis: 100%; }
}
