/* ---------- tier list ---------- */
.tl-toolbar { margin-bottom: var(--s4); }
.tl-title-input { flex: 1 1 220px; width: auto; min-width: 0; }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r2); border: 1px solid var(--line); background: var(--surface-2); }
.seg-btn {
  min-height: 34px; padding: 0 var(--s3); border: 0; border-radius: var(--r1); background: transparent; color: var(--muted);
  font: 600 14px var(--font-body); cursor: pointer; white-space: nowrap;
  transition: color .2s var(--ease), background-color .2s var(--ease), transform .25s var(--spring);
}
.seg-btn:hover { color: var(--text); background: var(--surface-3); }
.seg-btn:active { transform: scale(.96); }
.seg-btn[aria-pressed="true"] { color: var(--gold-ink); background: linear-gradient(180deg, var(--gold-hi), var(--gold)); }

/* board: a label column in the tier's colour, then the icons */
.tl-board {
  display: grid; gap: 3px; padding: 3px; border-radius: var(--r2);
  background: #07080c; border: 1px solid var(--line); box-shadow: var(--shadow-2);
}
.tl-title { padding: var(--s3) var(--s3) var(--s2); font-size: clamp(18px, 2.6vw, 22px); }
.tl-row { display: grid; grid-template-columns: 84px 1fr auto; min-height: 76px; border-radius: 6px; overflow: hidden; background: var(--surface-1); }
.tl-label {
  display: grid; place-items: center; padding: var(--s2);
  background: var(--tier); color: #15110a; font: 700 22px/1.1 var(--font-display); text-align: center; overflow-wrap: anywhere;
}
.tl-label span { font-size: clamp(16px, 2.4vw, 22px); }
.tl-label-input {
  width: 100%; min-width: 0; padding: var(--s1) 2px; border: 1px dashed rgba(21, 17, 10, .35); border-radius: var(--r1);
  background: transparent; color: inherit; font: inherit; text-align: center;
}
.tl-label-input:hover { border-color: rgba(21, 17, 10, .6); }
.tl-label-input:focus-visible { outline: 2px solid #15110a; outline-offset: 0; }
.tl-drop {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: var(--s2); padding: var(--s2) var(--s3);
  min-width: 0; transition: background-color .15s var(--ease);
}
.tl-row .tl-drop { align-content: center; }
.tl-drop.over { background: color-mix(in srgb, var(--tier, var(--gold)) 10%, transparent); }
.tl-row-tools { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: var(--s1); border-left: 1px solid var(--line); }
.tl-mini {
  width: 28px; height: 22px; border: 0; border-radius: 4px; background: transparent; color: var(--muted);
  font: 600 13px/1 var(--font-body); cursor: pointer; transition: color .2s var(--ease), background-color .2s var(--ease), transform .25s var(--spring);
}
.tl-mini:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }
.tl-mini:active:not(:disabled) { transform: scale(.9); }
.tl-mini:disabled { opacity: .25; cursor: default; }
.tl-add { margin-top: var(--s3); }

/* icon: the spec or class art, a class-colour rim, and the class crest on specs */
.tl-item {
  position: relative; display: grid; justify-items: center; gap: 3px; padding: 0; border: 0; background: none;
  color: var(--text); font: inherit; cursor: grab; -webkit-user-select: none; user-select: none;
  transition: transform .3s var(--spring), opacity .2s var(--ease);
}
.tl-view .tl-item { cursor: default; }
.tl-art { position: relative; display: block; width: 56px; height: 56px; }
.tl-art > img:first-child {
  width: 56px; height: 56px; border-radius: 8px;
  box-shadow: 0 0 0 2px var(--c), 0 0 0 3px rgba(0, 0, 0, .7), 0 4px 10px rgba(0, 0, 0, .5);
}
.tl-crest {
  position: absolute; right: -5px; bottom: -5px; width: 22px; height: 22px; border-radius: 50%;
  box-shadow: 0 0 0 2px #07080c, 0 0 0 3px var(--c);
}
.tl-name { max-width: 76px; font-size: 12px; font-weight: 600; line-height: 1.2; text-align: center; color: var(--muted); }
.tl-item.named { width: 76px; gap: 8px; }
.tl-item:hover { transform: translateY(-2px); }
.tl-item:active { transform: scale(.95); }
.tl-item:focus-visible { outline: none; }
.tl-item:focus-visible .tl-art > img:first-child { box-shadow: 0 0 0 2px var(--c), 0 0 0 4px var(--gold-hi); }
.tl-item.selected .tl-art > img:first-child { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 0 5px rgba(242, 201, 110, .35), 0 6px 18px rgba(242, 201, 110, .3); }
.tl-item.selected { transform: translateY(-3px); }
.tl-item.dragging { opacity: .25; }
.tl-item img { -webkit-user-drag: none; pointer-events: none; }
/* editor only: a drag must not scroll the page */
html:not(.tl-view-mode) .tl-item { touch-action: none; }

.tl-ghost { position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none; filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .6)); }
.tl-marker { align-self: stretch; width: 3px; min-height: 56px; border-radius: 2px; background: var(--gold-hi); box-shadow: 0 0 10px rgba(242, 201, 110, .6); }
html.tl-dragging, html.tl-dragging * { cursor: grabbing !important; }

/* pool and code panels */
.tl-pool-panel, .tl-code-panel { margin-top: var(--s5); padding: var(--s5); }
.tl-pool-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }
.tl-hint { margin: var(--s2) 0 var(--s3); color: var(--faint); font-size: 14px; }
.tl-pool { min-height: 80px; padding: var(--s3); border: 1px dashed var(--line-strong); border-radius: var(--r2); }
.tl-empty { color: var(--faint); font-size: 14px; align-self: center; }
.tl-code-panel { display: grid; gap: var(--s5); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.tl-code-col { display: grid; gap: var(--s2); align-content: start; }
.tl-code-col h2 { font-size: 18px; }
.tl-code-col .muted { font-size: 14px; }
.tl-code { min-height: 96px; padding: var(--s2) var(--s3); resize: vertical; font: 500 13px/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace; word-break: break-all; }
.tl-code-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* embedded view: just the board */
.tl-view-mode main { padding: var(--s2) 0; }

@media (max-width: 600px) {
  .tl-row { grid-template-columns: 56px 1fr auto; min-height: 60px; }
  .tl-label { font-size: 17px; padding: var(--s1); }
  .tl-drop { gap: 6px; padding: 6px var(--s2); }
  .tl-art, .tl-art > img:first-child { width: 44px; height: 44px; }
  .tl-crest { width: 18px; height: 18px; }
  .tl-item.named { width: 62px; }
  .tl-name { font-size: 11px; max-width: 62px; }
  .tl-pool-panel, .tl-code-panel { padding: var(--s4); }
}
