:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3a4f;
  --text: #e8eef7;
  --muted: #8b9cb3;
  --accent: #3d9a6a;
  --accent-dim: #2d7a52;
  --danger: #c94c4c;
  --user-bubble: #1e4d3a;
  --bot-bubble: #243044;
  --warn: #c9a227;
  --theme-toggle-bg: rgba(255, 255, 255, 0.08);
  --theme-toggle-border: rgba(255, 255, 255, 0.15);
  font-family: "DM Sans", "Noto Sans KR", system-ui, sans-serif;
}

[data-theme="light"] {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #eaf2ee;
  --border: #c8dbd1;
  --text: #1a2e24;
  --muted: #5a7a69;
  --accent: #2e8055;
  --accent-dim: #236644;
  --danger: #c0392b;
  --user-bubble: #d4eddf;
  --bot-bubble: #ffffff;
  --warn: #b07d10;
  --theme-toggle-bg: rgba(0, 0, 0, 0.05);
  --theme-toggle-border: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] a {
  color: #1a6fa8;
}

[data-theme="light"] .badge.admin {
  color: #8a5f00;
  background: rgba(201, 162, 39, 0.15);
}

[data-theme="light"] .msg-error {
  background: rgba(192, 57, 43, 0.09);
}

[data-theme="light"] .response-callout-success {
  background: rgba(46, 128, 85, 0.1);
}

[data-theme="light"] .response-callout-clarify {
  background: rgba(234, 179, 8, 0.2);
  border-color: rgba(176, 125, 16, 0.35);
  border-left-color: var(--warn);
}

[data-theme="light"] .btn-secondary:hover {
  background: rgba(46, 128, 85, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
}

#app-root {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

a {
  color: #7ec8ff;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.landing {
  flex: 1;
  max-width: 40rem;
  margin: 3rem auto;
  padding: 0 1.25rem;
  width: 100%;
}

.landing h1 {
  font-weight: 600;
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.landing code {
  font-size: 0.85em;
  background: var(--surface);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.landing .examples {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.landing .examples h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.landing .examples ul {
  margin: 0;
  padding-left: 1.25rem;
}

.landing .examples li {
  margin: 0.5rem 0;
  word-break: break-all;
}

.app-header {
  flex-shrink: 0;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.app-header > div:first-child {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.app-header h1,
.app-header .chat-header-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.chat-header-title-block {
  flex: 1 1 auto;
  min-width: min(14rem, 72vw);
  max-width: 100%;
  min-height: 1.35em;
  text-align: left;
}

.chat-header-title.chat-header-title--loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.35em;
}

.chat-header-title-loader {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.chat-header-title-dot {
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.45;
  animation: chat-header-title-dot 1.05s ease-in-out infinite;
}

.chat-header-title-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-header-title-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chat-header-title-dot {
  0%,
  70%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  35% {
    transform: translateY(-0.22rem);
    opacity: 1;
  }
}

.app-header .meta {
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 28rem;
  word-break: break-all;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge.admin {
  border-color: var(--warn);
  color: #f0d060;
  background: rgba(201, 162, 39, 0.12);
}

.app-header .badge {
  flex-shrink: 0;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 52rem;
  width: 100%;
  margin: 0 auto;
  min-height: 0;
}

.chat-main.is-empty .messages {
  display: none;
}

@media (min-width: 521px) {
  .chat-main.is-empty {
    justify-content: center;
    padding-bottom: 4rem;
  }
}

/* ── Quick-action tiles (empty state) ──────────────────────────────────
   Rendered inside `.chat-main` but only visible when the chat is in the
   `is-empty` state. As soon as the first user/assistant bubble appears
   `clearEmpty()` strips the `is-empty` class on `.chat-main` and the
   tiles disappear via the rule below. */
.quick-actions {
  display: none;
}

.chat-main.is-empty .quick-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1.5rem;
  width: 100%;
}

.quick-actions-heading {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  margin: 0;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.quick-action-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  min-height: 7.5rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.quick-action-tile:hover {
  background: var(--surface-2);
  border-color: var(--accent);
}

.quick-action-tile:active {
  transform: translateY(1px);
}

.quick-action-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.quick-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--accent);
  flex-shrink: 0;
}

.chat-main.is-empty .quick-action-tile:hover .quick-action-icon {
  background: var(--surface);
}

.quick-action-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.quick-action-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.quick-action-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 520px) {
  .chat-main.is-empty .quick-actions {
    padding: 0.75rem 0.75rem 1rem;
    gap: 0.6rem;
  }

  .quick-actions-grid {
    gap: 0.6rem;
  }

  .quick-action-tile {
    padding: 0.75rem;
    min-height: 6rem;
    gap: 0.45rem;
  }

  .quick-action-icon {
    width: 1.9rem;
    height: 1.9rem;
  }

  .quick-action-icon svg {
    width: 18px;
    height: 18px;
  }

  .quick-action-title {
    font-size: 0.85rem;
  }

  .quick-action-desc {
    font-size: 0.72rem;
  }
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.msg {
  max-width: 92%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bubble);
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bot-bubble);
}

.msg .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.msg-error {
  border-color: var(--danger);
  background: rgba(201, 76, 76, 0.12);
}

.msg-error .error-user-facing {
  font-size: 0.9rem;
  line-height: 1.45;
}

.msg-loading {
  max-width: max-content;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0;
  height: 1rem;
}

.typing-indicator > span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  opacity: 0.35;
  animation: tlchat-typing-bounce 1.2s infinite ease-in-out;
}

.typing-indicator > span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator > span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes tlchat-typing-bounce {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .typing-indicator > span {
    animation: none;
    opacity: 0.55;
  }
}

.data-panel {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.data-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.server-message {
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 0.35rem;
}

.response-callout {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.45;
}

.response-callout-clarify {
  background: rgba(234, 179, 8, 0.14);
  border-color: rgba(201, 162, 39, 0.4);
  border-left-width: 3px;
  border-left-color: var(--warn);
}

.response-callout-success {
  background: rgba(61, 154, 106, 0.12);
  border-color: var(--accent);
}

.response-json {
  max-height: 14rem;
  overflow: auto;
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  line-height: 1.4;
}

.roster-block {
  margin-top: 0.65rem;
}

.roster-block:first-child {
  margin-top: 0;
}

.roster-heading {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.roster-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.roster-item {
  margin: 0;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.roster-pair {
  font-weight: 500;
}

.roster-plus {
  color: var(--muted);
  font-weight: 400;
}

.roster-list-players .roster-item {
  padding: 0.4rem 0.65rem;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

table.data th,
table.data td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

table.data th {
  color: var(--muted);
  font-weight: 500;
}

.standings-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

table.data th.standings-metric-rank,
table.data td.standings-metric-rank strong {
  font-weight: 700;
}

table.data th.standings-metric-rank {
  color: var(--text);
}

.match-form-roster-notes {
  margin-top: 0.5rem;
  margin-bottom: 0.15rem;
}

.match-form-roster-notes p {
  margin: 0.4em 0;
}

.match-form-roster-notes p:first-child {
  margin-top: 0;
}

.match-form-roster-notes .roster-note-warn {
  color: var(--warn);
}

.action-card {
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.action-card .row {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
  font-size: 0.8rem;
}

.action-card .row label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.action-card .method-url {
  word-break: break-all;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
}

.action-card fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0.75rem 0 0;
  padding: 0.75rem;
}

.action-card fieldset legend {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 0.35rem;
}

.form-grid {
  display: grid;
  gap: 0.65rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
}

.form-grid input {
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.form-grid .nick-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  align-items: end;
  min-width: 0;
}

.form-grid .nick-pair label {
  min-width: 0;
}

/* Wraps a write-form nickname input so its autocomplete popover can be
 * absolutely positioned below the input without escaping the form grid. */
.nick-input-wrap {
  position: relative;
  display: block;
  min-width: 0;
}

/* Nickname autocomplete popover: visually identical to .chat-mention-popover
 * but anchored BELOW the input (forms are read top-down) instead of above. */
.nick-ac-popover {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: min(220px, 40vh);
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
  z-index: 30;
}

[data-theme="dark"] .nick-ac-popover {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.form-scores-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-scores-heading {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.form-scores-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  align-items: end;
  min-width: 0;
}

.form-scores-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  min-width: 0;
}

/* Match score picker: <select> renders as a native wheel on iOS and a
 * list/dropdown elsewhere, all of which prevent free-form typing. */
.form-score-select {
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  appearance: auto;
}

@media (max-width: 520px) {
  .form-score-select {
    font-size: 1rem;
  }
}

.composer {
  flex-shrink: 0;
  padding: 0.85rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.composer form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.composer-input-wrap {
  position: relative;
  flex: 1;
}

.chat-mention-popover {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  margin-bottom: 6px;
  max-height: min(220px, 40vh);
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  z-index: 20;
}

[data-theme="dark"] .chat-mention-popover {
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.45);
}

.chat-mention-item {
  padding: 0.45rem 0.65rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.chat-mention-item:last-child {
  border-bottom: none;
}

.chat-mention-item[role="option"]:hover,
.chat-mention-item[role="option"].is-active {
  background: rgba(61, 154, 106, 0.14);
}

.chat-mention-item.chat-mention-status {
  cursor: default;
  color: var(--muted);
  font-size: 0.85rem;
}

.chat-mention-item.chat-mention-status:hover {
  background: transparent;
}

.composer textarea {
  width: 100%;
  min-height: 4.5rem;
  resize: none;
  overflow-y: hidden;
  padding: 0.55rem 3rem 0.55rem 0.65rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
  box-sizing: border-box;
}

.composer button[type="submit"] {
  position: absolute;
  right: 0.5rem;
  bottom: 0.65rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}

.composer button[type="submit"]:hover {
  background: var(--accent-dim);
}

.composer button[type="submit"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  margin-top: 0.65rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background: rgba(61, 154, 106, 0.15);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.match-picker .match-picker-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.match-picker .match-picker-heading-label {
  margin-right: 0.15rem;
}

.match-picker .match-picker-filter {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.78rem;
}

.match-picker-table td.match-picker-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.btn-edit-row {
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-edit-row:hover {
  background: rgba(61, 154, 106, 0.15);
}

.match-picker-edit-row > td {
  padding: 0.25rem 0 0.65rem;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.match-picker-edit-card {
  margin-top: 0.35rem;
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.chat-footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.75rem;
  color: var(--muted);
}

/* Placeholder until site-header.js + initPage() replace it */
#tlchat-site-header-root:empty {
  display: none;
}

/* Top bar language switch (static pages) */
.site-header {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.45rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.locale-dropdown-wrap {
  display: flex;
  align-items: center;
}

.locale-dropdown {
  margin: 0;
  padding: 0.35rem 2rem 0.35rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--theme-toggle-border);
  background: var(--theme-toggle-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  min-width: 5.5rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b9cb3' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

[data-theme="light"] .locale-dropdown {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a7a69' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

.locale-dropdown:hover {
  border-color: var(--border);
  background-color: var(--surface-2);
}

.locale-dropdown:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.locale-dropdown option {
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
}

.locale-dropdown--compact {
  padding: 0.28rem 1.85rem 0.28rem 0.5rem;
  font-size: 0.78rem;
  min-width: 5rem;
}

.locale-dropdown-wrap--compact {
  flex-shrink: 0;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

/* ── Sticky shortcut bar (starter-tile icons). HELP accordion still uses ────
    .intent-helper-body when rendering the HELP intent panel. ───────────── */

.intent-helper {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 1.25rem;
}

.intent-helper-shortcuts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.intent-helper-quick-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition:
    border-color 0.12s,
    background-color 0.12s,
    transform 0.08s,
    box-shadow 0.12s;
}

.intent-helper-quick-btn:hover {
  border-color: var(--muted);
  background: var(--bg);
}

.intent-helper-quick-btn:active {
  transform: translateY(1px);
}

.intent-helper-quick-btn:focus-visible {
  outline: 2px solid var(--accent-soft, var(--muted));
  outline-offset: 2px;
}

.intent-helper-quick-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.intent-helper-quick-icon svg {
  width: 20px;
  height: 20px;
}

.intent-helper-body {
  padding: 0.75rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 30vh;
  overflow-y: auto;
}

.intent-group-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.intent-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.intent-item {
  padding: 0;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.intent-accordion > .intent-item-summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.intent-accordion > .intent-item-summary::-webkit-details-marker {
  display: none;
}

.intent-chevron {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  min-height: 1em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
}

.intent-chevron::before {
  content: ">";
}

.intent-accordion[open] > .intent-item-summary .intent-chevron::before {
  content: "▼";
  font-size: 0.58rem;
  line-height: 1;
}

.intent-item-details {
  padding: 0 0.75rem 0.65rem 0.75rem;
  padding-left: calc(0.75rem + 1.1em + 0.45rem);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.intent-item-details .intent-desc {
  padding-top: 0.45rem;
}

.intent-name {
  font-size: 0.75rem;
  font-weight: 600;
  font-family: ui-monospace, monospace;
  color: var(--accent);
  margin-bottom: 0;
}

.admin-intents .intent-name {
  color: var(--warn);
}

.intent-desc {
  font-size: 0.78rem;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.intent-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.intent-ex {
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-style: italic;
}

/* ── Theme toggle button ───────────────────────────────────────────────── */

.theme-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--theme-toggle-border);
  background: var(--theme-toggle-bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
}

.theme-toggle .theme-icon {
  font-size: 0.9rem;
  line-height: 1;
}

/* ── Create league page ─────────────────────────────────────────────────── */

.create-league-page .create-league-back {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.create-league-intro {
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.create-league-form {
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.create-league-form .form-grid textarea,
.create-league-form .form-grid select {
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  width: 100%;
}

.create-league-form .form-grid textarea {
  min-height: 4.5rem;
  resize: vertical;
}

.req {
  color: var(--danger);
  font-weight: 600;
}

.optional-label {
  color: var(--muted);
  font-weight: 400;
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-row input {
  width: auto !important;
  margin: 0;
}

.allowlist-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.8rem;
}

.allowlist-field > .field-label-with-help label {
  font-size: inherit;
  display: inline;
}

.allowlist-toggle-input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.allowlist-label-row label[for="require-allowlist-toggle"] {
  cursor: pointer;
}

.chips-input {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.35rem;
  min-height: 4.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: text;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.chips-input:focus-within {
  border-color: var(--accent);
}

.chips-input[data-enabled="false"] {
  background: var(--surface-2);
  opacity: 0.65;
  cursor: not-allowed;
}

.chips-input[data-enabled="false"] .chips-input-field {
  cursor: not-allowed;
}

.chips-input-field {
  flex: 1 1 8rem;
  min-width: 6rem;
  border: none;
  outline: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0.15rem 0;
}

.chips-input-field::placeholder {
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.35rem 0.15rem 0.55rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--text);
  max-width: 100%;
}

.chips-input[data-enabled="true"] .chip {
  background: rgba(61, 154, 106, 0.16);
  border-color: var(--accent);
}

.chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}

.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 50%;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.chip-remove:hover,
.chip-remove:focus-visible {
  background: rgba(201, 76, 76, 0.18);
  color: var(--danger);
  outline: none;
}

.chips-input[data-enabled="false"] .chip-remove {
  pointer-events: none;
}

.create-league-advanced {
  margin-top: 1rem;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--border);
}

.create-league-advanced summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  user-select: none;
}

.create-league-advanced summary:hover {
  color: var(--accent);
}

.create-league-advanced[open] summary {
  margin-bottom: 0.5rem;
}

.create-league-actions {
  margin-top: 1.25rem;
}

.btn-primary {
  padding: 0.55rem 1.35rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dim);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  margin-left: 0.5rem;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.create-league-alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.create-league-alert-error {
  border: 1px solid var(--danger);
  background: rgba(201, 76, 76, 0.12);
  color: var(--text);
}

.create-league-success {
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.create-league-success h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.create-league-credentials {
  margin: 1rem 0 0;
}

.create-league-credentials > div {
  margin-bottom: 0.85rem;
}

.create-league-credentials dt {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.create-league-credentials dd {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.create-league-credentials code {
  font-size: 0.78rem;
  word-break: break-all;
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.create-league-links {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.create-league-links ul {
  margin: 0.35rem 0 0;
  padding-left: 1.25rem;
}

.create-league-links li {
  margin: 0.35rem 0;
}

.create-league-config-hint {
  margin-top: 1.5rem;
}

.field-label-with-help {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
}

.help-icon {
  flex-shrink: 0;
  margin-left: auto;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateY(0.05em);
}

.help-icon:hover {
  border-color: var(--accent);
  color: var(--accent-dim);
}

.help-icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.help-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 5000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.help-modal:not([hidden]) {
  display: flex;
}

.help-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 25, 0.55);
  cursor: pointer;
}

[data-theme="light"] .help-modal-backdrop {
  background: rgba(26, 46, 36, 0.35);
}

.help-modal-card {
  position: relative;
  z-index: 1;
  max-width: 30rem;
  width: 100%;
  max-height: min(70vh, 28rem);
  overflow-y: auto;
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.4);
  padding: 1.1rem 1.25rem 1.25rem;
}

.help-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.help-modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  flex: 1;
}

.help-modal-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.help-modal-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.help-modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.help-modal-body p {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

.help-modal-body p:last-child {
  margin-bottom: 0;
}

/* ── Find league page ───────────────────────────────────────────────────── */

.find-league-form .form-grid input {
  width: 100%;
}

.find-league-results-wrap {
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.find-league-results-heading {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.find-league-results-summary {
  margin: 0 0 1rem;
}

.find-league-results {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.find-league-card {
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.find-league-card-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.find-league-card-id {
  margin: 0 0 0.65rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.find-league-card-id-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.find-league-card-id code {
  font-size: 0.78rem;
  word-break: break-all;
  padding: 0.25rem 0.45rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.find-league-card-actions {
  margin: 0;
  font-size: 0.92rem;
}

/* ── Find league by URL prefix (minimal) ────────────────────────────────── */

.find-league-prefix-shell {
  flex: 1;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 1.5rem;
}

.find-league-prefix-outlet {
  min-height: 0;
}

.find-league-prefix-message {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}

.find-league-prefix-message-muted {
  color: var(--muted);
}

.find-league-prefix-results {
  margin: 0;
}

.find-league-prefix-results .find-league-card--prefix,
.find-league-page .find-league-results .find-league-card--prefix {
  padding: 0.65rem 0.85rem;
}

.find-league-prefix-results .find-league-card-row,
.find-league-page .find-league-results .find-league-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.find-league-prefix-results .find-league-card--prefix .find-league-card-title,
.find-league-page .find-league-results .find-league-card--prefix .find-league-card-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
}

.find-league-card-icon-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--accent);
  line-height: 0;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.find-league-card-icon-link:hover {
  border-color: var(--accent);
  background: var(--surface);
  color: var(--accent-dim);
  text-decoration: none;
}

.find-league-card-icon-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 520px) {
  #theme-toggle-btn {
    display: none;
  }

  #app-root .chat-footer {
    display: none;
  }

  .composer textarea {
    min-height: 3.5rem;
  }
}
