:root {
  --bg: #f6efe5;
  --bg-strong: #efe4d4;
  --surface: rgba(255, 250, 243, 0.78);
  --surface-strong: rgba(255, 248, 239, 0.95);
  --ink: #10202d;
  --ink-soft: #425466;
  --ink-faint: #697a8a;
  --gold: #b48647;
  --gold-soft: #d2b180;
  --navy: #112236;
  --navy-soft: #1c3550;
  --line: rgba(16, 32, 45, 0.1);
  --shadow: 0 28px 60px rgba(15, 32, 50, 0.14);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-body: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(180, 134, 71, 0.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(28, 53, 80, 0.12), transparent 32%),
    linear-gradient(135deg, #f8f2e9 0%, #f2e6d8 48%, #f9f4ec 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(16, 32, 45, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 32, 45, 0.025) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.95), transparent 92%);
  pointer-events: none;
}

.page-aura {
  position: fixed;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  pointer-events: none;
}

.page-aura-left {
  top: -8rem;
  left: -6rem;
  background: rgba(180, 134, 71, 0.32);
}

.page-aura-right {
  right: -10rem;
  bottom: -10rem;
  background: rgba(28, 53, 80, 0.26);
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.02fr 1.18fr;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

.card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: linear-gradient(180deg, rgba(255, 251, 246, 0.86), rgba(245, 238, 229, 0.82));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.22) 22%, transparent 44%);
  transform: translateX(-120%);
  animation: sheen 12s ease-in-out infinite;
  pointer-events: none;
}

.brand-panel,
.dialogue-panel {
  border-radius: var(--radius-xl);
}

.brand-panel {
  padding: 1.6rem;
  display: grid;
  gap: 1.4rem;
  align-content: start;
}

.brand-topline,
.dialogue-header,
.brand-lockup,
.section-heading,
.message-meta,
.form-actions,
.controls-grid,
.dashboard-grid,
.feature-grid,
.prompt-list,
.dialogue-actions,
.response-badges {
  display: flex;
  gap: 0.9rem;
}

.brand-topline,
.dialogue-header {
  justify-content: space-between;
  align-items: center;
}

.topline-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 32, 45, 0.08);
  background: rgba(255, 251, 244, 0.82);
}

.lang-button {
  min-width: 2.4rem;
  height: 2.2rem;
  padding: 0 0.75rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.lang-button:hover,
.lang-button:focus-visible {
  background: rgba(180, 134, 71, 0.1);
  color: var(--ink);
  outline: none;
}

.lang-button.active,
.lang-button[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--navy), #234467);
  color: #fff7eb;
  box-shadow: 0 10px 20px rgba(17, 34, 54, 0.16);
}

.brand-lockup {
  align-items: center;
}

.crest {
  flex: 0 0 112px;
  width: 112px;
  height: 112px;
  padding: 0.65rem;
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(17, 34, 54, 0.98), rgba(22, 39, 57, 0.94));
  box-shadow:
    inset 0 0 0 1px rgba(216, 181, 122, 0.35),
    0 22px 40px rgba(17, 34, 54, 0.22);
}

.crest svg {
  width: 100%;
  height: 100%;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.status-pill,
.mini-chip,
.confidence-chip,
.date-chip,
.prompt-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  font-size: 0.84rem;
}

.status-pill,
.mini-chip,
.confidence-chip,
.date-chip {
  padding: 0.45rem 0.85rem;
  border: 1px solid rgba(16, 32, 45, 0.08);
  background: rgba(255, 251, 244, 0.8);
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: linear-gradient(180deg, #31d49a, #0e8b65);
  box-shadow: 0 0 0 0 rgba(49, 212, 154, 0.35);
  animation: pulse 2s ease-out infinite;
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2.8rem, 5vw, 4.7rem);
}

h2 {
  font-size: clamp(1.55rem, 2vw, 2.2rem);
}

.brand-summary,
.feature-card p,
.metric-card p,
.message-card p,
.citation-card p,
.toggle-card small {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

.hero-illustration {
  border-radius: 28px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(17, 34, 54, 0.98), rgba(17, 34, 54, 0.88));
  box-shadow: inset 0 0 0 1px rgba(216, 181, 122, 0.2);
}

.hero-illustration svg {
  display: block;
  width: 100%;
  height: auto;
}

.feature-grid {
  flex-wrap: wrap;
}

.feature-card,
.metric-card,
.scope-card,
.toggle-card,
.citation-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(16px);
}

.feature-card {
  flex: 1 1 220px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  padding: 1rem 1.05rem;
}

.feature-card h2 {
  font-size: 1.06rem;
  margin-bottom: 0.3rem;
}

.feature-icon {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #fffaf1;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(180, 134, 71, 0.24);
}

.dashboard-grid {
  flex-wrap: wrap;
}

.metric-card {
  flex: 1 1 250px;
  padding: 1rem 1.1rem;
}

.metric-label {
  display: inline-block;
  margin-bottom: 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.metric-card strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 1.15rem;
  color: var(--ink);
  line-height: 1.35;
}

.prompt-bank {
  display: grid;
  gap: 0.85rem;
}

.section-heading {
  flex-direction: column;
  gap: 0.25rem;
}

.prompt-list {
  flex-wrap: wrap;
}

.prompt-chip {
  padding: 0.82rem 1.02rem;
  border: 1px solid rgba(17, 34, 54, 0.08);
  background: rgba(255, 249, 241, 0.9);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.prompt-chip:hover,
.prompt-chip:focus-visible {
  transform: translateY(-2px);
  background: rgba(255, 251, 245, 1);
  border-color: rgba(180, 134, 71, 0.4);
}

.dialogue-panel {
  padding: 1.35rem;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: calc(100vh - 3rem);
}

.dialogue-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.conversation {
  min-height: 0;
  display: grid;
  gap: 1rem;
  padding: 1.25rem 0 1rem;
  overflow: auto;
  scrollbar-width: thin;
}

.message {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.assistant-message {
  justify-content: flex-start;
}

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

.avatar {
  width: 2.85rem;
  height: 2.85rem;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--navy), var(--navy-soft));
  color: #fff8ec;
  box-shadow: 0 16px 30px rgba(17, 34, 54, 0.22);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.message-card {
  max-width: min(100%, 48rem);
  padding: 1rem 1.1rem;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: 0 18px 36px rgba(16, 32, 45, 0.08);
}

.user-message .message-card {
  background: linear-gradient(145deg, var(--navy), #1c3550);
  color: #f8f2e7;
}

.user-message .message-card p,
.user-message .message-meta,
.user-message .speaker,
.user-message .time-label {
  color: rgba(248, 242, 231, 0.88);
}

.message-meta {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.55rem;
}

.speaker {
  font-weight: 700;
}

.time-label {
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.response-card {
  width: min(100%, 54rem);
}

.response-summary {
  display: grid;
  gap: 0.95rem;
}

.response-summary p {
  margin: 0;
}

.response-badges {
  flex-wrap: wrap;
  margin-top: 1rem;
}

.confidence-chip[data-level="high"] {
  color: #0c7f57;
  border-color: rgba(12, 127, 87, 0.18);
  background: rgba(227, 250, 240, 0.96);
}

.confidence-chip[data-level="medium"] {
  color: #8f641f;
  border-color: rgba(180, 134, 71, 0.22);
  background: rgba(255, 244, 221, 0.96);
}

.confidence-chip[data-level="low"] {
  color: #9b3c36;
  border-color: rgba(155, 60, 54, 0.2);
  background: rgba(255, 235, 232, 0.95);
}

.citations-grid {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.citation-card {
  padding: 1rem 1.05rem;
}

.citation-card h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  font-family: var(--font-display);
}

.citation-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

.citation-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.7rem;
  color: var(--navy-soft);
  text-decoration: none;
  font-weight: 600;
}

.citation-link:hover {
  color: var(--gold);
}

.debug-panel {
  margin-top: 1rem;
  border-top: 1px solid rgba(16, 32, 45, 0.08);
  padding-top: 0.8rem;
}

.debug-panel summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-weight: 600;
}

.debug-text {
  white-space: pre-wrap;
  margin: 0.75rem 0 0;
  padding: 0.85rem;
  border-radius: 14px;
  background: rgba(17, 34, 54, 0.06);
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.55;
}

.composer-shell {
  border-top: 1px solid rgba(16, 32, 45, 0.08);
  padding-top: 1rem;
}

.query-form {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}

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

textarea,
input[type="date"],
select {
  width: 100%;
  border: 1px solid rgba(16, 32, 45, 0.1);
  border-radius: 18px;
  background: rgba(255, 251, 244, 0.92);
  color: var(--ink);
  padding: 0.95rem 1rem;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

textarea {
  resize: vertical;
  min-height: 8rem;
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: rgba(180, 134, 71, 0.55);
  box-shadow: 0 0 0 4px rgba(180, 134, 71, 0.12);
}

.controls-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 0.85rem;
}

.scope-card {
  display: grid;
  gap: 0.28rem;
  padding: 0.95rem 1rem;
  align-content: center;
}

.scope-card strong {
  display: block;
  font-size: 0.98rem;
}

.scope-card small {
  color: var(--ink-soft);
  line-height: 1.6;
}

.toggle-card {
  align-items: center;
  justify-content: space-between;
  padding: 0.95rem 1rem;
}

.toggle-card strong {
  display: block;
  margin-bottom: 0.2rem;
}

.toggle-card input {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--gold);
}

.form-actions {
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 3.4rem;
  padding: 0.9rem 1.25rem;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--navy), #234467);
  color: #fff7eb;
  box-shadow: 0 18px 34px rgba(17, 34, 54, 0.24);
}

.primary-button svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.secondary-button {
  background: rgba(255, 249, 241, 0.96);
  color: var(--ink);
  border: 1px solid rgba(16, 32, 45, 0.09);
}

.primary-button:hover,
.primary-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible {
  transform: translateY(-2px);
}

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

.loading-card {
  position: relative;
  overflow: hidden;
}

.loading-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(180, 134, 71, 0.18), transparent);
  animation: shimmer 1.6s linear infinite;
}

.reveal {
  animation: riseIn 800ms ease both;
}

.delay-1 {
  animation-delay: 120ms;
}

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

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(49, 212, 154, 0.4);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(49, 212, 154, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(49, 212, 154, 0);
  }
}

@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(120%);
  }
}

@keyframes sheen {
  0%,
  82%,
  100% {
    transform: translateX(-120%);
  }
  90% {
    transform: translateX(120%);
  }
}

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

  .dialogue-panel {
    min-height: auto;
  }
}

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

@media (max-width: 640px) {
  .shell {
    padding: 0.8rem;
    gap: 0.9rem;
  }

  .brand-panel,
  .dialogue-panel {
    border-radius: 24px;
    padding: 1rem;
  }

  .brand-lockup {
    flex-direction: column;
    align-items: flex-start;
  }

  .crest {
    width: 88px;
    height: 88px;
  }

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

  .dialogue-header,
  .brand-topline,
  .form-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .topline-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .conversation {
    padding-top: 0.8rem;
  }

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