:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-muted: #eef4f1;
  --panel: #101820;
  --panel-soft: #18252d;
  --line: #d7e0dd;
  --text: #18212a;
  --muted: #64716d;
  --accent: #176b5d;
  --accent-strong: #0f4f45;
  --accent-soft: #dff3ee;
  --gold: #b88a32;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(16, 24, 32, 0.14);
  --content-width: 1120px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.auth-screen {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.55fr);
  min-height: 100vh;
}

.auth-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 52px max(36px, calc((100vw - var(--content-width)) / 2)) 52px 52px;
  color: #f9fbfa;
  background:
    linear-gradient(135deg, rgba(16, 24, 32, 0.96), rgba(22, 79, 68, 0.94)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cpath d='M0 90h180M90 0v180' stroke='%23ffffff' stroke-opacity='.06'/%3E%3C/svg%3E");
}

.brand-lockup,
.brand-block {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 850;
}

.auth-brand-panel .brand-mark {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.13);
}

.brand-lockup h1,
.brand-block h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.auth-brand-panel .eyebrow {
  color: #b6ddd4;
}

.auth-copy {
  max-width: 740px;
}

.auth-copy h2 {
  margin: 0 0 18px;
  font-size: 44px;
  line-height: 1.08;
  letter-spacing: 0;
}

.auth-copy p {
  max-width: 600px;
  margin: 0;
  color: #d6e5e1;
  font-size: 18px;
  line-height: 1.55;
}

.assurance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.assurance-grid div {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.assurance-grid span {
  color: #d7b779;
  font-size: 12px;
  font-weight: 850;
}

.assurance-grid strong {
  display: block;
  margin: 8px 0 5px;
}

.assurance-grid p {
  margin: 0;
  color: #d6e5e1;
  font-size: 13px;
  line-height: 1.45;
}

.auth-card {
  align-self: center;
  width: min(420px, calc(100vw - 36px));
  margin: 36px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 8px 0 8px;
  font-size: 26px;
  letter-spacing: 0;
}

.auth-hint {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form + .auth-form {
  margin-top: 16px;
}

.auth-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.auth-form input,
.field-group input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--text);
  background: #fbfcfc;
  outline: none;
}

.auth-form input:focus,
.field-group input:focus,
.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 93, 0.16);
}

.auth-status {
  min-height: 22px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.auth-status.success {
  color: var(--accent-strong);
}

.auth-status.info {
  color: var(--muted);
}

.verification-note {
  border: 1px solid #ead7a5;
  border-radius: 8px;
  margin-top: 18px;
  padding: 12px;
  color: #596965;
  background: #fff9ec;
  font-size: 13px;
  line-height: 1.45;
}

.signup-link {
  width: 100%;
  margin-top: 14px;
  text-align: center;
}

.workspace {
  min-height: 100vh;
}

.workspace-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 16px max(24px, calc((100vw - var(--content-width)) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.header-actions a,
.status-pill,
.user-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  text-decoration: none;
}

.user-pill {
  max-width: 260px;
  overflow: hidden;
  color: var(--accent-strong);
  background: var(--accent-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions a:hover {
  border-color: #9bd5c9;
  color: var(--accent-strong);
}

.status-pill.ok {
  border-color: #9bd5c9;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.status-pill.error {
  border-color: #f3b6ae;
  color: var(--danger);
  background: #fff1f0;
}

.workspace-controls,
.capability-strip,
.conversation {
  width: min(var(--content-width), calc(100vw - 48px));
  margin-right: auto;
  margin-left: auto;
}

.workspace-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 24px 0 0;
}

.workspace-title {
  flex: 1 1 420px;
}

.workspace-title h2 {
  margin: 5px 0 0;
  font-size: 26px;
  letter-spacing: 0;
}

.control-row {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
}

.control-row label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.control-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.capability-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 20px 0 8px;
}

.capability-strip div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.capability-strip strong,
.capability-strip span {
  display: block;
}

.capability-strip strong {
  margin-bottom: 4px;
}

.capability-strip span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.conversation {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 0 230px;
}

.message {
  width: min(880px, 100%);
  scroll-margin-bottom: 220px;
}

.user-message {
  align-self: flex-end;
}

.assistant-message {
  align-self: flex-start;
}

.message-label {
  margin: 0 0 7px 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.agent-banner {
  display: inline-flex;
  margin: 0 0 10px;
  border: 1px solid #9bd5c9;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 850;
}

.message-body {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(16, 24, 32, 0.05);
  white-space: pre-wrap;
  line-height: 1.58;
}

.user-message .message-body {
  border-color: #b7d8d2;
  background: #eefaf7;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.message-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 12px;
}

.artifact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.artifact-link {
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}

.artifact-link:hover {
  color: #ffffff;
  background: var(--accent);
}

.composer {
  position: fixed;
  z-index: 30;
  right: max(16px, calc((100vw - var(--content-width)) / 2));
  bottom: 16px;
  left: max(16px, calc((100vw - var(--content-width)) / 2));
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.attachment-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid #b7d8d2;
  border-radius: 8px;
  min-height: 36px;
  padding: 7px 10px;
  color: var(--accent-strong);
  background: #eefaf7;
  font-size: 13px;
}

.attachment-bar button,
.link-button {
  border: 0;
  padding: 4px 6px;
  color: var(--danger);
  background: transparent;
}

.link-button {
  justify-self: center;
  color: var(--accent-strong);
  font-weight: 750;
}

.composer textarea {
  width: 100%;
  max-height: 90px;
  min-height: 44px;
  resize: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--text);
  background: #f8fafc;
  outline: none;
  line-height: 1.45;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.format-control {
  display: flex;
  margin-right: auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.format-control select {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 32px 9px 10px;
  color: var(--text);
  background: var(--surface);
}

.primary-button,
.secondary-button {
  border-radius: 8px;
  padding: 10px 15px;
  font-weight: 850;
}

.primary-button {
  border: 1px solid var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface);
}

.secondary-button:hover {
  background: var(--surface-muted);
}

.secondary-button.slim {
  padding: 8px 12px;
}

.full-width {
  width: 100%;
}

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

@media (max-width: 900px) {
  .auth-screen {
    grid-template-columns: 1fr;
  }

  .auth-brand-panel {
    min-height: auto;
    padding: 32px 24px;
  }

  .auth-copy h2 {
    font-size: 32px;
  }

  .assurance-grid {
    grid-template-columns: 1fr;
    margin-top: 28px;
  }

  .capability-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 740px) {
  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .workspace-controls,
  .capability-strip,
  .conversation {
    width: calc(100vw - 28px);
  }

  .workspace-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-title h2 {
    font-size: 22px;
  }

  .control-row {
    width: 100%;
  }

  .capability-strip {
    grid-template-columns: 1fr;
  }

  .conversation {
    padding-bottom: 260px;
  }

  .message {
    scroll-margin-bottom: 250px;
  }

  .composer {
    right: 14px;
    bottom: 14px;
    left: 14px;
  }

  .composer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
