/* 팀 나누기. 팀 색은 카드마다 --tc 로 받고, 나머지는 공통 변수를 써서 어두운 화면에 맞춘다. */
.tm {
  margin-top: 22px;
  display: grid;
  gap: 14px;
}
.tm-setup,
.tm-out {
  padding: clamp(16px, 4vw, 22px);
}
.tm-setup {
  display: grid;
  gap: 18px;
}
@media (min-width: 720px) {
  .tm-setup {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }
}
.tm-h {
  display: block;
  font-weight: 800;
  font-size: 1rem;
}
.tm-h .fine {
  font-weight: 500;
}

/* 이름 */
.tm-text {
  display: block;
  width: 100%;
  min-height: 230px;
  margin-top: 10px;
  resize: vertical;
  font: inherit;
  font-size: 1rem; /* 16px: 아이폰에서 누를 때 화면이 확대되지 않게 */
  font-weight: 600;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 10px 12px;
  outline: none;
}
.tm-text:focus {
  border-color: var(--brand);
  background: var(--surface);
}
.tm-text[aria-invalid='true'] {
  border-color: var(--wait);
}
.tm-count {
  margin: 8px 0 0;
}
.tm-count.is-warn {
  color: var(--wait);
  font-weight: 700;
}
.tm-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.tm-small {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.9rem;
}

/* 설정 */
.tm-opts {
  display: grid;
  gap: 4px;
}
.tm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.tm-row:first-child {
  margin-top: 0;
}
.tm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tm-chips .chip {
  min-height: 38px;
  font-size: 0.88rem;
}
.tm-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tm-step {
  appearance: none;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.tm-step:disabled {
  opacity: 0.4;
  cursor: default;
}
.tm-value {
  min-width: 72px;
  text-align: center;
  font-weight: 800;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}
.tm-plan {
  margin: 6px 0 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--brand-soft);
  font-weight: 700;
  font-size: 0.95rem;
}
.tm-plan.is-warn {
  background: var(--surface-2);
  color: var(--wait);
}
.tm-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.45;
}
.tm-check input {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--brand);
  flex-shrink: 0;
}
.tm-check .fine {
  font-weight: 500;
}
.tm-make {
  width: 100%;
  min-height: 54px;
  margin-top: 16px;
  font-size: 1.08rem;
}
.tm-make:disabled {
  opacity: 0.55;
  cursor: default;
}
.tm-note {
  margin: 10px 0 0;
}

/* 결과 */
.tm-status {
  font-weight: 700;
  margin: 0 0 14px;
  min-height: 1.6em;
  text-align: center;
  overflow-wrap: anywhere;
}
.tm-teams {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 12px;
}
.tm-team {
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  min-width: 0;
}
.tm-team.pop {
  animation: tm-pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}
@keyframes tm-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
}
.tm-team-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 10px 14px;
  background: var(--tc);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
}
.tm-team-head small {
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0.9;
}
.tm-members {
  list-style: none;
  margin: 0;
  padding: 8px;
  display: grid;
  gap: 4px;
}
.tm-name {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 6px 10px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tm-name span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.tm-name[aria-pressed='true'] {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.tm-name[aria-pressed='true']::after {
  content: '고름';
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--brand);
  flex-shrink: 0;
}
.tm-lead {
  flex-shrink: 0;
  font-style: normal;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--tc);
  color: #fff;
}
.tm-swap {
  text-align: center;
  margin: 14px 0 0;
}
.tm-out .actions {
  margin-top: 14px;
}
.tm-out .toast {
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .tm-team.pop {
    animation: none;
  }
}
