/* Components. Every color, size and space resolves from tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-md)/1.45 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--font-mono); font-size: 0.92em; color: var(--accent-strong); }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--control-h); padding: 0 var(--sp-3);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:disabled { opacity: 0.4; cursor: default; pointer-events: none; }
.btn[aria-pressed="true"], .btn.is-active { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-strong); }
.btn--list .icon { width: 17px; height: 17px; }
.btn--list .icon { color: var(--accent); }
.btn--list .count { margin-left: 0; background: var(--surface-3); }
#edProfileEditLabel:empty { display: none; }
.btn--heart .icon { color: var(--accent); }
.btn--heart[aria-pressed="true"] .icon { fill: currentColor; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--danger-wash); border-color: var(--danger); }
.btn--icon { width: var(--control-h); padding: 0; }
.btn--sm { height: 28px; padding: 0 var(--sp-2); font-size: var(--fs-xs); }
.btn--sm.btn--icon { width: 28px; }

.input, .select, .textarea {
  height: var(--control-h); padding: 0 var(--sp-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--accent-ring); outline-offset: 0; border-color: var(--accent); }
.input { width: 100%; min-width: 0; }
.input--num { width: 96px; }
.select { max-width: 220px; cursor: pointer; }
.select--sm { height: 30px; }
.textarea {
  display: block; width: 100%; height: auto; padding: var(--sp-3);
  font-family: var(--font-mono); line-height: 1.5; resize: vertical;
}
.textarea--sm { font-size: var(--fs-xs); word-break: break-all; }
.field { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.field--inline { flex-direction: row; align-items: center; gap: var(--sp-2); white-space: nowrap; }
.field--grow { flex: 1; min-width: 160px; }
.check { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-soft); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.hint { font-size: var(--fs-sm); color: var(--text-muted); }
.hint--accent { padding: var(--sp-3); background: var(--accent-wash); border: 1px solid var(--accent-ring); border-radius: var(--radius-sm); color: var(--text-soft); }
.subhead { margin-top: var(--sp-2); font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.count {
  display: inline-block; margin-left: var(--sp-1); padding: 1px var(--sp-2);
  background: var(--surface-3); border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-soft); vertical-align: middle;
}
.count:empty { display: none; }

/* Top bar */
/* Left menu panel */
.sidebar {
  position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: var(--side-w);
  display: flex; flex-direction: column; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-3); overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.brand__mark {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  background: var(--accent); color: var(--accent-ink); border-radius: var(--radius-sm);
  font-weight: 800;
}
.brand__name { font-size: var(--fs-md); font-weight: 700; line-height: 1.2; }
.side-group { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.side-group--end { margin-top: auto; gap: var(--sp-2); }
.side-title { padding: 0 var(--sp-2); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.side-btn { width: 100%; justify-content: flex-start; }
.side-btn .count { margin-left: auto; }
.btn--primary.side-btn { justify-content: center; }
.side-row { display: flex; gap: var(--sp-2); }
.side-row .side-btn { justify-content: center; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav__item {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; height: var(--control-h); padding: 0 var(--sp-2);
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-soft); text-align: left; cursor: pointer;
}
.side-nav__item:hover { background: var(--surface-2); color: var(--text); }
.side-nav__item.is-active { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-strong); }
.side-nav__name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-nav__item .count { margin-left: 0; }
.side-select { display: none; max-width: none; }

/* Layout */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4);
  max-width: var(--page-max); margin: 0 0 0 var(--side-w); padding: var(--sp-4) var(--sp-4) 110px;
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-4); min-width: 0; }
.panel__head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.panel__title { font-size: var(--fs-lg); font-weight: 700; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.search {
  display: flex; align-items: center; gap: var(--sp-2);
  height: var(--control-h); padding: 0 var(--sp-3); min-width: 230px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-muted);
}
.search:focus-within { border-color: var(--accent); }
.search__input { flex: 1; min-width: 0; height: 100%; padding: 0; background: none; border: 0; outline: 0; font-size: var(--fs-sm); color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg__btn { display: grid; place-items: center; width: var(--control-h); height: calc(var(--control-h) - 2px); background: var(--surface-2); border: 0; color: var(--text-muted); cursor: pointer; }
.seg__btn:hover { color: var(--text); }
.seg__btn.is-active { background: var(--accent-wash); color: var(--accent-strong); }
.filters {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3); padding: var(--sp-3);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
}
.filters .input:not(.input--num) { width: 200px; }
.filter-info { margin-bottom: var(--sp-3); font-size: var(--fs-sm); color: var(--accent-strong); }
/* Character grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr)); gap: var(--sp-2); }
.grid.size-s { --card-min: 104px; }
.grid.size-l { --card-min: 176px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  content-visibility: auto; contain-intrinsic-size: auto 220px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.card:hover { border-color: var(--border-strong); }
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.card.is-dragging { opacity: 0.3; }
.card.drop-before::before, .card.drop-after::before {
  content: ""; position: absolute; z-index: 3; top: 0; bottom: 0; width: 4px; background: var(--accent); border-radius: 2px;
}
.card.drop-before::before { left: 0; }
.card.drop-after::before { right: 0; }
.card__media { position: relative; flex: none; width: 100%; aspect-ratio: 2 / 3; background: var(--surface-3); overflow: hidden; }
/* Owned / Wishlist / Like list marks sit on the photo, just above the series color band. */
.card__marks {
  position: absolute; z-index: 1; top: 0; left: 0; right: 0; aspect-ratio: 2 / 3;
  display: flex; flex-wrap: wrap-reverse; align-items: flex-end; align-content: flex-start; justify-content: center; gap: var(--sp-1);
  padding: 0 var(--sp-1) 11px; pointer-events: none;
}
.card__marks:empty { display: none; }
.card__mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: var(--bg); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); pointer-events: auto; }
.card__mark .icon { width: 14px; height: 14px; }
.card__mark--wish { background: var(--accent); }
.card__mark--wish .icon, .card__mark--like .icon { fill: currentColor; }
.card__mark--like { background: var(--gold); }
.card__mark--owned { background: var(--ok); }
.card__mark--owned .icon { stroke-width: 3; }
/* List view: the marks get their own fixed slot after the kakera value, so names stay lined up. */
.grid.is-list .card__marks, .grid.is-list .card__marks:empty { position: static; order: 3; display: flex; flex: none; width: 54px; aspect-ratio: auto; flex-wrap: nowrap; justify-content: flex-end; align-items: center; padding: 0; }
.grid.is-list .card__mark { width: 22px; height: 22px; box-shadow: none; }
.card__media img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
/* Series color: a band under the picture, the series name, and a ring on series mates. */
.card__media::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--series, transparent); }
.card.is-selected::after { content: ""; position: absolute; z-index: 1; inset: 0; border: 3px solid var(--series); border-radius: inherit; pointer-events: none; }
.card.is-selected::after { border-color: var(--accent); }
.card__series:hover { text-decoration: underline; }
.series-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3); padding: var(--sp-2) var(--sp-3);
  background: var(--bg); border: 1px solid var(--series, var(--border-strong)); border-radius: var(--radius);
}
.series-bar__name { font-size: var(--fs-md); color: var(--series, var(--text)); }
.series-bar__info { margin-right: auto; font-size: var(--fs-sm); color: var(--text-muted); }
.series-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--series, var(--border-strong)); }
.card__initial { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.2rem; font-weight: 800; color: var(--text-muted); }
.card__body { flex: 1; padding: var(--sp-2); min-width: 0; text-align: center; }
.card__name { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card__series { display: block; width: 100%; padding: 0; background: none; border: 0; text-align: inherit; cursor: pointer; font-size: var(--fs-xs); color: var(--series, var(--text-muted)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card__meta { display: flex; justify-content: center; align-items: center; gap: var(--sp-2); min-height: 16px; font-size: var(--fs-xs); }
.card__ka { font-weight: 700; color: var(--accent-strong); white-space: nowrap; }
.card__note { color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card__tags { display: flex; justify-content: center; flex-wrap: nowrap; gap: var(--sp-1); margin-top: 2px; overflow: hidden; }
.card__tags:empty { display: none; }
.card__tag { max-width: 100%; padding: 0 var(--sp-1); background: var(--surface-3); border-radius: 999px; font-size: var(--fs-xs); color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid.is-list .card__tags { justify-content: flex-start; margin: 0; }
.card__pos {
  position: absolute; z-index: 2; top: var(--sp-1); left: var(--sp-1);
  min-width: 24px; height: 20px; padding: 0 var(--sp-1);
  background: var(--scrim); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: var(--fs-xs); font-weight: 700; cursor: pointer;
}
.card__pos:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.card__check {
  position: absolute; z-index: 2; top: 30px; left: var(--sp-1);
  display: grid; place-items: center; width: 22px; height: 22px; padding: 0;
  background: var(--scrim); color: transparent; border: 2px solid var(--text-soft); border-radius: var(--radius-sm); cursor: pointer; opacity: 0;
}
.card__check .icon { width: 14px; height: 14px; stroke-width: 3; }
.card:hover .card__check, .card:focus-within .card__check, .grid.has-selection .card__check { opacity: 1; }
.card__check:hover { border-color: var(--accent-strong); }
.card.is-selected .card__check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.grid.is-list .card__check { position: static; opacity: 1; order: -1; flex: none; }
.card__act {
  display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
  background: var(--scrim); color: var(--text-soft); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer;
}
.card__act .icon { width: 13px; height: 13px; }
.card__actions { position: absolute; z-index: 2; top: var(--sp-1); right: var(--sp-1); display: flex; flex-direction: column; gap: var(--sp-1); opacity: 0; }
.card:hover .card__actions, .card:focus-within .card__actions { opacity: 1; }
a.btn, a.card__act { text-decoration: none; }
.card__act:hover { background: var(--surface-3); color: var(--text); }
.card__act--danger:hover { color: var(--danger); border-color: var(--danger); }

/* List view */
.grid.is-list { grid-template-columns: minmax(0, 1fr); gap: var(--sp-1); }
.grid.is-list .card { flex-direction: row; align-items: center; gap: var(--sp-3); padding: var(--sp-1) var(--sp-2); contain-intrinsic-size: auto 52px; }
.grid.is-list .card__pos, .grid.is-list .card__actions { position: static; opacity: 1; }
.grid.is-list .card__pos { order: 0; min-width: 40px; }
.grid.is-list .card__media::after { height: 3px; }
.grid.is-list .card__media { order: 1; width: 34px; height: 42px; aspect-ratio: auto; flex: none; border-radius: var(--radius-sm); overflow: hidden; }
.grid.is-list .card__initial { font-size: var(--fs-md); }
.grid.is-list .card__body { order: 2; flex: 1; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) auto auto; align-items: center; gap: var(--sp-3); padding: 0; text-align: left; }
.grid.is-list .card__meta { justify-content: flex-end; max-width: 240px; }
.grid.is-list .card__actions { order: 4; flex-direction: row; }
.grid.is-list .card__act { background: transparent; border-color: transparent; }
.grid.is-list .card.drop-before::before, .grid.is-list .card.drop-after::before { left: 0; right: 0; width: auto; height: 3px; }
.grid.is-list .card.drop-before::before { top: 0; bottom: auto; }
.grid.is-list .card.drop-after::before { top: auto; bottom: 0; }
.grid.size-s.is-list .card__media { width: 26px; height: 32px; }
.grid.size-l.is-list .card__media { width: 46px; height: 58px; }

/* Drag ghost */
.drag-ghost {
  position: fixed; z-index: 100; top: 0; left: 0; margin: 0; pointer-events: none;
  opacity: 0.95; box-shadow: var(--shadow-drag); border-color: var(--accent); cursor: grabbing;
}
.drag-ghost__badge {
  position: absolute; z-index: 4; top: -8px; right: -8px;
  min-width: 24px; height: 24px; padding: 0 var(--sp-2); display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: var(--fs-xs); font-weight: 800;
}
body.is-dragging, body.is-dragging .card { cursor: grabbing; }

/* Empty states */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-6) var(--sp-4); text-align: center; }
.empty__mark { display: grid; place-items: center; width: 56px; height: 56px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--text-muted); }
.empty__mark .icon { width: 22px; height: 22px; }
.empty__title { font-size: var(--fs-lg); font-weight: 700; }
.empty__text { font-size: var(--fs-sm); color: var(--text-muted); }
.empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-2); }

/* Commands */
.tabs { display: flex; gap: var(--sp-1); margin-bottom: var(--sp-3); padding: var(--sp-1); background: var(--bg); border-radius: var(--radius-sm); }
.tabs { flex-wrap: wrap; }
.tabs__tab { flex: 1; height: 28px; background: none; border: 0; border-radius: var(--radius-sm); font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); cursor: pointer; }
.tabs__tab.is-active { background: var(--surface-3); color: var(--text); }
.cmd-stale { margin-bottom: var(--sp-3); padding: var(--sp-2) var(--sp-3); background: var(--accent-wash); border: 1px solid var(--accent-ring); border-radius: var(--radius-sm); font-size: var(--fs-sm); color: var(--accent-strong); }
.panel--cmd .row { margin-bottom: var(--sp-3); }
.cmd-field { margin-bottom: var(--sp-3); }
.tabs__tab code { color: inherit; opacity: 0.75; }
.cmd-summary { margin-bottom: var(--sp-3); font-size: var(--fs-sm); color: var(--text-muted); }
.cmd-summary strong { color: var(--text-soft); }
.cmd-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.cmd { padding: var(--sp-3); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.cmd.is-done { border-color: var(--ok); }
.cmd__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-2); font-size: var(--fs-xs); color: var(--text-muted); }
.cmd__label { font-weight: 700; color: var(--accent-strong); }
.cmd.is-done .cmd__label { color: var(--ok); }
.cmd__tools { display: flex; gap: var(--sp-1); }
.cmd__text { margin: 0; max-height: 168px; overflow: auto; font: var(--fs-xs)/1.5 var(--font-mono); color: var(--text-soft); white-space: pre-wrap; word-break: break-word; }

/* Selection bar */
.selbar {
  position: fixed; z-index: 50; left: var(--side-w); right: 0; bottom: var(--sp-4); margin: 0 auto; width: fit-content;
  display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: var(--sp-2);
  max-width: calc(100vw - var(--sp-5)); padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2); border: 1px solid var(--accent); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
}
.selbar__count { padding: 0 var(--sp-2); font-size: var(--fs-sm); font-weight: 700; color: var(--accent-strong); white-space: nowrap; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; z-index: 60; left: 0; bottom: calc(100% + var(--sp-2));
  display: flex; flex-direction: column; gap: 2px; min-width: 240px; max-width: 320px; max-height: 320px; overflow-y: auto;
  padding: var(--sp-1); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-pop);
}
.menu__item {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; padding: var(--sp-2);
  background: none; border: 0; border-radius: var(--radius-sm); text-align: left; font-size: var(--fs-sm); color: var(--text); cursor: pointer;
}
.menu__item:hover { background: var(--surface-2); }
.menu__item input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; flex: none; }
.menu__name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu__item--new { border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); color: var(--accent-strong); font-weight: 600; }
.menu__hint { padding: var(--sp-2); font-size: var(--fs-sm); color: var(--text-muted); }
.selbar__sep { width: 1px; height: 20px; background: var(--border-strong); }

/* Dialogs */
.dialog {
  width: min(560px, calc(100vw - var(--sp-5))); max-height: calc(100vh - var(--sp-6)); padding: 0;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
}
.dialog[open] { display: flex; flex-direction: column; }
.dialog > form { display: flex; flex-direction: column; min-height: 0; }
.dialog::backdrop { background: var(--scrim); }
.dialog--wide { width: min(820px, calc(100vw - var(--sp-5))); }
.dialog--narrow { width: min(400px, calc(100vw - var(--sp-5))); }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) 0; }
.dialog__title { font-size: var(--fs-lg); font-weight: 700; }
.dialog__body { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4); overflow-y: auto; min-height: 0; }
.dialog__foot { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border); }
.dialog__status { margin-right: auto; font-size: var(--fs-sm); color: var(--text-muted); }
.preview { padding: var(--sp-3); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: var(--fs-sm); }
.preview__row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: var(--sp-3); padding: 2px 0; }
.preview__row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview__series { color: var(--text-muted); }
.preview__ka { color: var(--accent-strong); }
.preview__more { margin-top: var(--sp-1); color: var(--text-muted); }
.examples { font-size: var(--fs-sm); color: var(--text-muted); }
.examples summary { cursor: pointer; font-weight: 600; color: var(--text-soft); }
.examples__label { margin-top: var(--sp-3); }
.code { margin: var(--sp-1) 0 0; padding: var(--sp-2); background: var(--bg); border-radius: var(--radius-sm); font: var(--fs-xs)/1.5 var(--font-mono); white-space: pre-wrap; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.choices .btn { justify-content: flex-start; }

.edit { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: start; gap: var(--sp-4); }
.edit__photo { position: relative; }
.edit__photo-btn { position: absolute; z-index: 1; top: var(--sp-2); right: var(--sp-2); background: var(--scrim); border-color: var(--border-strong); }
.edit__photo-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.edit__preview { position: relative; aspect-ratio: 2 / 3; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.edit__preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.edit__fields { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }


.series-order { display: flex; flex-direction: column; gap: var(--sp-1); max-height: 280px; overflow-y: auto; }
.series-order__item { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) var(--sp-2); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: var(--fs-sm); cursor: grab; }
.series-order__item.is-dragging { opacity: 0.4; }
.series-order__item.is-over { border-color: var(--accent); }
.series-order__owned { flex: none; font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }
.series-order__name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.col-item { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.col-item.is-active { border-color: var(--accent); }
.col-item__name { flex: 1; min-width: 0; padding: 0; background: none; border: 0; text-align: left; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }

/* Toasts */
.toasts { position: fixed; z-index: 200; right: var(--sp-4); top: var(--sp-4); display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-2); pointer-events: none; }
.toast { max-width: 340px; padding: var(--sp-2) var(--sp-3); background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); font-size: var(--fs-sm); }
.toast--error { border-color: var(--danger); }

/* Wide screens: commands sit beside the grid and stay in view */
@media (min-width: 1180px) {
  body.cmd-open .layout { grid-template-columns: minmax(0, 1fr) var(--sidebar-w); align-items: start; }
  .panel--cmd { position: sticky; top: var(--sp-4); max-height: calc(100vh - var(--sp-6)); overflow-y: auto; }
}
@media (max-width: 720px) {
  .layout { padding-left: var(--sp-2); padding-right: var(--sp-2); }
  .panel { padding: var(--sp-3); }
  /* Small screens: the menu panel becomes a strip across the top, and collections go back into a dropdown. */
  .sidebar { position: static; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-2); border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { flex: 1 1 100%; }
  .side-group, .side-group--end, .side-row { flex-direction: row; align-items: center; gap: var(--sp-2); margin: 0; }
  .side-title, .side-nav { display: none; }
  .side-select { display: block; max-width: 170px; }
  .side-btn { width: auto; }
  .layout { margin-left: 0; }
  .btn__label { display: none; }
  .search { min-width: 0; flex: 1 1 100%; }
  .grid { --card-min: 104px; }
  .grid.size-s { --card-min: 84px; }
  .grid.size-l { --card-min: 140px; }
  .card__actions { display: none; }
  .card__check { opacity: 1; }
  .card.is-selected .card__actions { display: flex; opacity: 1; }
  .grid.is-list .card__actions { display: none; }
  .grid.is-list .card.is-selected .card__actions { display: flex; }
  .grid.is-list .card__body { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .grid.is-list .card__meta { justify-content: flex-start; }
  .edit { grid-template-columns: minmax(0, 1fr); }
  .edit__photo { width: 120px; }
  .choices { grid-template-columns: minmax(0, 1fr); }
  .selbar { left: var(--sp-2); right: var(--sp-2); width: auto; max-width: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
