:root {
  color-scheme: light;
  font-family: "Aptos", "Segoe UI", sans-serif;
  color: #1f1f1f;
  background: #f5f5f5;
  --bg: #f6f1e8;
  --ink: #1a1712;
  --muted: #6a6256;
  --card: rgba(255, 252, 247, 0.92);
  --line: rgba(82, 64, 38, 0.18);
  --accent: #0f6c5b;
  --accent-strong: #0a5648;
  --accent-soft: rgba(15, 108, 91, 0.12);
  --info-soft: rgba(12, 74, 123, 0.09);
  --warning-soft: rgba(181, 117, 24, 0.12);
  --error-soft: rgba(178, 55, 55, 0.14);
  --error: #8e1f1f;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(circle at top left, rgba(216, 198, 164, 0.45), transparent 36%),
    linear-gradient(180deg, #fbf7f1 0%, var(--bg) 100%);
}

.shell {
  box-sizing: border-box;
  display: flex;
  min-height: 100%;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.shell--message {
  justify-content: center;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.assistant-layout {
  display: grid;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle,
.hint {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.status {
  position: relative;
  border: 1px solid rgba(13, 69, 90, 0.14);
  border-radius: 16px;
  padding: 13px 14px;
  background: #eaf3ff;
  color: #0c4a7b;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 10px 28px rgba(25, 55, 85, 0.08);
}

.status[data-state="success"] {
  background: #e9f7ee;
  color: #185c37;
}

.status[data-state="error"] {
  background: var(--error-soft);
  color: var(--error);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: var(--card);
  box-shadow: 0 16px 38px rgba(41, 34, 25, 0.08);
}

.stack {
  display: grid;
  gap: 12px;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #514538;
}

.field {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.field--compact {
  min-width: 220px;
}

input,
select,
.composer {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font: inherit;
  line-height: 1.45;
}

.composer {
  min-height: 0;
  max-height: 220px;
  overflow-y: hidden;
  resize: none;
}

input:focus-visible,
select:focus-visible,
.composer:focus-visible,
.button:focus-visible {
  outline: 2px solid #1d9bf0;
  outline-offset: 2px;
}

.button {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
}

.button:hover,
.button:focus-visible {
  background: var(--accent-strong);
}

.button:active {
  transform: translateY(1px);
}

.button--secondary {
  background: #1f4d7a;
}

.button--secondary:hover,
.button--secondary:focus-visible {
  background: #163b5e;
}

.button--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.button:disabled {
  background: #aab6c3;
  cursor: not-allowed;
  transform: none;
}

.error {
  margin: 0;
  min-height: 18px;
  color: var(--error);
  font-size: 13px;
}

.info-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: help;
  margin-left: 6px;
  font-style: normal;
}

.tooltip-text {
  position: absolute;
  visibility: hidden;
  opacity: 0;
  bottom: 125%;
  right: -10px;
  width: 220px;
  background-color: var(--ink);
  color: #fff;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  z-index: 10;
  transition: opacity 0.2s;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: grid;
  gap: 4px;
  line-height: 1.4;
}

.tooltip-text strong {
  color: #fff;
  font-weight: 600;
}

.tooltip-text code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-family: "Aptos", "Segoe UI", sans-serif;
}

.info-tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

.inline-status {
  position: relative;
  display: grid;
  gap: 4px;
  border-radius: 16px;
  border: 1px solid rgba(82, 64, 38, 0.14);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  line-height: 1.5;
}

.inline-status[data-state="working"] {
  padding-left: 42px;
  background: rgba(243, 248, 240, 0.95);
  border-color: rgba(15, 108, 91, 0.18);
  color: #21463e;
}

.inline-status[data-state="working"]::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(15, 108, 91, 0.18);
  border-top-color: var(--accent);
  transform: translateY(-50%);
  animation: spin 900ms linear infinite;
}

.inline-status[data-state="success"] {
  background: #eef8f1;
  border-color: rgba(24, 92, 55, 0.18);
  color: #185c37;
}

.inline-status[data-state="info"] {
  background: #eef5fb;
  border-color: rgba(12, 74, 123, 0.16);
  color: #0c4a7b;
}

.inline-status[data-state="error"] {
  background: var(--error-soft);
  border-color: rgba(142, 31, 31, 0.18);
  color: var(--error);
}

.transcript-panel {
  display: grid;
  gap: 12px;
  min-height: 0;
  flex: 1;
}

.transcript-panel__header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.transcript-panel__header {
  display: grid;
  gap: 4px;
}

.transcript {
  list-style: none;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 4px 2px 2px;
  min-height: 220px;
  max-height: 44vh;
  overflow: auto;
}

.transcript-item {
  display: flex;
}

.transcript-item--user {
  justify-content: flex-end;
}

.transcript-item--assistant,
.transcript-item--muted {
  justify-content: flex-start;
}

.message {
  display: grid;
  gap: 6px;
  max-width: min(88%, 480px);
  padding: 13px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 30px rgba(41, 34, 25, 0.07);
}

.message--user {
  background: linear-gradient(180deg, rgba(18, 110, 93, 0.95) 0%, rgba(12, 93, 78, 0.96) 100%);
  color: #ffffff;
  border-color: rgba(12, 93, 78, 0.38);
}

.message--assistant[data-tone="success"] {
  background: rgba(240, 250, 244, 0.95);
}

.message--assistant[data-tone="info"] {
  background: rgba(239, 246, 253, 0.96);
}

.message--assistant[data-tone="warning"] {
  background: rgba(255, 248, 238, 0.96);
  border-color: rgba(181, 117, 24, 0.22);
}

.message--assistant[data-tone="error"] {
  background: rgba(255, 243, 243, 0.97);
  border-color: rgba(142, 31, 31, 0.22);
}

.message--muted {
  color: var(--muted);
  border-style: dashed;
  box-shadow: none;
}

.message__label,
.message__meta,
.message__body,
.message__quote-label,
.message__quote-body,
.message__action {
  margin: 0;
}

.message__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.message--user .message__label,
.message--user .message__meta {
  color: rgba(255, 255, 255, 0.82);
}

.message__body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}

.message--user .message__body {
  color: #ffffff;
}

.message__meta {
  font-size: 12px;
  color: var(--muted);
}

.message__quote {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border-radius: 14px;
  border: 1px solid rgba(82, 64, 38, 0.1);
  background: rgba(255, 255, 255, 0.55);
}

.message__quote-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.message__quote-body {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
}

.message__action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(12, 74, 123, 0.09);
  color: #0c4a7b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.message__action::after {
  content: "\2193";
  font-size: 12px;
}

.message--user .message__quote {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.11);
}

.message--user .message__quote-label,
.message--user .message__quote-body {
  color: rgba(255, 255, 255, 0.92);
}

.message--actionable {
  cursor: pointer;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

.message--actionable:hover {
  transform: translateY(-1px);
  border-color: rgba(12, 74, 123, 0.26);
  box-shadow: 0 16px 32px rgba(25, 55, 85, 0.12);
}

.message--selected {
  border-color: rgba(12, 74, 123, 0.32);
  box-shadow:
    0 0 0 3px rgba(12, 74, 123, 0.08),
    0 16px 32px rgba(25, 55, 85, 0.12);
}

.composer-panel {
  position: sticky;
  bottom: 0;
}

.composer-context {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(12, 74, 123, 0.16);
  border-radius: 14px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(239, 246, 253, 0.96) 0%, rgba(235, 243, 252, 0.96) 100%);
}

.composer-context__title {
  margin: 0 0 1px;
  font-size: 12px;
  font-weight: 700;
  color: #0c4a7b;
}

.composer-context .hint {
  font-size: 13px;
}

[hidden] {
  display: none !important;
}

@keyframes spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 14px;
  }

  .panel {
    padding: 14px;
  }

  .transcript {
    max-height: 40vh;
  }

  .composer-context,
  .toolbar,
  .hero {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .message {
    max-width: 100%;
  }
}

.drawer-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 100;
  opacity: 1;
  transition: opacity 200ms ease;
}

.drawer-backdrop[hidden] {
  display: block !important;
  opacity: 0;
  pointer-events: none;
}

.drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
  z-index: 101;
  padding: 16px;
  display: grid;
  gap: 16px;
  transform: translateY(0);
  transition: transform 250ms cubic-bezier(0.25, 1, 0.5, 1);
  max-height: 80%;
  overflow-y: auto;
}

.drawer[hidden] {
  display: grid !important;
  transform: translateY(100%);
}

.drawer__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.icon-button {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 150ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: rgba(0, 0, 0, 0.06);
}

.icon-button svg {
  display: block;
}
