:root {
  --bg: #f6efe5;
  --panel: rgba(255, 250, 243, 0.78);
  --panel-strong: #fff7ec;
  --text: #1f1b17;
  --muted: #6e6257;
  --line: rgba(61, 43, 21, 0.12);
  --accent: #c3572a;
  --accent-strong: #9f4018;
  --accent-soft: #f7d7c7;
  --danger: #8f2020;
  --shadow: 0 24px 60px rgba(60, 37, 18, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), transparent 30%),
    radial-gradient(circle at 85% 10%, rgba(227, 160, 92, 0.22), transparent 28%),
    linear-gradient(135deg, #f4ead9, #f5f0e8 45%, #f1e0d1);
  color: var(--text);
  font-family: "Aptos", "Trebuchet MS", "Segoe UI", sans-serif;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(0);
  opacity: 0.6;
  pointer-events: none;
}

body::before {
  width: 320px;
  height: 320px;
  left: -80px;
  top: 20%;
  background: rgba(255, 205, 172, 0.45);
}

body::after {
  width: 240px;
  height: 240px;
  right: 5%;
  bottom: 18%;
  background: rgba(212, 104, 57, 0.12);
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

code {
  padding: 0.12rem 0.38rem;
  border-radius: 0.5rem;
  background: rgba(61, 43, 21, 0.08);
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.92em;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(290px, 340px) 1fr;
  gap: 24px;
  min-height: 100vh;
  padding: 24px 24px 120px;
}

.sidebar,
.main-layout {
  display: grid;
  gap: 18px;
}

.main-layout {
  align-content: start;
}

.panel,
.brand-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.brand-card,
.panel {
  padding: 22px;
}

.brand-card h1,
.hero h2,
.chat-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.03em;
}

.brand-card h1 {
  font-size: clamp(2.6rem, 5vw, 3.5rem);
}

.hero h2 {
  font-size: clamp(2rem, 4vw, 3rem);
  max-width: 12ch;
}

.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-copy,
.hero-copy,
.helper-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.status-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  width: fit-content;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c9b59b;
}

.status-dot.live {
  background: #2f9b59;
  box-shadow: 0 0 0 8px rgba(47, 155, 89, 0.12);
}

.status-dot.warn {
  background: #c48317;
  box-shadow: 0 0 0 8px rgba(196, 131, 23, 0.12);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 8px rgba(143, 32, 32, 0.12);
}

.panel-heading,
.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.button-stack {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

button {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  padding: 13px 16px;
  transition:
    transform 150ms ease,
    opacity 150ms ease,
    background-color 150ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #dd7744);
  color: #fffdf9;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
}

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

.danger-button {
  background: rgba(143, 32, 32, 0.1);
  color: var(--danger);
  border: 1px solid rgba(143, 32, 32, 0.18);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--muted);
}

.toggle-row input {
  inline-size: 18px;
  block-size: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(290px, 360px);
  gap: 18px;
}

.chat-panel,
.library-panel {
  min-height: 70vh;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.messages {
  display: grid;
  gap: 14px;
  align-content: start;
  overflow: auto;
  padding-right: 6px;
}

.message {
  max-width: min(82%, 760px);
  padding: 14px 16px;
  border-radius: 22px;
  line-height: 1.55;
  animation: messageIn 220ms ease;
  white-space: pre-wrap;
}

.message.user {
  margin-left: auto;
  background: linear-gradient(135deg, var(--accent), #d87b4e);
  color: #fffdf9;
  border-bottom-right-radius: 6px;
}

.message.assistant {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(70, 45, 18, 0.08);
  border-bottom-left-radius: 6px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  padding: 26px;
  border: 1px dashed rgba(70, 45, 18, 0.18);
  border-radius: 22px;
  color: var(--muted);
  text-align: center;
}

.composer {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.composer textarea,
.settings-form input,
.settings-form textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(70, 45, 18, 0.12);
  background: rgba(255, 255, 255, 0.84);
  resize: vertical;
  color: var(--text);
}

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

.chat-list {
  display: grid;
  gap: 10px;
  max-height: calc(70vh - 60px);
  overflow: auto;
}

.chat-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 150ms ease;
}

.chat-card:hover,
.chat-card.active,
.chat-card:focus-visible {
  border-color: rgba(195, 87, 42, 0.42);
  outline: none;
}

.chat-card h3 {
  margin: 0;
  font-size: 1rem;
}

.chat-card p,
.chat-card small {
  margin: 0;
  color: var(--muted);
}

.chat-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.small-danger {
  background: transparent;
  color: var(--danger);
  padding: 0;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.settings-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.origin-card {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(70, 45, 18, 0.08);
}

.ad-banner {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid rgba(70, 45, 18, 0.08);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(39, 31, 23, 0.94), rgba(98, 53, 28, 0.92));
  color: #fffaf2;
  text-decoration: none;
  box-shadow: 0 20px 45px rgba(24, 14, 6, 0.24);
}

.ad-label {
  flex-shrink: 0;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ad-copy {
  display: grid;
  gap: 4px;
}

.ad-copy span {
  color: rgba(255, 245, 231, 0.78);
}

.ad-cta {
  margin-left: auto;
  flex-shrink: 0;
  padding: 11px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(31, 27, 23, 0.94);
  color: #fffaf2;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.2);
}

[hidden] {
  display: none !important;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .page-shell,
  .workspace,
  .hero {
    grid-template-columns: 1fr;
  }

  .chat-panel,
  .library-panel {
    min-height: auto;
  }

  .chat-list {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 16px 16px 120px;
  }

  .brand-card,
  .panel {
    padding: 18px;
    border-radius: 20px;
  }

  .composer-actions,
  .chat-header,
  .ad-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .message {
    max-width: 100%;
  }

  .ad-cta {
    margin-left: 0;
    text-align: center;
  }
}
