/* TTA Chat - Playwright AI Practice Sandbox
   Styles layered on top of /playwright/theme.css.
   Selectors avoid !important so the shared theme still wins for design tokens.
*/

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-2);
  color: var(--ink);
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: -9999px;
}
.skip-link:focus {
  left: 16px;
  top: 16px;
  z-index: 1000;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header ---------- */

.chat-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.chat-header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
}

.brand-name {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.brand-tagline {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

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

.icon-btn.small {
  width: 28px;
  height: 28px;
  font-size: 1.05rem;
  line-height: 1;
}

.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }

/* ---------- Disclaimer banner ---------- */

.disclaimer-banner {
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 20px;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  line-height: 1.5;
}

.disclaimer-banner strong {
  color: var(--ink);
}

.disclaimer-banner code {
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
}

/* ---------- Main chat shell ---------- */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.chat-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 12px;
  min-height: 0;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 40px 16px 28px;
  color: var(--ink);
}

.empty-state h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.empty-state p {
  margin: 0 auto 20px;
  max-width: 56ch;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.96rem;
}

.empty-state code {
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.85rem;
}

.empty-suggestions {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.suggestion-chip {
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 8px 14px;
  border-radius: 999px;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.suggestion-chip:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

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

/* ---------- Messages ---------- */

.message-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.message-user {
  background: var(--accent-ghost);
  border-color: var(--accent-soft);
}

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

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--accent);
  color: #fff;
  flex: 0 0 28px;
  margin-top: 2px;
}

.message-user .message-avatar {
  background: var(--ink-soft);
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-role {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}

.message-content {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 0.97rem;
  line-height: 1.6;
  color: var(--ink);
}

.message-content code {
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.85rem;
}

.message-content pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.85rem;
  margin: 8px 0;
}

.message-content pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

/* ---------- Status + error ---------- */

.message-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-top: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.9rem;
}

.message-status[hidden] {
  display: none;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-top: 16px;
  border-radius: var(--radius-md);
  border: 1px solid #e64949;
  background: rgba(230, 73, 73, 0.08);
  color: var(--ink);
  font-size: 0.9rem;
}

.error-banner[hidden] { display: none; }

.error-text {
  flex: 1;
  word-break: break-word;
}

/* ---------- Composer ---------- */

.composer {
  position: sticky;
  bottom: 0;
  background: var(--bg-2);
  padding: 12px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.composer-row {
  display: flex;
  align-items: stretch;
}

.chat-input {
  width: 100%;
  resize: vertical;
  min-height: 56px;
  max-height: 240px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 0.97rem;
  line-height: 1.5;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.chat-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chat-input::placeholder { color: var(--muted-2); }

.composer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-left,
.composer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.composer-select {
  font-family: inherit;
  font-size: 0.88rem;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

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

.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-primary[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--border-strong);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

/* ---------- Settings drawer ---------- */

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 90;
}

.settings-overlay[hidden] { display: none; }

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(420px, 92vw);
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.18s ease;
}

.settings-drawer[hidden] { display: none; }

.settings-drawer.is-open {
  transform: translateX(0);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.settings-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-group h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.settings-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.settings-hint code {
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
}

.settings-label {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.settings-input,
.settings-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.92rem;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
}

.settings-input:focus-visible,
.settings-textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.settings-status {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.settings-status[data-state="set"] {
  color: var(--accent);
}

.settings-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-slider {
  flex: 1;
}

.settings-slider-value {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--ink);
  min-width: 36px;
  text-align: right;
}

.settings-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.92rem;
}

.settings-toggle-label {
  color: var(--ink);
}

/* ---------- Footer ---------- */

.chat-footer {
  padding: 16px 20px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.chat-footer a {
  color: var(--accent);
  text-decoration: none;
}

.chat-footer a:hover {
  text-decoration: underline;
}

.chat-footer code {
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .brand-tagline { display: none; }
  .chat-shell { padding: 16px 14px 8px; }
  .composer-controls { flex-wrap: wrap; }
  .composer-left { flex: 1 1 100%; }
  .composer-right { flex: 1 1 100%; justify-content: flex-end; }
}
