/* ==========================================================================
   SnippetLab — bookmarks, comments, command palette

   Same design system as app.css: near-black surfaces, 1px borders, radii
   bimodal between a pill and a card, colour only in small details.
   ========================================================================== */


/* ==================================================================== save

   Saved state reads through the filled icon plus a border lift, not a colour
   fill — a filled button at this size competes with "Copy code", which is the
   primary action on the page.
   ==================================================================== */

#detailSave.is-saved{
  border-color:var(--border-hover);
  color:var(--text);
  background:var(--chip);
}

#detailSave.is-saved .icon{color:var(--text)}
#detailSave:active{transform:translateY(1px)}


/* ================================================================= comments */

.comments{border-top:1px solid var(--border-subtle);margin-top:28px;padding-top:4px}

.comment-form{display:flex;flex-direction:column;gap:8px;margin-bottom:20px}

.comment-form .textarea{
  min-height:78px;
  font-family:var(--font-sans);
  font-size:12.5px;
  line-height:1.55;
  resize:vertical;
}

.comment-form-foot{display:flex;align-items:center;gap:10px}
.comment-form-foot .field-hint{flex:1;min-width:0}
.comment-form-foot .btn{flex-shrink:0}

.comment-list{display:flex;flex-direction:column;gap:2px}

.comment{
  display:flex;
  gap:10px;
  padding:12px 0;
  border-top:1px solid var(--border-subtle);
}

.comment:first-child{border-top:0}
.comment.is-deleted{opacity:.55}

.comment-avatar{
  flex:0 0 28px;
  width:28px;height:28px;
  border-radius:9px;
  border:1px solid var(--border);
  background:var(--chip-2);
  color:var(--text-muted);
  display:grid;place-items:center;
  font:600 11px/1 var(--font-sans);
  overflow:hidden;
}

.comment-avatar img{width:100%;height:100%;object-fit:cover;display:block}
.comment-main{flex:1;min-width:0}

.comment-meta{display:flex;align-items:center;gap:8px;margin-bottom:3px}
.comment-meta strong,
.comment-meta .link-btn{font:600 12px/1.3 var(--font-sans);color:var(--text)}

.comment-meta time{
  font-size:10px;
  color:var(--text-dim);
  font-variant-numeric:tabular-nums;
}

/* Delete sits at the far right and only appears on hover, so the row is not a
   permanent row of controls. Always visible on touch, where there is no hover. */
.comment-del{
  margin-left:auto;
  width:22px;height:22px;
  display:grid;place-items:center;
  border-radius:var(--r-sm);
  color:var(--text-dim);
  opacity:0;
  transition:opacity var(--ease),color var(--ease),background var(--ease);
}

.comment:hover .comment-del,
.comment:focus-within .comment-del{opacity:1}
.comment-del:hover{background:rgba(239,68,68,.1);color:var(--red)}

@media (hover:none){.comment-del{opacity:1}}

.comment-body{
  font-size:12.5px;
  line-height:1.6;
  color:var(--text-muted);
  white-space:pre-wrap;
  word-break:break-word;
}

.comment.is-deleted .comment-body{font-style:italic;color:var(--text-dim)}


/* ================================================================ palette

   One input over everything. Centred near the top rather than the middle,
   because the results list grows downward and a centred box jumps as it does.
   ================================================================ */

.palette{
  position:fixed;
  inset:0;
  z-index:80;
  display:none;
  align-items:flex-start;
  justify-content:center;
  padding:12vh 16px 16px;
  background:rgba(5,5,5,.72);
  backdrop-filter:blur(3px);
}

.palette.is-open{display:flex}

.palette-box{
  width:min(600px,100%);
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--r-card);
  box-shadow:var(--shadow-pop);
  overflow:hidden;
  animation:palette-in 140ms ease;
}

@keyframes palette-in{
  from{opacity:0;transform:translateY(-6px) scale(.99)}
  to{opacity:1;transform:none}
}

.palette-input-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:14px 16px;
  border-bottom:1px solid var(--border-subtle);
}

.palette-input-row .icon{color:var(--text-dim);flex-shrink:0}

.palette-input-row input{
  flex:1;
  min-width:0;
  border:0;
  background:none;
  outline:none;
  font-size:14px;
  color:var(--text);
}

.palette-input-row input::placeholder{color:var(--text-dim)}

.palette-esc{
  flex-shrink:0;
  padding:2px 6px;
  border:1px solid var(--border);
  border-radius:5px;
  font:500 9.5px/1.5 var(--font-mono);
  color:var(--text-dim);
  text-transform:uppercase;
}

.palette-results{
  max-height:min(52vh,380px);
  overflow-y:auto;
  padding:6px;
  scrollbar-width:thin;
  scrollbar-color:var(--border-hover) transparent;
}

.palette-results::-webkit-scrollbar{width:8px}
.palette-results::-webkit-scrollbar-thumb{background:var(--border);border-radius:var(--r-pill)}

.palette-row{
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  padding:9px 10px;
  border-radius:var(--r-sm);
  text-align:left;
  color:var(--text-muted);
  transition:background var(--ease),color var(--ease);
}

.palette-row .icon{flex-shrink:0;color:var(--text-dim)}

/* The active row is what Enter will run, so it has to be unmistakable. */
.palette-row.is-active{background:var(--chip-2);color:var(--text)}
.palette-row.is-active .icon{color:var(--text)}

.palette-label{
  font-size:12.5px;
  font-weight:500;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.palette-sub{
  margin-left:auto;
  flex-shrink:0;
  font-size:10px;
  color:var(--text-dim);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  max-width:40%;
}

.palette-empty{
  padding:22px 14px;
  text-align:center;
  font-size:11.5px;
  color:var(--text-dim);
}

.palette-foot{
  display:flex;
  align-items:center;
  gap:14px;
  padding:9px 16px;
  border-top:1px solid var(--border-subtle);
  background:var(--code-bg);
  font-size:10px;
  color:var(--text-dim);
}

.palette-foot kbd{
  display:inline-block;
  min-width:16px;
  padding:1px 4px;
  margin-right:2px;
  border:1px solid var(--border);
  border-radius:4px;
  font:500 9px/1.5 var(--font-mono);
  text-align:center;
  color:var(--text-faint);
}

.palette-brand{
  margin-left:auto;
  display:inline-flex;
  align-items:center;
  gap:3px;
  color:var(--text-faint);
}

.palette-brand .icon{width:12px;height:12px}


/* ================================================================== saved */

#savedGrid .card{cursor:default}
#savedGrid .card h3{font-size:14px}

#savedGrid .card-foot{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-top:12px;
}

#savedGrid .card-foot .btn .icon{width:12px;height:12px}

.card-tags{display:flex;flex-wrap:wrap;gap:4px;margin-top:10px}

.card-tags .tag{
  padding:2px 7px;
  border:1px solid var(--border-subtle);
  border-radius:var(--r-pill);
  font-size:9.5px;
  color:var(--text-dim);
}


/* ------------------------------------------------------------- responsive */

@media (max-width:560px){
  .palette{padding-top:8vh}
  .palette-sub{display:none}
  .comment-form-foot{flex-wrap:wrap}
  .comment-form-foot .btn{width:100%}
}


/* ================================================================ viewers

   The readers list, expanded from the view count in the byline. Inline under
   the byline rather than a modal: it is detail on the number you just pressed,
   and a modal would cover the snippet it describes.
   ================================================================ */

.byline-views{
  padding:0;
  border:0;
  background:none;
  font:inherit;
  color:inherit;
  cursor:pointer;
  text-decoration:underline;
  text-underline-offset:2px;
  text-decoration-color:var(--border-hover);
  transition:color var(--ease),text-decoration-color var(--ease);
}

.byline-views:hover{color:var(--text);text-decoration-color:var(--text-faint)}

.viewers{
  margin:14px 0 4px;
  border:1px solid var(--border);
  border-radius:var(--r-panel);
  background:var(--code-bg);
  overflow:hidden;
}

.viewers.hidden{display:none}

.viewers-head{
  display:flex;
  align-items:center;
  gap:8px;
  padding:10px 12px;
  border-bottom:1px solid var(--border-subtle);
}

.viewers-head strong{font:600 11.5px/1.3 var(--font-sans);color:var(--text)}

.viewers-head .faint{
  font-size:10.5px;
  color:var(--text-dim);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.viewers-close{
  margin-left:auto;
  width:22px;height:22px;
  display:grid;place-items:center;
  border-radius:var(--r-sm);
  color:var(--text-dim);
  flex-shrink:0;
  transition:background var(--ease),color var(--ease);
}

.viewers-close:hover{background:var(--chip-2);color:var(--text)}

.viewers-list{
  max-height:280px;
  overflow-y:auto;
  padding:4px;
  scrollbar-width:thin;
  scrollbar-color:var(--border-hover) transparent;
}

.viewers-list::-webkit-scrollbar{width:8px}
.viewers-list::-webkit-scrollbar-thumb{background:var(--border);border-radius:var(--r-pill)}

.viewer-row{
  display:flex;
  align-items:center;
  gap:9px;
  padding:7px 8px;
  border-radius:var(--r-sm);
  transition:background var(--ease);
}

.viewer-row:hover{background:var(--chip)}

.viewer-avatar{
  flex:0 0 26px;
  width:26px;height:26px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--chip-2);
  color:var(--text-muted);
  display:grid;place-items:center;
  font:600 10.5px/1 var(--font-sans);
  overflow:hidden;
}

.viewer-avatar img{width:100%;height:100%;object-fit:cover;display:block}

.viewer-main{
  display:flex;
  align-items:baseline;
  gap:8px;
  min-width:0;
}

.viewer-main .faint{
  font-size:10px;
  color:var(--text-dim);
  flex-shrink:0;
}

.viewers-empty{
  padding:18px 14px;
  text-align:center;
  font-size:11.5px;
  color:var(--text-dim);
  line-height:1.6;
}
