:root {
  color-scheme: light;
  font-family: "Segoe UI", Arial, sans-serif;
  color: #151d2e;
  background: #fff;
  --ink: #151d2e;
  --muted: #657178;
  --line: #dfe5e8;
  --wash: #f5f8f8;
  --teal: #008f79;
  --teal-dark: #006e62;
  --coral: #b75b43;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, textarea, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.app-shell { height: 100dvh; overflow: hidden; }
.brand-mark { display: block; flex: none; width: 160px; height: 40px; object-fit: contain; }

.workspace { display: flex; flex-direction: column; min-width: 0; height: 100dvh; min-height: 0; background: #fff; }
.workspace-header { display: flex; align-items: center; gap: 17px; flex: none; height: 68px; padding: 0 26px; border-bottom: 1px solid var(--line); background: #fff; }
.language-control { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.language-control select { max-width: 190px; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--ink); }
.language-control select:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.header-title { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.header-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.header-title span { font-size: 11px; color: var(--muted); }
.config-banner { flex: none; padding: 11px 28px; border-bottom: 1px solid #eed7c9; background: #fff7f2; color: #8b4937; font-size: 13px; }

.conversation-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; background: #fcfdfd; }
.conversation-content { width: min(100%, 880px); min-height: 100%; margin: 0 auto; padding: 14px 30px 32px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: min(52vh, 420px); text-align: center; }
.empty-mark { display: block; width: 230px; max-width: 65vw; height: auto; margin-bottom: 18px; }
.empty-state h1 { margin: 0; font-size: 21px; font-weight: 650; }
.empty-state p { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.messages { display: flex; flex-direction: column; }
.message-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-self: flex-start; width: fit-content; max-width: min(94%, 760px); padding: 11px 0; }
.message-row.user { align-self: flex-end; grid-template-columns: minmax(0, 1fr) 28px; }
.message-row.user .message-avatar { grid-column: 2; grid-row: 1; background: #e3efeb; color: var(--teal-dark); }
.message-row.user .message-body { grid-column: 1; grid-row: 1; text-align: right; }
.message-row.assistant .message-body { padding: 12px 14px 14px; border: 1px solid var(--line); border-radius: 7px; background: #fff; box-shadow: 0 1px 3px #121d2a0a; }
.message-avatar { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 5px; background: #e1e8e7; color: #445659; font-size: 11px; font-weight: 700; }
.message-row.assistant .message-avatar { background: #151d2e; color: #18c49c; font-size: 16px; }
.message-body { min-width: 0; }
.message-label { margin: 3px 0 9px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.message-text { min-width: 0; color: var(--ink); font-size: 14px; line-height: 1.62; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-row.user .message-text { display: inline-block; max-width: 100%; padding: 10px 12px; border-radius: 6px; background: #e6f2ee; text-align: left; }
.message-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.message-meta span:first-child { color: var(--teal-dark); font-weight: 600; }
.inline-command { margin-top: 10px; padding: 0; border: 0; background: transparent; color: var(--teal-dark); font-size: 12px; font-weight: 600; }
.inline-command:hover { text-decoration: underline; }
.message-row.interrupted .message-label { color: var(--coral); }
.message-results { display: grid; gap: 12px; }
.result-section { min-width: 0; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.result-heading { margin-bottom: 9px; font-size: 13px; font-weight: 700; color: var(--ink); }
.result-stats { display: flex; flex-wrap: wrap; gap: 5px 13px; margin-bottom: 9px; color: var(--muted); font-size: 11px; }
.result-stats span:first-child { color: var(--teal-dark); font-weight: 700; }
.result-item { display: grid; gap: 4px; min-width: 0; padding: 9px 0; border-top: 1px solid #edf0f1; }
.result-item > strong { font-size: 13px; overflow-wrap: anywhere; }
.result-item small { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.stats-missing { padding-top: 3px; }
.match-stats { min-width: 0; margin-top: 6px; color: var(--muted); font-size: 11px; }
.match-stats summary { width: fit-content; cursor: pointer; color: var(--teal-dark); font-weight: 700; }
.stats-period { margin-top: 9px; color: var(--ink); font-weight: 700; }
.match-stats table { width: 100%; margin-top: 7px; border-collapse: collapse; text-align: left; }
.match-stats th, .match-stats td { padding: 5px 7px 5px 0; border-bottom: 1px solid var(--line); font-weight: 400; overflow-wrap: anywhere; }
.match-stats thead th { color: var(--muted); font-weight: 700; }
.match-stats th:first-child { width: 40%; text-transform: capitalize; }
.match-stats td { text-align: right; }
.player-match { margin: 0 0 8px; color: var(--ink); font-size: 13px; font-weight: 600; }
.player-table-scroll { max-width: 100%; overflow-x: auto; }
.player-table { width: 100%; min-width: 460px; border-collapse: collapse; font-size: 11px; }
.player-table th, .player-table td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.player-table th:first-child, .player-table td:first-child { padding-left: 0; text-align: left; font-weight: 600; }
.player-table th { color: var(--muted); font-weight: 700; }
.player-count { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.lineup-side { min-width: 0; padding: 11px 0; border-top: 1px solid var(--line); }
.lineup-side h3 { margin: 0; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.lineup-meta { margin-top: 3px; color: var(--muted); font-size: 11px; }
.lineup-roster { margin-top: 8px; font-size: 11px; }
.lineup-roster summary { width: fit-content; cursor: pointer; color: var(--teal-dark); font-weight: 700; }
.lineup-player { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 6px 0; border-bottom: 1px solid #edf0f1; }
.lineup-player strong { overflow-wrap: anywhere; font-size: 12px; font-weight: 600; }
.lineup-player small, .lineup-unassigned { color: var(--muted); font-size: 11px; }
.lineup-number { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); font-size: 10px; }
.lineup-unassigned { display: block; margin-top: 9px; }
.season-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 11px; min-width: 0; padding: 9px 0; border-top: 1px solid var(--line); }
.season-row strong { min-width: 0; margin-right: auto; font-size: 13px; overflow-wrap: anywhere; }
.season-row small { flex-basis: 100%; color: var(--muted); font-size: 11px; }
.season-state { flex: none; color: var(--muted); font-size: 11px; }
.season-state.current { color: var(--teal-dark); font-weight: 700; }
.season-more { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.fixture { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; font-size: 13px; }
.fixture strong { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.fixture b { flex: none; color: var(--teal-dark); }
.result-empty { margin: 5px 0 9px; color: var(--muted); font-size: 12px; }
.result-json { margin-top: 9px; color: var(--muted); font-size: 11px; }
.result-json summary { width: fit-content; cursor: pointer; color: var(--teal-dark); font-weight: 700; }
.result-json pre { max-height: 280px; overflow: auto; margin: 8px 0 0; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--wash); color: var(--ink); font-size: 11px; line-height: 1.5; }

.candidates { padding: 18px 0 28px 41px; }
.candidate-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.candidate-header h2 { margin: 0; font-size: 14px; }
.candidate-header span { color: var(--muted); font-size: 12px; }
.candidate-search { width: 100%; height: 36px; margin-bottom: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px; outline: none; font-size: 13px; }
.candidate-search:focus, #message-input:focus { border-color: var(--teal); box-shadow: 0 0 0 2px #d8eae6; }
.candidate-list { max-height: 300px; overflow-y: auto; border-top: 1px solid var(--line); }
.candidate-option { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 48px; padding: 9px 10px; border: 0; border-bottom: 1px solid var(--line); background: #fff; color: var(--ink); text-align: left; }
.candidate-option:hover { background: #f0f7f5; }
.candidate-main { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
.candidate-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.candidate-main small, .candidate-option-number { color: var(--muted); font-size: 11px; }
.candidate-option-number { flex: none; }
.candidate-more { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

.activity { display: flex; align-items: center; gap: 8px; min-height: 28px; flex: none; padding: 3px max(30px, calc((100% - 820px) / 2)); color: var(--muted); font-size: 12px; }
.activity.busy::before { content: ""; flex: none; width: 12px; height: 12px; border: 2px solid #c3d8d3; border-top-color: var(--teal); border-radius: 50%; animation: activity-spin .8s linear infinite; }
.activity.error { color: var(--coral); }
@keyframes activity-spin { to { transform: rotate(360deg); } }
.composer { flex: none; padding: 12px 28px 20px; border-top: 1px solid var(--line); background: #fff; }
.composer-inner { width: min(100%, 820px); margin: 0 auto; padding: 10px 11px 9px; border: 1px solid #bfcac9; border-radius: 8px; background: #fff; }
#message-input { display: block; width: 100%; min-height: 34px; max-height: 156px; resize: none; padding: 5px 3px; border: 1px solid transparent; border-radius: 4px; outline: none; color: var(--ink); font-size: 14px; line-height: 1.5; }
#message-input::placeholder { color: #8c999a; }
.composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 5px; }
.composer-state { flex: 1; min-width: 0; color: var(--muted); font-size: 11px; }
.send-button, .secondary-button { min-width: 65px; height: 32px; padding: 0 13px; border-radius: 5px; font-size: 12px; font-weight: 700; }
.send-button { border: 1px solid var(--teal); background: var(--teal); color: #fff; }
.send-button:hover:not(:disabled) { background: var(--teal-dark); }
.secondary-button { border: 1px solid #bfcac9; background: #fff; color: var(--ink); }
.secondary-button:hover { background: var(--wash); }

@media (max-width: 760px) {
  .app-shell { display: block; }
  .workspace { height: 100dvh; }
  .workspace-header { height: 58px; padding: 0 14px; }
  .language-control span { display: none; }
  .brand-mark { width: 128px; height: 32px; }
  .language-control select { max-width: 118px; }
  .header-title span { display: none; }
  .conversation-content { padding: 8px 18px 24px; }
  .empty-state { min-height: 48vh; }
  .message-row { max-width: 94%; padding: 10px 0; }
  .candidates { padding-left: 0; }
  .composer { padding: 10px 12px max(12px, env(safe-area-inset-bottom)); }
  .config-banner { padding: 10px 16px; }
  .activity { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 420px) {
  .workspace-header .header-title { display: none; }
  .language-control select { max-width: 132px; }
}
