@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --bg-top: #f7efe4;
  --bg-bottom: #e8d9c6;
  --bg-glow-1: rgba(82, 188, 187, 0.18);
  --bg-glow-2: rgba(231, 169, 97, 0.18);
  --grid: rgba(115, 88, 63, 0.06);
  --panel: rgba(255, 249, 241, 0.84);
  --panel-strong: rgba(255, 250, 244, 0.94);
  --panel-soft: rgba(248, 238, 225, 0.72);
  --line: rgba(121, 92, 61, 0.16);
  --text: #2e241a;
  --muted: #6f5a45;
  --accent: #5bc3bc;
  --accent-strong: #2f8f89;
  --accent-wash: rgba(91, 195, 188, 0.16);
  --warning: #f0b766;
  --danger: #d97d65;
  --shadow: 0 30px 80px rgba(77, 56, 35, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --mono: "IBM Plex Mono", monospace;
  --sans: "Space Grotesk", sans-serif;
}

html[data-theme="dark"] {
  --bg-top: #061019;
  --bg-bottom: #0d2030;
  --bg-glow-1: rgba(91, 195, 188, 0.16);
  --bg-glow-2: rgba(103, 149, 255, 0.16);
  --grid: rgba(255, 255, 255, 0.025);
  --panel: rgba(8, 20, 31, 0.84);
  --panel-strong: rgba(6, 15, 24, 0.94);
  --panel-soft: rgba(9, 20, 31, 0.6);
  --line: rgba(157, 197, 228, 0.18);
  --text: #f6f7f2;
  --muted: #a1b3c5;
  --accent: #7df0c7;
  --accent-strong: #45b493;
  --accent-wash: rgba(125, 240, 199, 0.16);
  --warning: #ffbb70;
  --danger: #ff8f80;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--bg-glow-1), transparent 32%),
    radial-gradient(circle at bottom right, var(--bg-glow-2), transparent 36%),
    linear-gradient(160deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  font-family: var(--sans);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: radial-gradient(circle at center, black 36%, transparent 88%);
}

body {
  position: relative;
}

h1,
h2,
p {
  margin: 0;
}

a {
  color: inherit;
}

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

.page-chrome,
.landing-shell,
.chat-shell,
.admin-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
}

.page-chrome {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  padding-top: 22px;
}

.landing-shell,
.chat-shell,
.admin-shell {
  padding: 24px 0 48px;
}

.landing-shell {
  min-height: calc(100vh - 112px);
  display: grid;
  place-items: center;
}

.brand-badge,
.preference-card,
.hero-card,
.panel-card,
.sidebar-card,
.thread-card,
.login-card,
.request-panel,
.composer,
.status-banner {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 22px;
  text-decoration: none;
}

.brand-logo,
.hero-logo {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  object-fit: contain;
  padding: 4px;
  background: color-mix(in srgb, var(--panel-strong) 94%, transparent);
  border: 1px solid var(--line);
}

.hero-logo {
  width: 84px;
  height: 84px;
  border-radius: 24px;
}

.hero-logo.compact {
  width: 64px;
  height: 64px;
}

.brand-copy,
.hero-brand-copy {
  display: grid;
  gap: 4px;
}

.brand-copy strong,
.hero-brand-copy strong {
  font-size: 1.02rem;
}

.preference-card {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: 22px;
}

.preference-group {
  display: grid;
  gap: 8px;
}

.preference-group span {
  font: 500 0.72rem/1.2 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.toggle-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 9px 14px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.icon-chip {
  width: 48px;
  min-width: 48px;
  padding: 9px 0;
  display: inline-grid;
  place-items: center;
}

.icon-chip svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toggle-chip.active {
  background: var(--accent-wash);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--text);
}

.hero-card {
  width: min(760px, 100%);
  border-radius: var(--radius-xl);
  padding: 36px;
  display: grid;
  gap: 22px;
}

.hero-brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.hero-brand.compact {
  gap: 14px;
}

.hero-spotlight {
  display: grid;
  place-items: center;
  padding: 8px 0 0;
}

.hero-logo-display {
  width: min(100%, 640px);
  max-height: 290px;
  object-fit: contain;
  filter: drop-shadow(0 18px 30px rgba(69, 52, 32, 0.08));
}

.hero-copy-stack {
  display: grid;
  gap: 14px;
}

.hero-kicker {
  font: 600 0.96rem/1.4 var(--sans);
  color: var(--accent-strong);
}

.eyebrow {
  font: 500 0.82rem/1.4 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

h1 {
  font-size: clamp(2.35rem, 4.2vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
  max-width: 13ch;
}

.hero-copy,
.muted-copy,
.feedback,
.status-banner {
  color: var(--muted);
}

.stack-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.92rem;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel-strong) 92%, transparent);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.primary-button,
.secondary-button,
.tab-button,
.icon-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.tab-button:hover,
.icon-button:hover,
.toggle-chip:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff 30%));
  color: #08231d;
  font-weight: 700;
  padding: 14px 20px;
}

.benefit-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.benefit-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 500;
}

.benefit-list li::before {
  content: "✓";
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent-strong);
  font-weight: 700;
  flex: 0 0 auto;
}

.secondary-button,
.tab-button,
.icon-button,
.ghost-link {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 18px;
  text-decoration: none;
}

.info-strip {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.brand-logo.is-fallback,
.hero-logo.is-fallback,
.hero-logo-display.is-fallback {
  object-fit: contain;
  padding: 0;
}

.info-strip div {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.chat-header,
.admin-header,
.panel-head,
.request-toolbar,
.admin-tabs {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.chat-shell,
.admin-shell {
  display: grid;
  gap: 18px;
}

.status-banner,
.request-panel,
.message-list,
.composer,
.sidebar-card,
.thread-card,
.panel-card {
  border-radius: var(--radius-lg);
}

.status-banner {
  min-height: 28px;
  padding: 12px 16px;
}

.request-toolbar {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.admin-header-side {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  justify-content: flex-end;
}

.admin-app-field {
  min-width: 220px;
}

.request-panel,
.sidebar-card,
.thread-card,
.panel-card {
  padding: 22px;
}

.hidden {
  display: none !important;
}

.install-button {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  color: #08231d;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff 30%));
  box-shadow: var(--shadow);
}

.message-list {
  display: grid;
  gap: 14px;
  min-height: 42vh;
  max-height: 54vh;
  overflow-y: auto;
  padding: 8px 4px;
}

.message-item {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.message-history-tools {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.message-item.me {
  justify-items: end;
}

.bubble {
  max-width: min(78ch, 100%);
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.message-item.deleted .bubble {
  background: color-mix(in srgb, var(--panel-soft) 82%, var(--paper));
  border-color: color-mix(in srgb, var(--line) 78%, transparent);
}

.message-item.me .bubble {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.message-item.system .bubble {
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  border-color: color-mix(in srgb, var(--warning) 40%, transparent);
}

.message-item.nudge .bubble {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 36%, transparent);
}

.meta {
  font: 500 0.75rem/1.4 var(--mono);
  color: var(--muted);
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.message-delete-button {
  padding: 6px 10px;
  font: 600 0.72rem/1 var(--mono);
}

.deleted-message-copy {
  font-style: italic;
  color: var(--muted);
}

.chat-audio {
  display: block;
  width: min(100%, 280px);
  margin-bottom: 10px;
}

.composer {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--panel-strong);
}

.composer-main {
  display: grid;
  gap: 12px;
}

.composer-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.composer textarea {
  min-height: 60px;
  resize: vertical;
}

.hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-button {
  display: inline-flex;
  align-items: center;
}

.chat-image {
  display: block;
  max-width: min(100%, 280px);
  border-radius: 14px;
  margin-bottom: 10px;
  cursor: zoom-in;
}

.image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.image-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.68);
}

.image-preview-card {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  width: min(92vw, 860px);
  max-height: 90vh;
  margin: 0;
  padding: 18px;
  border-radius: 24px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.image-preview-close {
  justify-self: end;
}

.image-preview-image {
  display: block;
  width: 100%;
  max-height: calc(90vh - 120px);
  object-fit: contain;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.08);
}

.image-preview-caption {
  color: var(--muted);
  word-break: break-word;
}

.admin-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.client-list,
.request-list {
  display: grid;
  gap: 12px;
  max-height: 70vh;
  overflow-y: auto;
}

.client-card,
.request-card {
  width: 100%;
  text-align: left;
  padding: 16px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.client-card.active {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel-soft));
}

.client-card strong,
.request-card strong {
  display: block;
  margin-bottom: 4px;
}

.small-badge,
.status-pill,
.request-status,
.message-badge {
  font: 500 0.76rem/1.3 var(--mono);
}

.small-badge,
.request-status,
.message-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.message-badge.has-unread {
  color: #08231d;
  background: var(--accent);
  border-color: transparent;
}

.status-pill {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.request-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.request-remark {
  margin-top: 12px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-button.active {
  background: var(--accent-wash);
  border-color: color-mix(in srgb, var(--accent) 34%, transparent);
}

.login-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(31, 21, 13, 0.24);
  z-index: 10;
}

html[data-theme="dark"] .login-overlay {
  background: rgba(3, 8, 13, 0.5);
}

.login-card {
  width: min(460px, calc(100vw - 32px));
  padding: 28px;
  border-radius: var(--radius-xl);
  display: grid;
  gap: 18px;
}

.import-result {
  margin-top: 20px;
  display: grid;
  gap: 10px;
}

.request-status.pending {
  color: #3d2906;
  background: color-mix(in srgb, var(--warning) 72%, white 28%);
  border-color: transparent;
}

.request-status.approved {
  color: #08231d;
  background: var(--accent);
  border-color: transparent;
}

.request-status.rejected {
  color: #3a120b;
  background: color-mix(in srgb, var(--danger) 70%, white 30%);
  border-color: transparent;
}

code {
  font-family: var(--mono);
}

@media (max-width: 900px) {
  .page-chrome {
    flex-direction: column;
  }

  .preference-card {
    width: 100%;
  }

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

  .info-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-chrome,
  .landing-shell,
  .chat-shell,
  .admin-shell {
    width: min(100vw - 20px, 1120px);
  }

  .page-chrome {
    padding-top: 16px;
    gap: 10px;
  }

  .landing-shell,
  .chat-shell,
  .admin-shell {
    padding: 16px 0 36px;
  }

  .brand-badge,
  .preference-card,
  .hero-card,
  .request-panel,
  .sidebar-card,
  .thread-card,
  .panel-card {
    padding: 18px;
  }

  .brand-badge {
    width: 100%;
    padding: 10px 12px;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .brand-copy strong {
    font-size: 0.94rem;
  }

  .preference-card {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .preference-group {
    min-width: 0;
  }

  .toggle-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toggle-chip {
    width: 100%;
    padding: 10px 0;
    text-align: center;
  }

  .icon-chip {
    width: 100%;
  }

  .hero-brand,
  .chat-header,
  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-header-side {
    width: 100%;
  }

  h1 {
    max-width: 100%;
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .hero-logo-display {
    max-height: 220px;
  }

  .chat-header h1,
  .admin-header h1 {
    font-size: clamp(1.95rem, 9vw, 2.85rem);
  }

  .ghost-link {
    padding: 10px 14px;
  }

  .composer-actions,
  .request-toolbar {
    justify-content: flex-start;
  }

  .request-toolbar .secondary-button {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }

  .composer-actions > .secondary-button,
  .composer-actions > .file-button {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
    text-align: center;
  }

  .composer-actions > .primary-button {
    flex: 1 1 100%;
  }

  .message-list {
    min-height: 34vh;
    max-height: none;
  }

  .admin-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-tabs .tab-button {
    width: 100%;
    text-align: center;
  }
}
