/* croqi app, the library: the board (tools, recent work, folders, every part) and the pattern shelf that shares its frame. */

.library { display: grid; grid-template-columns: 232px minmax(0, 1fr); align-items: start; min-height: 100%; }
.library.has-preview { grid-template-columns: 232px minmax(0, 1fr) 300px; }
.lib-preview {
  position: sticky; top: 0; align-self: start; display: grid; align-content: start; gap: 14px;
  height: calc(100dvh - var(--bar-h) - var(--status-h)); padding: 14px; overflow-y: auto; border-left: 1px solid var(--line); background: var(--surface);
}
.pv-head { display: flex; align-items: center; gap: 8px; }
.pv-head h2 { flex: 1; min-width: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.pv-pair .card-visual { height: 220px; border: 0; border-radius: 8px; }
.pv-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pv-actions .btn-primary { grid-column: 1 / -1; }
.pv-facts { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 7px 10px; margin: 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; }
.pv-facts dt { color: var(--ink-muted); }
.pv-facts dd { margin: 0; overflow-wrap: anywhere; }
.pv-block { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.pv-block h3 { margin: 0; }
.pv-versions { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; font-size: 12.5px; }
.pv-versions li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; }
.pv-versions b { color: var(--ink-muted); font-weight: 500; font-size: 11.5px; }
.pv-quiet { display: block !important; color: var(--ink-muted); }
.pv-made { display: flex; flex-wrap: wrap; gap: 6px; }
.pv-made .chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--ink); font-size: 12px; text-decoration: none; }
.pv-made .chip:hover { border-color: var(--accent); }

/* several parts ticked: what can be done to all of them, floating over the grid */
.batch {
  position: sticky; bottom: 16px; z-index: 6; display: flex; align-items: center; gap: 2px; width: max-content; max-width: 100%; margin: 18px auto 0; padding: 5px 5px 5px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: #0e0f10; box-shadow: var(--shadow-pop);
}
.batch-count { margin-right: 10px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.batch .btn { height: 30px; }
.tree-row { display: flex; align-items: center; }
.tree-row .tree-item { flex: 1; min-width: 0; }
.tree-row .folder-more { width: 26px; height: 26px; opacity: 0; }
.tree-row:hover .folder-more, .tree-row .folder-more:focus-visible, .tree-row .folder-more[aria-expanded="true"] { opacity: 1; }
.library-main { min-width: 0; width: min(100%, 1480px); padding: 22px 28px 72px; }
@media (max-width: 1000px) {
  .library, .library.has-preview { grid-template-columns: minmax(0, 1fr); }
  .library-main { padding: 16px 16px 72px; }
  .lib-preview { position: fixed; left: 0; right: 0; bottom: 54px; z-index: 20; height: auto; max-height: 55dvh; border-left: 0; border-top: 1px solid var(--line-strong); box-shadow: var(--shadow-pop); }
  .status-chips { overflow-x: auto; }
  .batch { bottom: 70px; }
}
.library-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.head-title { display: grid; gap: 3px; margin-right: auto; min-width: 0; }
.library-head h1 { font-size: 22px; letter-spacing: -.02em; }
.board-summary { color: var(--ink-muted); font-size: 12.5px; }
.board-summary:empty { display: none; }
kbd.on-fill { border-color: #ffffff47; background: #ffffff1a; color: #e4eef8; }
.library-actions { display: flex; align-items: center; gap: 10px; }
.trail-step { border: 0; padding: 0; background: transparent; color: var(--ink-muted); font: inherit; }
.trail-step:hover { color: var(--accent); text-decoration: underline; }
.trail-caret { margin: 0 8px; color: var(--line-strong); }

.search-box {
  display: flex; align-items: center; gap: 8px; width: 280px; height: 34px; padding: 0 11px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink-muted);
}
.search-box:hover { border-color: var(--ink-muted); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.search { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent; color: var(--ink); outline: none; }
.search::placeholder { color: var(--ink-muted); }

/* ---------- tabs, sort, grid or list ---------- */
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.status-chips { display: flex; gap: 6px; padding-bottom: 6px; }
.status-chips .chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border: 1px solid var(--line); border-radius: 99px; background: transparent; color: var(--ink-muted); font-size: 12px; }
.status-chips .chip:hover { border-color: var(--line-strong); color: var(--ink); }
.status-chips .chip.is-chosen { border-color: #6ea9e380; background: var(--accent-wash); color: var(--ink); }
.status-chips .count { font: 500 11px var(--font-mono); color: var(--ink-muted); }
.status-chips .count:empty { display: none; }
.tab-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; margin-bottom: -1px; padding: 0 14px;
  border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--ink-muted); font-size: 14px; font-weight: 600;
}
.tab.is-active { border-bottom-color: var(--accent); color: var(--ink); }
.tab .count { padding: 1px 7px; border-radius: 99px; background: #ffffff0f; color: var(--ink-muted); font: 500 11px var(--font-mono); font-variant-numeric: tabular-nums; }
.tabs-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; padding-bottom: 6px; }
.menu-anchor { position: relative; }
.toggle { display: inline-flex; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.toggle button { display: grid; place-items: center; width: 30px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-muted); }
.toggle button.is-active { background: var(--accent-wash); color: var(--accent); }

/* the grid stands inside a wrapper so the drop tile can be its first cell without the cards' list ever clearing it */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; }
.board-grid > .grid { display: contents; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; }

.card-wrap { position: relative; display: flex; }
.card-wrap > .card { flex: 1; min-width: 0; }
.card {
  --card-visual-h: 214px;
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface);
  color: inherit; text-align: left; text-decoration: none; padding: 0;
}
.card-visual {
  position: relative; display: grid; place-items: center; height: var(--card-visual-h); padding: 16px; overflow: hidden;
  border-bottom: 1px solid var(--line); background: #fff;
}
.card-visual img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.card-visual.is-pair { grid-template-columns: 1fr 1fr; gap: 1px; padding: 0; background: #e3e5e7; }
.card-visual.is-pair img { padding: 14px 10px; background: #fff; }
.card-visual.is-pair.is-single { grid-template-columns: 1fr; }
.card-visual.is-photo { background: var(--raise); }
.card-visual.is-photo img { opacity: .5; filter: grayscale(1); }
.card-state { display: grid; gap: 6px; justify-items: center; color: var(--ink-muted); font-size: 12px; }
.card-state .spinner { width: 18px; height: 18px; }
.card-body { display: grid; gap: 8px; padding: 12px 12px 10px 14px; }
.card-name { overflow: hidden; font-weight: 600; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.card-title { display: flex; align-items: center; gap: 8px; }
.card-wrap .card-title, .card-wrap .card-name { padding-right: 30px; }
.card-meta { display: flex; align-items: center; gap: 8px; color: var(--ink-muted); font: 500 11px var(--font-mono); }
.card-error { color: var(--danger); }
.card-more { position: absolute; right: 8px; top: calc(var(--card-visual-h, 214px) + 8px); }
.fav { position: absolute; right: 8px; top: 8px; z-index: 1; color: #1a1c1e59; }
.fav:hover:not(:disabled) { background: #1a1c1e14; color: #1a1c1e; }
.card-check {
  position: absolute; left: 8px; top: 8px; z-index: 1; display: grid; place-items: center; width: 22px; height: 22px; padding: 0;
  border: 1.5px solid #1a1c1e4d; border-radius: 6px; background: #ffffffe6; color: #fff; opacity: 0; transition: opacity 120ms ease, background-color 120ms ease;
}
.card-check .i { width: 14px; height: 14px; }
.card-wrap:hover .card-check, .card-check:focus-visible, .grid.is-selecting .card-check, .card-wrap.is-selected .card-check { opacity: 1; }
.card-wrap.is-selected .card-check { border-color: var(--accent-fill); background: var(--accent-fill); }
.card-wrap.is-selected .card { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card-wrap .state { left: 38px; }
.fav[aria-pressed="true"] { color: var(--amber); }
.fav[aria-pressed="true"] .i { fill: currentColor; }
.state {
  position: absolute; left: 10px; top: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px;
  border: 1px solid #1a1c1e24; border-radius: 99px; background: #fffffff0; color: #4b5258; font: 500 11px var(--font-mono);
}
.state.is-running { border-color: #2d6aa066; color: #1f5585; }
.state.is-error { border-color: #b3382c66; color: #9e2f24; }
.state .pulse { background: #2d6aa0; }
.state.is-running { border-color: var(--accent); color: var(--accent); }
.state.is-error { border-color: var(--danger); color: var(--danger); }
.state .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.outs { display: inline-flex; gap: 3px; margin-left: auto; }
.outs i { display: grid; place-items: center; width: 22px; height: 20px; border-radius: 5px; background: var(--accent-wash); color: var(--accent); font-style: normal; }
.outs i .i { width: 13px; height: 13px; }
.kind { position: absolute; left: 8px; top: 8px; padding: 2px 7px; border-radius: 5px; background: #1a1c1ee0; color: #fff; font: 500 11px/1.4 var(--font-mono); letter-spacing: .06em; }
.card-tile { width: 100%; height: 100%; background-size: 50% auto; background-repeat: repeat; }
.card-tile.is-single { background-size: contain; background-repeat: no-repeat; background-position: center; }
.swatches { display: inline-flex; gap: 3px; margin-left: auto; }
.swatches i { width: 12px; height: 12px; border: 1px solid #12181d1f; border-radius: 3px; }

.list-wrap { position: relative; overflow-x: auto; }
table.list { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); }
.list th { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; color: var(--ink-muted); font: 500 11px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.list td { padding: 8px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list img { width: 40px; height: 40px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.list .name { display: flex; align-items: center; gap: 12px; color: inherit; font-weight: 600; text-decoration: none; }
.list .outs { margin-left: 0; }

/* the drop target: a tile in a full grid, or the large one of an empty library */
.drop {
  position: relative; display: grid; place-content: center; justify-items: center; gap: 8px; min-height: 290px; padding: 20px;
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-2); background: transparent;
  color: var(--ink-muted); text-align: center; font-size: 12px; cursor: pointer;
}
.drop strong { color: var(--ink); font-size: 14px; }
.drop .i { width: 22px; height: 22px; color: var(--accent); }
body.is-dragging .drop, .drop.is-dragging { border-color: var(--accent); background: var(--accent-wash); }

/* ---------- empty states ---------- */
/* the first run: your photo on one board, the sample part on the other */
.first-run { gap: 18px; padding-top: 5vh; }
.fr-boards { display: grid; grid-template-columns: repeat(2, minmax(0, 300px)); gap: 28px; margin-top: 18px; }
.fr-board { position: relative; display: grid; align-content: center; justify-items: center; gap: 10px; aspect-ratio: 3 / 4; padding: 18px; text-align: center; }
.fr-board .board-name { position: absolute; left: 0; top: -20px; color: var(--ink-muted); font: 500 11px var(--font-mono); }
.first-run .drop.fr-board { min-height: 0; width: auto; }
.fr-sample { border: 0; border-radius: 2px; background: #fff; box-shadow: 0 18px 40px -20px #000000b3; color: #1a1c1e; cursor: pointer; transition: transform var(--dur-press) var(--ease-out); }
.fr-sample img { width: 100%; min-height: 0; flex: 1; object-fit: contain; }
.fr-sample-foot { color: #4b5258; font-size: 12px; line-height: 1.4; }
.fr-sample:hover { transform: translateY(-2px); }
@media (max-width: 700px) { .fr-boards { grid-template-columns: minmax(0, 1fr); } }

.empty { display: grid; gap: 14px; justify-items: center; padding: 40px 0; text-align: center; color: var(--ink-muted); }
.empty-title { margin: 0; color: var(--ink); font-size: 16px; font-weight: 600; }
.empty-hint { max-width: 420px; margin: 0; }
.empty-state { display: grid; justify-items: center; gap: 22px; padding: 7vh 0 0; text-align: center; }
.empty-state h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.025em; }
.empty-state p { max-width: 46ch; margin: 0; color: var(--ink-muted); font-size: 14px; }
.empty-state .drop { width: min(100%, 640px); min-height: 220px; }
.tips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(100%, 760px); margin-top: 8px; border-top: 1px solid var(--line); text-align: left; }
.tips div { padding: 16px 18px 0 0; }
.tips b { display: block; margin-bottom: 4px; font-size: 13px; }
.tips span { color: var(--ink-muted); font-size: 12px; }

@media (max-width: 1000px) {
  .library { width: min(100% - 32px, 1400px); padding-top: 18px; }
  .library-head { flex-wrap: wrap; }
  .library-head h1 { flex: 1 1 100%; }
  .library-actions { flex-wrap: wrap; width: 100%; }
  .search-box { flex: 1 1 200px; width: auto; }
}
@media (max-width: 620px) {
  .library-actions .btn { flex: 1 1 auto; }
  .tabs-tools { margin-left: 0; padding-bottom: 8px; }
  .tips { grid-template-columns: minmax(0, 1fr); }
  .tips div { padding-right: 0; }
}

/* ---------- feel ---------- */
.card, .tab, .toggle button, .drop {
  transition: transform var(--dur-press) var(--ease-out), border-color 120ms ease, background-color 120ms ease, color 120ms ease, box-shadow var(--dur-ui) var(--ease-out), opacity 140ms ease;
}
.card:active, .drop:active { transform: scale(.99); }
@media (hover: hover) and (pointer: fine) {
  .card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lift); transform: translateY(-1px); }
  .card:hover:active { transform: translateY(0) scale(.99); }
  .drop:hover { border-color: var(--accent); background: var(--accent-wash); }
  .tab:hover { color: var(--ink); }
  .list tbody tr:hover { background: #ffffff05; }
}
@media (prefers-reduced-motion: reduce) {
  .state .pulse { animation: none; }
  .card, .tab, .toggle button, .drop { transition-property: opacity, border-color, background-color, color; }
  .card:hover, .card:active, .drop:active { transform: none; }
}
