/* The tool explorer (UI V3 P5, 2026-11-05): "모든 도구" as a tree (ui/explorer.js)
   with 내 작업 영역, and the ribbon's drop place for a tool dragged from it.
   Tokens only: both themes follow css/tokens.css. */

.menu.tool-library {
  /* A tool scrolled to stays clear of the search kept at the top. */
  scroll-padding-top: 64px;
  width: min(460px, calc(100% - 2 * var(--gap)));
  max-width: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 6px 10px;
}
/* (The search comes first and sticks: the field never moves as the list under it changes.) */
.explorer .xp-title { display: flex; align-items: center; gap: 8px; padding: 2px 8px 6px; }
.xp-name { font-size: 14px; font-weight: 600; }
.xp-n { min-width: 28px; height: 20px; padding: 0 8px; border-radius: 10px; background: var(--panel2); color: var(--muted); font: 500 12px/20px var(--font); font-variant-numeric: tabular-nums; text-align: center; }
.explorer .xp-fold-all { margin-left: auto; height: 30px; padding: 0 8px; }
.explorer .more-head { z-index: 3; }
.xp-acts { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 4px 8px; }
.xp-act { gap: 6px; }
.xp-act .ic, .xp-say-share .ic { flex: none; }

/* 내 작업 영역: the save, share and import panel, one at a time. */
.xp-panel { display: flex; flex-direction: column; gap: 8px; margin: 0 4px 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-input); background: var(--panel2); }
.xp-panel[hidden] { display: none; }
.xp-lab { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.xp-code { width: 100%; resize: vertical; height: auto; padding: 6px 8px; font: 12px/1.4 var(--mono); word-break: break-all; }
.xp-btns { display: flex; gap: 6px; }
.xp-btns .btn { gap: 6px; }
.xp-note { font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.xp-err { font-size: 12.5px; line-height: 1.4; color: var(--danger); }
.xp-err:empty { display: none; }
.xp-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 8px 8px; font-size: 12px; line-height: 1.5; color: var(--text); }
.xp-status:empty { display: none; }
.xp-say-share { height: 26px; padding: 0 9px; gap: 5px; }

/* The tree: category › group › tool. */
.xp-tree { display: flex; flex-direction: column; padding: 0 2px; }
.xp-sec { display: flex; flex-direction: column; }
.xp-sec[hidden] { display: none; }
.xp-sec + .xp-sec { margin-top: 2px; padding-top: 2px; border-top: 1px solid var(--line); }
.xp-row { display: flex; align-items: center; min-width: 0; border-radius: 6px; }
.xp-row[hidden] { display: none; }
.xp-row:hover { background: var(--hover); }
.xp-row[data-best] { background: var(--tint); }
.xp-row:focus-within { background: var(--hover); }
.xp-main { font: inherit; }
.xp-fold { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 13px; text-align: left; }
.xp-l0 .xp-fold { font-weight: 600; }
.xp-l1 .xp-fold { padding-left: 24px; color: var(--muted); font-size: 12.5px; }
.xp-chev { flex: none; width: 12px; height: 12px; color: var(--muted); transform: rotate(-90deg); transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); }
.xp-fold[aria-expanded="true"] .xp-chev { transform: none; }
.xp-fold[aria-expanded="true"] .xp-label { color: var(--text); }
.xp-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-count { flex: none; margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
.xp-label mark, .tk mark { padding: 1px 0; border-radius: 3px; background: var(--tint); color: var(--ink); font-weight: 600; }
/* On the best row (already tinted) a second tint under the match stacked to 3.6:1 in the dark theme: underline it there instead. */
.xp-row[data-best] .xp-label mark, .xp-row[data-best] .tk mark { background: transparent; text-decoration: underline; text-underline-offset: 2px; }
.xp-l2 { padding-left: 28px; }
.xp-l1.tcell { padding-left: 8px; }
.xp-tool { flex: 1 1 auto; width: auto; min-width: 0; height: 32px; flex-direction: row; justify-content: flex-start; gap: 8px; padding: 0 6px; font-size: 13px; }
.xp-tool:hover:not(:disabled) { background: transparent; }
.xp-tool .ic { flex: none; width: 18px; height: 18px; }
.xp-tool .lbl { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 13px; line-height: 1.2; text-align: left; }
.xp-tool .tk { max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-pin { width: 30px; height: 30px; margin-right: 2px; }
.xp-row[data-pinned] .xp-tool .ic { color: var(--ink); }
.xp-row[data-drag] { opacity: 0.4; }
.xp-empty { padding: 14px 10px; }
.tool-library .xp-main:focus-visible, .tool-library .xp-pin:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* A tool dragged off its row (mouse, pen): the chip by the pointer. */
.xp-chip { position: absolute; z-index: 60; display: flex; align-items: center; gap: 8px; height: 31px; padding: 0 12px 0 10px; border-radius: 8px; background: var(--panel); color: var(--text); font: 500 13px/1 var(--font); white-space: nowrap; pointer-events: none; box-shadow: 0 0 0 1.5px var(--accent), var(--shadow); }
.xp-chip .ic { color: var(--ink); }
body.xp-dragging, body.xp-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }

/* The ribbon while a tool is dragged: its panel ringed, and a place for the
   tool in "내 도구" (made at the end when the lens has none) once it is over. */
#toolbar[data-drop] :is(.rail-body, .rb-ctxbody) { outline: 1.5px dashed color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: -3px; }
#toolbar[data-drop="over"] :is(.rail-body, .rb-ctxbody) { outline: 2px solid var(--accent); outline-offset: -3px; background: color-mix(in srgb, var(--accent) 7%, var(--panel2)); }
.xp-ghost { flex: none; width: 56px; height: 56px; display: grid; place-items: center; border: 1.5px dashed var(--accent); border-radius: var(--r-tool); color: var(--ink); background: var(--tint); }
#app[data-ribbon] .xp-ghost { height: 44px; width: 44px; }
.xp-ghost-in { display: grid; place-items: center; }
.xp-ghost .ic { width: 22px; height: 22px; }
.xp-ghost-group { flex: none; display: flex; flex-direction: column; padding: 0 6px; }
#toolbar .tb.fresh { background: var(--tint); box-shadow: inset 0 0 0 1.5px var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  #toolbar .tb { transition: background 0.5s ease, box-shadow 0.5s ease; }
}

/* A finger's size. */
@media (pointer: coarse) {
  .xp-fold { height: 44px; }
  .xp-tool { height: 44px; }
  .xp-pin { width: 44px; height: 44px; margin-right: 0; }
  .explorer .xp-fold-all { height: 44px; padding: 0 10px; }
  .xp-acts .btn { height: 40px; }
}

/* A phone: the explorer is a sheet from under the top bars to the bar (no dragging). */
#app[data-size="phone"] .menu.tool-library {
  left: 8px !important;
  right: 8px;
  width: auto;
  top: var(--xp-top, calc(var(--safe-t) + 60px)) !important;
  bottom: var(--xp-bottom, 76px) !important;
  max-height: none !important;
  border-radius: var(--r-panel);
}
#app[data-size="phone"] .xp-tool .tk { display: none; }
