/* Tier list maker (templates/tier_list/*) */
.tl-head { padding: 10px 0 16px; }
.tl-head h1 { margin: 0 0 6px; font-size: clamp(1.4rem, 3.6vw, 2rem); }
.tl-head p { margin: 0; color: var(--muted); }
.tl-h-ico { display: inline-grid; place-items: center; vertical-align: middle; margin-right: 12px; width: 44px; height: 44px;
  border-radius: 14px; background: #ede9fe; color: #6d28d9; }
.tl-h-ico .icon { width: 24px; height: 24px; }
[data-theme=dark] .tl-h-ico { background: #2b2440; color: #f1eee9; }

.tl-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.tl-bar input { flex: 1 1 240px; min-width: 0; font-weight: 600; }
.tl-bar-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.tl-bar .icon { width: 16px; height: 16px; }

/* the board. --tile is one size for the board, the pool and saved boards;
   the S/M/L buttons (data-size on .tl-app) change it. */
:root { --tile: 72px; }   /* this file only loads on tier list pages */
.tl-app[data-size=s] { --tile: 56px; }
.tl-app[data-size=l] { --tile: 96px; }
.tl-board { --bg: #1f1d1b; background: var(--bg); border-radius: var(--radius-sm); overflow: hidden;
  display: flex; flex-direction: column; gap: 2px; padding: 2px; }
.tl-row { display: flex; min-height: calc(var(--tile) + 8px); background: rgb(255 255 255 / .06); }
.tl-label { flex: none; width: 96px; display: grid; place-items: center; padding: 6px; border: 0; font: 700 1.5rem/1.15 var(--font);
  color: #1d1b19; text-align: center; word-break: break-word; cursor: pointer; }
.tl-label:not(button) { cursor: default; }
.tl-drop { flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; padding: 4px; min-width: 0; }
.tl-item { position: relative; width: var(--tile); height: var(--tile); flex: none; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; padding: 4px; background: #fff; color: #1d1b19; border-radius: 6px; overflow: hidden;
  cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; }
.tl-item .e { font-size: 1.9rem; line-height: 1.1; }
.tl-item .t { font-size: .72rem; font-weight: 600; line-height: 1.15; text-align: center; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.tl-item:not(:has(.e)) .t, .tl-item .e:empty + .t { -webkit-line-clamp: 4; font-size: .8rem; }
/* picture tiles: the whole picture fits (no cropping) on a soft see-through card that suits the dark board
   and the light/dark pool; the name only shows on hover / when picked (it is still in the tooltip and search). */
.tl-item.has-img { padding: 3px; background: rgb(128 128 128 / .16); box-shadow: inset 0 0 0 1px rgb(128 128 128 / .22);
  transition: transform .12s, background .12s; }
.tl-item.has-img:hover { transform: translateY(-1px); background: rgb(128 128 128 / .26); }
.tl-item.has-img img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.tl-item.has-img .t { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 3px 2px; font-size: .6rem; color: #fff;
  background: linear-gradient(transparent, rgb(0 0 0 / .75)); -webkit-line-clamp: 1; opacity: 0; transition: opacity .12s; }
.tl-item.has-img:hover .t, .tl-item.has-img.tl-selected .t { opacity: 1; }
.tl-size { display: inline-flex; margin-left: auto; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tl-size button { padding: 3px 10px; border: 0; background: none; color: var(--muted); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.tl-size button + button { border-left: 1px solid var(--line); }
.tl-size button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); }
.tl-item.tl-dragging { opacity: .25; }
.tl-item.tl-selected { outline: 3px solid var(--accent); outline-offset: 1px; }
.tl-ghost { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; opacity: .9; box-shadow: 0 10px 24px rgb(0 0 0 / .35);
  transform-origin: center; cursor: grabbing; }

.tl-row-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0 14px; }
.tl-pool-wrap { border: 2px dashed var(--line); border-radius: var(--radius-sm); padding: 8px 10px 10px; }
.tl-pool-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 0 0 6px; color: var(--muted); }
.tl-pool { min-height: 90px; padding: 0; }
.tl-pool.big { max-height: min(60vh, 560px); overflow-y: auto; overscroll-behavior: contain; }   /* 1,000+ item templates */
.tl-pool .tl-item.off { display: none; }
.tl-pool-find { width: 100%; max-width: 320px; margin: 0 0 8px; }
.tl-pool.over, .tl-drop-files.over { outline: 3px dashed var(--accent); }
.tl-sel { position: sticky; bottom: 10px; z-index: 30; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px;
  padding: 10px 14px; border-radius: var(--radius); background: var(--text); color: var(--surface); box-shadow: 0 6px 20px rgb(0 0 0 / .25); }
.tl-sel span { flex: 1; min-width: 160px; font-size: .9rem; }
.tl-sel .btn { color: var(--surface); border-color: rgb(255 255 255 / .35); }
.tl-sel .icon { width: 14px; height: 14px; }
.tl-adders { margin-top: 14px; gap: 12px; }
.tl-adders textarea { width: 100%; resize: vertical; }
.tl-label-sm { display: block; font-weight: 500; font-size: .9rem; margin: 0 0 6px; }
.tl-adders .icon { width: 14px; height: 14px; }
.tl-opts { margin-top: 12px; }
.tl-opts summary { cursor: pointer; font-weight: 500; }
.tl-opts input[type=color] { width: 44px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.tl-msg { margin: 10px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--info-soft); word-break: break-all; }
.tl-msg.ok { background: var(--ok-soft); }
.tl-msg.bad { background: var(--bad-soft); color: var(--bad); }
.tl-perks { margin: 14px 0 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--info-soft); }
.tl-perks .icon { width: 16px; height: 16px; vertical-align: -3px; }

/* row editor */
.tl-dialog { border: 0; border-radius: var(--radius); padding: 20px 22px; width: min(92vw, 420px); background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / .35); }
.tl-dialog::backdrop { background: rgb(0 0 0 / .45); }
.tl-dialog h3 { margin: 0 0 12px; }
.tl-swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tl-swatches button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgb(0 0 0 / .1); cursor: pointer; }
.tl-swatches input { width: 36px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.tl-dialog-btns { display: flex; flex-wrap: wrap; gap: 6px; }

/* community ranking + template links */
.tl-community { margin-top: 28px; }
.tl-community h2 { font-size: 1.2rem; margin: 0 0 6px; }
.tl-community .tl-item { cursor: default; }
.tl-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tl-tpl { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s; }
.tl-tpl:hover { border-color: var(--accent); transform: translateY(-2px); }
.tl-tpl span { font-size: 1.5rem; }

@media (max-width: 640px) {
  :root { --tile: 58px; }
  .tl-app[data-size=s] { --tile: 46px; }
  .tl-app[data-size=l] { --tile: 76px; }
  .tl-label { width: 64px; font-size: 1.15rem; }
  .tl-item .e { font-size: 1.5rem; }
  .tl-item .t { font-size: .64rem; }
  .tl-adders { grid-template-columns: minmax(0, 1fr); }
}

/* browsing templates */
.tl-browse { margin-top: 26px; }
.tl-browse-cat { margin-top: 18px; }
.tl-browse-cat .section-title a { color: inherit; text-decoration: none; }
.tl-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.tl-cats a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: .88rem; color: var(--text); text-decoration: none; }
.tl-cats a:hover, .tl-cats a.active { border-color: var(--accent); background: var(--accent-soft); }
.tl-tpl img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; flex: none; }
.tl-tpl b { min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tl-cta { margin: 18px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--gold-soft); }
.tl-cta .icon { width: 16px; height: 16px; vertical-align: -3px; }

/* member templates: owner line, report form, create page, review page */
.tl-ut-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 12px; color: var(--muted); }
.tl-ut-meta .icon { width: 15px; height: 15px; vertical-align: -3px; }
.tl-report summary { cursor: pointer; }
.tl-report form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding: 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface); max-width: 360px; }
.tl-create-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.tl-create-item { display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.tl-create-item img, .tl-create-txt { width: 44px; height: 44px; flex: none; border-radius: 6px; object-fit: cover; }
.tl-create-txt { display: grid; place-items: center; background: var(--surface-2, var(--line)); color: var(--muted); font-weight: 700; }
.tl-create-item input { flex: 1; min-width: 0; padding: 6px 8px; }
.tl-review { margin-bottom: 12px; }
.tl-review .tl-row { min-height: 0; }

/* maker page layout: the maker on the left, the template panel (templates/tier_list/_picker.html) on the right */
.container.tl-wide { width: min(1400px, 100% - 32px); }
.tl-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.tl-main { min-width: 0; }
.tl-picker { position: sticky; top: 78px; max-height: calc(100vh - 96px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tl-pick-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 10px; }
.tl-pick-head h2 { margin: 0; font-size: 1.02rem; display: flex; align-items: center; gap: 8px; }
.tl-pick-head h2 .icon { color: var(--accent); }
.tl-pick-toggle { display: none; }
.tl-pick-toggle .when-open, .tl-picker.open .tl-pick-toggle .when-closed { display: none; }
.tl-picker.open .tl-pick-toggle .when-open { display: inline; }
.tl-pick-body { display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1; padding: 0 12px 12px; }
.tl-pick-body input[type=search] { border-radius: 999px; padding: 8px 14px; }
.tl-pick-cats { display: flex; flex-wrap: wrap; gap: 5px; }
.tl-pick-cats button { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .78rem; cursor: pointer; transition: border-color .12s, background .12s; }
.tl-pick-cats button:hover { border-color: var(--accent); }
.tl-pick-cats button span { color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.tl-pick-cats button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tl-pick-cats button[aria-pressed=true] span { color: inherit; opacity: .85; }
.tl-pick-count { margin: 0; color: var(--muted); }
.tl-pick-list { position: relative; list-style: none; margin: 0 -4px; padding: 0 4px; overflow-y: auto; overscroll-behavior: contain;
  flex: 1; min-height: 120px; display: flex; flex-direction: column; gap: 2px; }
.tl-pick-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius-sm); color: var(--text);
  text-decoration: none; border: 1px solid transparent; }
.tl-pick-item:hover { background: var(--surface-2); border-color: var(--line); }
.tl-pick-item.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.tl-pick-item .ico { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 1.3rem; }
.tl-pick-item .ico img { width: 100%; height: 100%; object-fit: contain; }
.tl-pick-item .nm { min-width: 0; display: flex; flex-direction: column; font-size: .9rem; font-weight: 600; line-height: 1.3; }
.tl-pick-item .nm, .tl-pick-item small { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tl-pick-item small { font-size: .74rem; font-weight: 400; color: var(--muted); -webkit-line-clamp: 1; }
.tl-pick-blank .ico { background: var(--accent-soft); }
.tl-pick-empty { margin: 0; padding: 18px 8px; text-align: center; color: var(--muted); }

/* narrower screens: the panel moves above the maker and folds to its title bar */
@media (max-width: 1100px) {
  .tl-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .tl-picker { order: -1; position: static; max-height: none; }
  .tl-pick-head { padding: 10px 12px; }
  .tl-pick-toggle { display: inline-flex; }
  .tl-picker:not(.open) .tl-pick-body { display: none; }
  .tl-pick-list { max-height: 50vh; }
}
