:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-subtle: #fbfbf8;
  --surface-hover: #f0f0ec;
  --text: #202123;
  --muted: #6f6f69;
  --faint: #8e8e87;
  --line: #e4e4dd;
  --line-strong: #d2d2ca;
  --accent: #10a37f;
  --accent-soft: #e7f5f0;
  --danger: #b42318;
  --shadow-soft: 0 10px 32px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

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

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(16, 163, 127, 0.34);
  outline-offset: 2px;
}

h1,
h2,
p {
  margin: 0;
}

.chat-shell {
  width: min(100% - 32px, 1040px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 64px;
  margin-bottom: 18px;
  padding: 6px 0;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 760;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.eyebrow,
.section-kicker {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

h1 {
  color: var(--text);
  font-size: 1.18rem;
  line-height: 1.12;
  font-weight: 720;
}

.language-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-width: 122px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ededeb;
}

.language-switch button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.language-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.conversation-workspace {
  display: grid;
  gap: 18px;
}

.composer-card,
.assistant-surface {
  width: min(100%, 820px);
  margin-inline: auto;
}

.composer-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.prompt-row,
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.prompt-row {
  margin-bottom: 12px;
}

label {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 1.24rem;
  line-height: 1.25;
  font-weight: 720;
}

.composer-input-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  transition: border-color 160ms ease, background 160ms ease;
}

.composer-input-wrap:focus-within {
  border-color: rgba(16, 163, 127, 0.64);
  background: var(--surface);
}

textarea {
  width: 100%;
  height: 96px;
  min-height: 96px;
  resize: vertical;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 16px;
  outline: none;
}

textarea::placeholder {
  color: var(--faint);
}

.privacy-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.control-grid {
  display: grid;
  gap: 13px;
  margin-top: 20px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

.chips,
.variant-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chips {
  margin-top: 8px;
}

.chips button,
.variant-buttons button,
.copy-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 5px 10px;
  font-size: 0.9rem;
  font-weight: 570;
}

.chips button:hover,
.variant-buttons button:hover,
.copy-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.chips button[aria-pressed="true"] {
  border-color: rgba(16, 163, 127, 0.42);
  background: var(--accent-soft);
  color: #08745b;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: white;
  padding: 0 16px;
  font-weight: 710;
}

.primary-button:hover:not(:disabled) {
  background: #000000;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.status {
  min-height: 24px;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.assistant-surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  overflow: hidden;
}

.empty-state {
  display: grid;
  min-height: 230px;
  padding: 30px;
  align-content: center;
  gap: 8px;
  background: transparent;
  color: var(--muted);
  border-style: dashed;
  box-shadow: none;
}

.empty-state h2 {
  max-width: 520px;
  color: var(--text);
  font-size: 1.34rem;
  line-height: 1.24;
  font-weight: 700;
}

.empty-state p:last-child {
  max-width: 560px;
}

.result-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 251, 248, 0.8);
}

h2 {
  margin-top: 3px;
  font-size: 1.2rem;
  line-height: 1.25;
}

.variant-buttons {
  justify-content: flex-end;
}

.variant-buttons button {
  background: transparent;
}

.result-content {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.assistant-message {
  padding: 15px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.assistant-message:last-child {
  border-bottom: 0;
}

.assistant-message.primary {
  background: #fbfffd;
}

.result-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.result-group-title {
  margin: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.result-group-body {
  display: grid;
}

.main-answer .assistant-message.primary {
  border-bottom: 0;
}

.variant-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.variant-grid .assistant-message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.analysis-stack {
  gap: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.card-head h3,
.assistant-message h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.25;
  font-weight: 720;
}

.copy-button {
  min-width: 54px;
  padding-inline: 10px;
  color: var(--muted);
}

.assistant-message p,
.assistant-message li {
  color: var(--text);
}

.assistant-message p {
  white-space: pre-wrap;
}

.assistant-message ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.meta-grid .assistant-message {
  border-bottom: 0;
}

.meta-grid .assistant-message:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.risk {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  margin: 0 15px 15px;
  border-radius: 8px;
  background: var(--surface-hover);
  padding: 3px 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.blocked {
  border-color: rgba(180, 35, 24, 0.22);
  background: #fff8f7;
}

.page-footer {
  width: min(100%, 820px);
  margin: 16px auto 0;
  padding: 0 2px;
}

.page-footer .privacy-note {
  font-size: 0.86rem;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .chat-shell {
    width: min(100% - 24px, 820px);
    padding-top: 14px;
  }

  .topbar {
    margin-bottom: 12px;
  }
}

@media (max-width: 640px) {
  .chat-shell {
    width: min(100% - 18px, 820px);
    padding-bottom: 28px;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 10px;
  }

  .language-switch {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .language-switch button {
    min-width: 48px;
    min-height: 34px;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }

  .language-switch button[aria-pressed="true"] {
    display: none;
  }

  .language-switch button[aria-pressed="false"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .composer-card {
    padding: 16px;
  }

  .prompt-row,
  .result-header {
    display: block;
  }

  .variant-buttons {
    margin-top: 10px;
  }

  .variant-buttons {
    justify-content: flex-start;
  }

  textarea {
    height: 110px;
    min-height: 110px;
  }

  .primary-button {
    width: 100%;
  }

  .empty-state,
  .assistant-message,
  .result-header {
    padding: 16px;
  }

  .risk {
    margin-left: 16px;
    margin-right: 16px;
  }

  .result-content {
    padding: 12px;
  }

  .variant-grid {
    grid-template-columns: 1fr;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .meta-grid .assistant-message:nth-child(odd) {
    border-right: 0;
  }

  .meta-grid .assistant-message {
    border-bottom: 1px solid var(--line);
  }

  .meta-grid .assistant-message:last-child {
    border-bottom: 0;
  }
}
