/* ── Sports list view ────────────────────────────────────────────────────── */
.sports-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 0.5rem);
}

.btn-sm {
  padding: 0.48rem 0.82rem;
  font-size: 0.82rem;
}

.sport-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  backdrop-filter: blur(6px);
  animation: rise 420ms ease both;
}

.sport-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.72rem 0.85rem;
  border-bottom: 1px solid rgba(165, 202, 214, 0.12);
}

.sport-card__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.sport-icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.sport-card__title h3 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sport-card__count {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  flex-shrink: 0;
  line-height: 1.3;
}

.sport-card__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* ── Template rows ───────────────────────────────────────────────────────── */
.templates-list {
  padding: 0.5rem 0.65rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.template-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.48rem 0.55rem;
  border-radius: 11px;
  background: rgba(7, 22, 30, 0.42);
  border: 1px solid rgba(165, 202, 214, 0.1);
  transition: border-color 150ms;
}

.template-row:hover {
  border-color: rgba(165, 202, 214, 0.25);
}

.template-row__info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.template-row__name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-row__meta {
  font-size: 0.72rem;
  color: var(--text-soft);
  white-space: nowrap;
  flex-shrink: 0;
}

.template-row__actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.sport-no-templates {
  margin: 0;
  padding: 0.35rem 0;
  font-size: 0.82rem;
  color: var(--text-soft);
  font-style: italic;
}

/* ── Icon buttons ────────────────────────────────────────────────────────── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(170, 198, 209, 0.2);
  background: rgba(170, 198, 209, 0.06);
  color: var(--text-soft);
  cursor: pointer;
  transition: color 160ms, background-color 160ms, border-color 160ms;
  flex-shrink: 0;
  padding: 0;
}

.icon-btn:hover {
  color: var(--text-main);
  background: rgba(170, 198, 209, 0.15);
}

.danger-icon-btn {
  border-color: rgba(218, 65, 65, 0.25);
  color: rgba(218, 65, 65, 0.65);
}

.danger-icon-btn:hover {
  background: rgba(218, 65, 65, 0.16);
  color: var(--danger);
  border-color: rgba(218, 65, 65, 0.5);
}

/* ── Add sport dialog — compact row ──────────────────────────────────────── */
.add-sport-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.add-sport-icon {
  width: 56px;
  text-align: center;
  font-size: 1.35rem;
  padding: 0.45rem;
  flex-shrink: 0;
}

.add-sport-name {
  flex: 1;
  min-width: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ── TEMPLATE EDITOR DIALOG ─────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.tpl-editor-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text-main);
  max-width: 100vw;
  max-height: 100dvh;
  width: 100vw;
  height: 100dvh;
}

.tpl-editor-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
}

/* On desktop, center card */
@media (min-width: 640px) {
  .tpl-editor-dialog {
    width: min(560px, calc(100vw - 2rem));
    height: auto;
    max-height: calc(100dvh - 2rem);
    border-radius: var(--radius-lg);
    background: #0c1d24;
    border: 1px solid var(--line);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  }
}

.tpl-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #0c1d24;
}

@media (min-width: 640px) {
  .tpl-editor {
    max-height: calc(100dvh - 2rem);
    border-radius: var(--radius-lg);
    overflow: hidden;
  }
}

/* ── Header (fixed top) ── */
.tpl-editor__head {
  flex-shrink: 0;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.tpl-editor__head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tpl-editor__head-row h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.tpl-editor__sport {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tpl-editor__name {
  width: 100%;
  font-size: 0.92rem;
  padding: 0.55rem 0.65rem;
}

/* ── Blocks header (fixed) ── */
.tpl-editor__blocks-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(165, 202, 214, 0.08);
}

.tpl-editor__blocks-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-soft);
  font-weight: 600;
}

.tpl-editor__blocks-count {
  font-size: 0.74rem;
  color: var(--accent);
  font-weight: 600;
}

.tpl-editor__add-block {
  margin-left: auto;
}

/* ── Error ── */
.tpl-editor__error {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--danger);
  margin: 0;
  padding: 0.3rem 1rem 0;
}

/* ── Blocks list (SCROLLABLE ZONE) ── */
.tpl-editor__blocks {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tpl-no-blocks {
  margin: 0;
  padding: 1.5rem 0.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-soft);
}

/* ── Block row ── */
.tpl-block-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  background: rgba(7, 22, 30, 0.55);
  border: 1px solid rgba(165, 202, 214, 0.1);
  border-radius: 10px;
}

.tpl-block-num {
  font-size: 0.7rem;
  color: var(--text-soft);
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  font-weight: 600;
}

.input-field {
  background: rgba(7, 22, 30, 0.65);
  border: 1px solid rgba(165, 202, 214, 0.2);
  border-radius: 8px;
  color: var(--text-main);
  padding: 0.45rem 0.55rem;
  font-size: 0.86rem;
  font-family: inherit;
  transition: border-color 160ms;
}

.input-field:focus {
  outline: none;
  border-color: rgba(24, 191, 125, 0.5);
}

.tpl-block-name {
  flex: 1;
  min-width: 0;
}

.tpl-duration-wrap {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.input-num {
  width: 40px;
  text-align: center;
  padding: 0.45rem 0.2rem;
  -moz-appearance: textfield;
}

.input-num::-webkit-inner-spin-button,
.input-num::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.tpl-colon {
  font-size: 0.85rem;
  color: var(--text-soft);
  padding: 0 1px;
}

.tpl-rm-btn {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* ── Footer (fixed bottom) ── */
.tpl-editor__foot {
  flex-shrink: 0;
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  padding-bottom: calc(0.7rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.tpl-editor__foot .secondary-btn {
  flex: 0 0 auto;
}

.tpl-editor__foot .primary-btn {
  flex: 1;
}

/* ── Mobile compact tweaks ───────────────────────────────────────────────── */
@media (max-width: 639px) {
  .tpl-editor__head {
    padding: 0.7rem 0.75rem;
    gap: 0.45rem;
  }

  .tpl-editor__head-row h2 {
    font-size: 1.05rem;
  }

  .tpl-editor__blocks-head {
    padding: 0.5rem 0.75rem;
  }

  .tpl-editor__blocks {
    padding: 0.45rem 0.55rem;
    gap: 0.35rem;
  }

  .tpl-block-row {
    gap: 0.3rem;
    padding: 0.35rem 0.4rem;
  }

  .tpl-block-name {
    font-size: 0.82rem;
    padding: 0.38rem 0.45rem;
  }

  .input-num {
    width: 36px;
    padding: 0.38rem 0.15rem;
    font-size: 0.82rem;
  }

  .tpl-editor__foot {
    padding: 0.6rem 0.75rem;
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom));
  }
}

/* ── Small screen extra compact ─────────────────────────────────────────── */
@media (max-width: 389px) {
  .tpl-block-name {
    font-size: 0.78rem;
  }

  .input-num {
    width: 33px;
    font-size: 0.78rem;
  }
}
