:root {
  --black: #11110f;
  --charcoal: #24241f;
  --cream: #f6f0e5;
  --white: #ffffff;
  --gold: #c9a24f;
  --gold-dark: #9d7a2e;
  --green: #173e31;
  --green-light: #285f4b;
  --muted: #6f706b;
  --border: #ded8cb;
  --danger: #a23838;
  --shadow: 0 18px 60px rgba(25, 24, 20, 0.12);
  font-family: "Inter", sans-serif;
  color: var(--black);
  background: var(--cream);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(201, 162, 79, 0.12), transparent 32rem),
    var(--cream);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(201, 162, 79, 0.55);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
}

.sidebar {
  background: var(--black);
  color: var(--white);
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 25px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 50px;
  height: 50px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--gold), #ead38c);
  color: var(--black);
  font-weight: 800;
  letter-spacing: 0.05em;
}

.brand h1 {
  font-family: "Playfair Display", serif;
  font-size: 1.15rem;
  margin: 0;
}

.brand p {
  margin: 3px 0 0;
  color: #c9c4b8;
  font-size: 0.78rem;
}

.sidebar-section {
  display: grid;
  gap: 10px;
}

.sidebar-section h2 {
  color: #d6cfbf;
  font-size: 0.75rem;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.mode-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-button {
  border: 1px solid #46463e;
  border-radius: 999px;
  background: #20201d;
  color: #eae6db;
  padding: 8px 11px;
  font-size: 0.78rem;
}

.mode-button.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--black);
  font-weight: 700;
}

.sidebar select {
  width: 100%;
  background: #22221e;
  border: 1px solid #4a4942;
  border-radius: 10px;
  color: var(--white);
  padding: 11px;
}

.small-copy {
  color: #9e9b92;
  font-size: 0.77rem;
  line-height: 1.5;
  margin: 0;
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 7px;
}

.primary-button,
.secondary-button,
.send-button {
  border-radius: 12px;
  border: 0;
  font-weight: 700;
  min-height: 44px;
  padding: 11px 17px;
}

.primary-button,
.send-button {
  background: linear-gradient(145deg, var(--gold), #dfc173);
  color: var(--black);
  box-shadow: 0 8px 24px rgba(201, 162, 79, 0.18);
}

.primary-button:hover,
.send-button:hover {
  filter: brightness(1.04);
}

.primary-button:disabled,
.send-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.7);
  opacity: 0.55;
}

.secondary-button {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
}

.sidebar .secondary-button {
  color: #e9e5da;
  border-color: #4a4942;
}

.full-width {
  width: 100%;
}

.text-button {
  background: transparent;
  border: 0;
  color: #beb9ad;
  text-align: left;
  padding: 7px 0;
  font-size: 0.82rem;
}

.text-button:hover {
  color: var(--white);
}

.danger-text {
  color: #e5a9a9;
}

.main-panel {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.topbar {
  min-height: 70px;
  padding: 13px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(17, 17, 15, 0.08);
  background: rgba(246, 240, 229, 0.88);
  backdrop-filter: blur(14px);
  z-index: 5;
}

.topbar > div:first-of-type {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.privacy-label {
  color: var(--green-light);
  font-size: 0.75rem;
  font-weight: 700;
}

.status-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

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

.status-dot.ready {
  background: #3b8b69;
  box-shadow: 0 0 0 5px rgba(59, 139, 105, 0.12);
}

.status-dot.busy {
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(201, 162, 79, 0.12);
}

.loading-panel {
  margin: 22px 28px 0;
  padding: 22px 24px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--green), #204f3f);
  color: var(--white);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
}

.loading-panel.loaded {
  display: none;
}

.loading-panel h2 {
  font-family: "Playfair Display", serif;
  font-size: clamp(1.4rem, 2vw, 2rem);
  margin: 3px 0 8px;
}

.loading-panel p {
  margin: 0;
  color: #e8eee9;
  max-width: 760px;
  line-height: 1.55;
}

.eyebrow {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--gold-dark);
  margin: 0 0 5px;
}

.loading-panel .eyebrow {
  color: #dfc173;
}

.progress-wrap {
  grid-column: 1 / -1;
}

.progress-bar {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  overflow: hidden;
  height: 9px;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #f0d991);
  transition: width 0.25s ease;
}

#progressText {
  font-size: 0.8rem;
  margin-top: 8px;
}

.compatibility-note {
  grid-column: 1 / -1;
  font-size: 0.82rem;
}

.hidden {
  display: none !important;
}

.chat-area {
  overflow-y: auto;
  padding: 26px 28px 34px;
  scroll-behavior: smooth;
}

.welcome-card {
  max-width: 850px;
  margin: 0 auto 26px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: clamp(22px, 4vw, 42px);
  box-shadow: var(--shadow);
}

.welcome-card h2 {
  font-family: "Playfair Display", serif;
  font-size: clamp(1.8rem, 4vw, 3.35rem);
  line-height: 1.08;
  margin: 6px 0 14px;
}

.welcome-card > p:not(.eyebrow) {
  color: #555650;
  line-height: 1.7;
  max-width: 680px;
}

.welcome-tagline {
  display: block;
  margin-top: 14px;
  color: var(--green);
  font-family: "Playfair Display", serif;
}

.chat-announcement {
  max-width: 900px;
  margin: 0 auto 18px;
  padding: 13px 16px;
  border: 1px solid rgba(201, 162, 79, 0.55);
  border-radius: 13px;
  background: #fff8df;
  color: #5b481b;
  line-height: 1.5;
}

.suggestion-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.suggestion-grid button {
  min-height: 66px;
  text-align: left;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fbf9f4;
  color: var(--charcoal);
  padding: 13px;
  line-height: 1.4;
}

.suggestion-grid button:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}

#messages {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.message-row {
  display: flex;
  gap: 11px;
  align-items: flex-start;
}

.message-row.user {
  justify-content: flex-end;
}

.avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.74rem;
}

.assistant .avatar {
  color: var(--black);
  background: linear-gradient(145deg, var(--gold), #e4cb84);
}

.user .avatar {
  order: 2;
  color: var(--white);
  background: var(--green);
}

.bubble {
  max-width: min(76ch, 83%);
  border-radius: 18px;
  padding: 14px 17px;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 25px rgba(20, 20, 17, 0.07);
}

.assistant .bubble {
  background: var(--white);
  border: 1px solid var(--border);
  border-top-left-radius: 5px;
}

.user .bubble {
  background: var(--green);
  color: var(--white);
  border-top-right-radius: 5px;
}

.message-meta {
  color: var(--muted);
  font-size: 0.68rem;
  margin-top: 5px;
}

.user .message-meta {
  text-align: right;
}

.typing::after {
  content: "▋";
  animation: blink 0.8s infinite;
  margin-left: 2px;
}

@keyframes blink {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

.composer {
  padding: 14px 28px 17px;
  background: rgba(246, 240, 229, 0.96);
  border-top: 1px solid rgba(17, 17, 15, 0.08);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.composer textarea {
  width: 100%;
  max-height: 180px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--white);
  padding: 13px 15px;
  line-height: 1.45;
  color: var(--black);
}

.composer-note {
  grid-column: 1 / -1;
  margin: 0;
  text-align: center;
  font-size: 0.68rem;
  color: var(--muted);
}

.privacy-note {
  margin-top: -4px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font-size: 1.4rem;
}

.mobile-only {
  display: none;
}

dialog {
  border: 0;
  border-radius: 22px;
  padding: 0;
  width: min(560px, calc(100vw - 28px));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.3);
}

dialog::backdrop {
  background: rgba(10, 10, 9, 0.68);
  backdrop-filter: blur(4px);
}

.dialog-card {
  padding: 25px;
  display: grid;
  gap: 17px;
  background: var(--cream);
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.dialog-heading h2 {
  font-family: "Playfair Display", serif;
  font-size: 1.8rem;
  margin: 4px 0 0;
}

.dialog-card label:not(.checkbox-row) {
  display: grid;
  gap: 7px;
  font-weight: 700;
  font-size: 0.85rem;
}

.dialog-card input,
.dialog-card textarea,
.dialog-card select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--white);
  padding: 11px 12px;
  color: var(--black);
}

.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.86rem;
  line-height: 1.45;
}

.checkbox-row input {
  margin-top: 3px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.dialog-actions .secondary-button {
  color: var(--black);
  border-color: var(--border);
}

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

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 90vw);
    z-index: 20;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 25px 0 80px rgba(0, 0, 0, 0.3);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-panel {
    height: 100dvh;
  }

  .mobile-only {
    display: grid;
    place-items: center;
  }

  .topbar {
    padding-inline: 14px;
  }

  .topbar > div:first-of-type {
    flex: 1;
    margin-left: 7px;
  }

  .status-wrap {
    max-width: 100px;
  }

  .loading-panel {
    margin: 14px 14px 0;
    grid-template-columns: 1fr;
  }

  .loading-panel .primary-button {
    width: 100%;
  }

  .chat-area {
    padding-inline: 14px;
  }

  .composer {
    padding-inline: 14px;
  }
}

@media (max-width: 620px) {
  .suggestion-grid {
    grid-template-columns: 1fr;
  }

  .welcome-card {
    padding: 22px 18px;
  }

  .bubble {
    max-width: 88%;
  }

  .privacy-label {
    display: none;
  }

  .status-wrap {
    font-size: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: 0.001ms !important;
  }
}
