:root {
  color-scheme: light dark;
  --bg: #f4f4f5;
  --fg: #18181b;
  --muted: #52525b;
  --border: #d4d4d8;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --danger: #b91c1c;
  --surface: #ffffff;
  --focus: #2563eb;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b;
    --fg: #fafafa;
    --muted: #a1a1aa;
    --border: #3f3f46;
    --accent: #3b82f6;
    --accent-fg: #0b1220;
    --danger: #f87171;
    --surface: #18181b;
    --focus: #60a5fa;
  }
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-fg);
  z-index: 100;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.shell {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.shell__header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.shell__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.shell__meta {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-height: 1.25rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.form-field label {
  font-weight: 500;
}

.field-hint {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  min-height: 2.75rem;
}

.form-field textarea {
  min-height: 5rem;
  resize: vertical;
}

.form-field input:focus-visible,
.form-field textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 0.375rem;
  padding: 0.625rem 1rem;
  min-height: 2.75rem;
  min-width: 2.75rem;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.status {
  margin: 0 0 1rem;
  padding: 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border);
  font-size: 0.9375rem;
}

.status--error {
  border-color: var(--danger);
  color: var(--danger);
}

.message-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 50vh;
  overflow-y: auto;
}

.message {
  padding: 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border);
}

.message--user {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.message--assistant {
  background: var(--bg);
}

.message__role {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.message__body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.banner {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--muted);
  border-left-width: 4px;
  border-radius: 4px;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ui-live */
.shell__body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .shell__body {
    flex-direction: row;
    align-items: flex-start;
  }

  .shell__body > .panel {
    flex: 1 1 55%;
    min-width: 0;
  }

  .live-panel {
    flex: 1 1 45%;
    min-width: 0;
  }
}

.live-panel {
  border: 1px solid var(--muted);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: var(--surface);
}

.live-panel__title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.live-panel__status {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.live-panel__meta {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
}

.live-panel__stop {
  margin-top: 0.75rem;
  min-height: 44px;
}

.live-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 14rem;
  overflow-y: auto;
  font-size: 0.8125rem;
}

.live-timeline__item {
  padding: 0.35rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
}

.live-timeline__head {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.live-timeline__body {
  margin: 0.15rem 0 0;
  word-break: break-word;
}

.live-steer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.live-steer button {
  min-height: 44px;
}

/* ui-questions */
.questions-panel {
  margin: 0 0 1rem;
  padding: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--muted) 40%, transparent);
  border-radius: 6px;
  background: var(--surface);
}

.questions-panel__title {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
}

.questions-panel__empty {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

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

.questions-item__text {
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
}

.questions-item__waits {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.questions-item__answer {
  margin: 0;
  font-size: 0.8125rem;
}

.questions-item__form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.questions-item__input {
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
}

.questions-item__options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.questions-item__option {
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.75rem;
}

/* ui-send-queue */
.send-queue {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.send-queue__item {
  padding: 0.5rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 6px;
  background: var(--surface);
}

.send-queue__text {
  margin: 0;
  font-size: 0.9375rem;
  word-break: break-word;
}

.send-queue__meta {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.send-queue__cancel {
  margin-top: 0.5rem;
  min-height: 44px;
}

/* ui-agents-panel */
.agents-panel {
  margin: 0 0 1rem;
  padding: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--muted) 40%, transparent);
  border-radius: 6px;
  background: var(--surface);
}

.agents-panel__title,
.agents-panel__subtitle {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
}

.agents-panel__error {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  color: var(--error, #b00020);
}

.agents-panel__empty {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.agents-list,
.agents-requests-list,
.agents-activity-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.agents-item__pick {
  width: 100%;
  min-height: 44px;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  border: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
}

.agents-item__pick--active {
  border-color: var(--accent, #2563eb);
}

.agents-request__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.agents-request__approve,
.agents-request__refuse {
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.75rem;
}

.agents-request__reason-input {
  flex: 1 1 100%;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
}

.agents-activity-item__meta {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.agents-activity-item__text {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
}
