.tm-root {
  --tm-bg: #192524;
  --tm-field: #111c1c;
  --tm-line: #384640;
  --tm-ink: #f0eee4;
  --tm-muted: #a7b2a9;
  --tm-accent: #d7ed85;
  display: grid;
  gap: 18px;
  color: var(--tm-ink);
  font-size: 14px;
}
.tm-root[hidden], .tm-root [hidden] { display: none !important; }
.tm-root *, .tm-root *::before, .tm-root *::after { box-sizing: border-box; }
.tm-root button, .tm-root input { font: inherit; }
.tm-root button { cursor: pointer; }
.tm-root button:disabled { cursor: default; }
.tm-root :is(button,input):focus-visible { outline: 2px solid var(--tm-accent); outline-offset: 3px; }
.tm-card {
  min-width: 0; padding: clamp(16px, 2.3vw, 30px);
  border: 1px solid var(--tm-line); border-radius: 12px; background: var(--tm-bg);
}
.tm-heading, .tm-pick-head, .tm-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tm-root h2, .tm-root h3, .tm-root p { margin: 0; }
.tm-root h2 { font-size: clamp(16px, 2vw, 20px); font-weight: 700; letter-spacing: .02em; }
.tm-pick-head h3 { font-size: 14px; font-weight: 650; }
.tm-link {
  min-height: 36px; padding: 4px 3px; border: 0; background: none;
  color: var(--tm-muted); font-size: 12px !important; white-space: nowrap;
}
.tm-link:hover { color: var(--tm-ink); text-decoration: underline; }
.tm-slots {
  display: grid; grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 9px; margin-top: 18px;
}
.tm-slot {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-width: 0; min-height: 74px; padding: 11px 14px; text-align: left;
  border: 1px solid var(--tm-line); border-radius: 7px; color: var(--tm-ink); background: var(--tm-field);
}
.tm-slot:hover { border-color: #71806e; }
.tm-slot-on { background: #303c2b; border-color: var(--tm-accent); }
.tm-slot-number, .tm-choice-slot, .tm-count {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums;
}
.tm-slot-number { color: var(--tm-muted); font-size: 11px; letter-spacing: .1em; }
.tm-slot-on .tm-slot-number { color: var(--tm-accent); }
.tm-slot-name { margin-top: 5px; font-size: clamp(12px,1.25vw,16px); font-weight: 700; overflow-wrap: anywhere; }
.tm-picker { margin-top: 23px; }
.tm-pick-head { flex-wrap: wrap; margin-bottom: 12px; }
.tm-search {
  display: flex; align-items: center; gap: 8px; min-width: 0; border: 1px solid var(--tm-line);
  border-radius: 5px; background: var(--tm-field); color: var(--tm-muted); padding: 0 11px;
}
.tm-search:focus-within { border-color: var(--tm-accent); }
.tm-glass { display: inline-block; position: relative; width: 12px; height: 12px; border: 1.5px solid; border-radius: 50%; }
.tm-glass::after { content: ''; position: absolute; width: 6px; height: 1.5px; background: currentColor; transform: rotate(45deg); bottom: -2px; right: -4px; }
.tm-search input {
  min-height: 36px; width: 180px; max-width: 100%; padding: 2px 0 2px 2px;
  border: 0; outline: 0; color: var(--tm-ink); background: transparent; font-size: 12px;
}
.tm-search input:focus-visible { outline: none; }
.tm-root input::placeholder { color: #9ca69d; opacity: 1; }
.tm-choices {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px,1fr));
  gap: 6px; max-height: 252px; padding: 3px; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-color: #596956 var(--tm-field); scrollbar-width: thin;
}
.tm-choice {
  display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 36px;
  padding: 7px 9px; border: 1px solid var(--tm-line); border-radius: 5px;
  background: transparent; color: #dedfd5; text-align: left; font-size: 12px !important;
}
.tm-choice:hover:enabled, .tm-secondary:hover { border-color: #8a9b7e; background: #253328; }
.tm-choice[aria-pressed="true"] { border-color: #9bad69; color: var(--tm-accent); background: #29372a; }
.tm-choice:disabled { background: var(--tm-field); color: #9aa69a; }
.tm-choice-slot { font-size: 10px; white-space: nowrap; }
.tm-no-match { grid-column: 1/-1; padding: 12px 5px; color: var(--tm-muted); }
.tm-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; border-top: 1px solid var(--tm-line); margin-top: 20px; padding-top: 18px; }
.tm-name { display: grid; gap: 6px; flex: 1 1 190px; color: var(--tm-muted); font-size: 12px; font-weight: 600; }
.tm-name input { width: 100%; min-width: 0; height: 41px; padding: 8px 12px; color: var(--tm-ink); border: 1px solid var(--tm-line); border-radius: 5px; background: var(--tm-field); font-size: 14px; }
.tm-primary, .tm-secondary, .tm-danger {
  min-height: 41px; padding: 8px 15px; border: 1px solid transparent; border-radius: 5px; font-size: 12px !important; font-weight: 650 !important;
}
.tm-primary { background: var(--tm-accent); color: #1b291c; }
.tm-primary:hover:enabled { background: #e8f8ad; }
.tm-primary:disabled, .tm-secondary:disabled { opacity: .44; }
.tm-secondary { background: var(--tm-field); border-color: var(--tm-line); color: var(--tm-ink); }
.tm-count { color: var(--tm-muted); font-size: 12px; }
.tm-empty { padding: 19px 0 3px; color: var(--tm-muted); font-size: 13px; }
.tm-row { flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--tm-line); }
.tm-row:first-child { margin-top: 14px; }
.tm-row:last-child { padding-bottom: 0; }
.tm-row-body { flex: 1 1 230px; min-width: 0; }
.tm-row-body h3 { font-size: 15px; overflow-wrap: anywhere; }
.tm-row-body p { margin-top: 5px; color: var(--tm-muted); font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.tm-row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.tm-confirm { font-size: 12px; color: var(--tm-muted); }
.tm-danger { color: #f1c1ae; border-color: #725246; background: #3a2c28; }
.tm-message { min-height: 1.2em; padding-inline: 2px; color: var(--tm-muted); font-size: 12px; }
@media (max-width: 560px) {
  .tm-slots { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; margin-top: 12px; }
  .tm-slot { min-height: 55px; padding: 8px 10px; }
  .tm-slot-name { font-size: 14px; }
  .tm-pick-head { align-items: flex-start; flex-direction: column; }
  .tm-search, .tm-search input { width: 100%; }
  .tm-choices { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .tm-choice { min-height: 40px; }
  .tm-name { flex-basis: 100%; }
}
@media (pointer: coarse) {
  .tm-root :is(.tm-choice, .tm-link, .tm-primary, .tm-secondary, .tm-danger, .tm-search input, .tm-name input) {
    min-height: 44px;
  }
  .tm-root :is(.tm-link, .tm-secondary, .tm-danger) { min-width: 44px; }
  .tm-root :is(.tm-search input, .tm-name input) { font-size: 16px; }
}

.tm-art-credit {
  display: block; width: fit-content; margin: 6px 2px 0 auto;
  padding: 3px 0; color: var(--tm-muted); font-size: .76rem; text-underline-offset: 3px;
}
.tm-with-portraits .tm-slots { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tm-with-portraits .tm-slot {
  flex-direction: row; align-items: center; justify-content: center; gap: 12px; min-height: 74px;
  padding: 5px 8px; overflow: hidden;
}
.tm-with-portraits .tm-slot-number { font-size: .82rem; }
.tm-slot-portrait { width: 62px; height: 62px; object-fit: contain; }
.tm-with-portraits .tm-choices { grid-template-columns: repeat(auto-fill, minmax(62px,1fr)); gap: 6px; max-height: 290px; }
.tm-with-portraits .tm-choice { position: relative; padding: 3px; min-height: 64px; justify-content: center; }
.tm-with-portraits .tm-choice:disabled .tm-choice-portrait { opacity: .57; }
.tm-choice-portrait { width: 55px; height: 55px; object-fit: contain; }
.tm-with-portraits .tm-choice-slot {
  position: absolute; bottom: 2px; right: 2px; border-radius: 3px;
  border: 1px solid var(--tm-line); padding: 1px 3px; color: var(--tm-accent); background: var(--tm-field);
}
.tm-saved-portraits { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.tm-saved-portrait { width: 38px; height: 38px; object-fit: contain; }
.tm-portrait-fallback { width: auto; height: auto; overflow-wrap: anywhere; }
@media(max-width:560px) {
  .tm-with-portraits .tm-slot { position: relative; min-height:70px; gap:0; padding: 6px 3px 1px; }
  .tm-with-portraits .tm-slot-number { position: absolute; top: 2px; left: 4px; font-size:.65rem; }
  .tm-slot-portrait { width: 100%; max-width: 49px; height: 49px; }
  .tm-with-portraits .tm-choices { grid-template-columns: repeat(auto-fill, minmax(49px,1fr)); gap: 4px; max-height: 236px; }
  .tm-with-portraits .tm-choice { min-height: 54px; }
  .tm-choice-portrait { width: 45px; height: 45px; }
}
