:root {
  --bg: #FFFFFF;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: #ffffff;
  --ink: #1a1d20;
  --muted: #6a5648;
  --accent: #4C2911;
  --accent-dark: #2f1708;
  --border: rgba(76, 41, 17, 0.14);
  --shadow: 0 24px 60px rgba(76, 41, 17, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(246, 183, 56, 0.22), transparent 28%),
    radial-gradient(circle at bottom right, rgba(76, 41, 17, 0.08), transparent 24%),
    linear-gradient(135deg, #FFFFFF, #fffaf1 52%, #ffffff);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

button,
a,
.ghost-link,
.text-link {
  font-family: "SFMono-Regular", Menlo, monospace;
}

input,
select,
textarea {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
}

input,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.72);
}

select {
  padding-right: 40px;
}

button,
.ghost-link {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 1rem;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff7f0;
  cursor: pointer;
  text-decoration: none;
  transition: transform 140ms ease, background 140ms ease;
}

button:hover,
.ghost-link:hover {
  transform: translateY(-1px);
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.75;
  cursor: wait;
}

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

.text-link {
  color: var(--accent-dark);
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  color: var(--accent-dark);
  margin-bottom: 12px;
}

.lede,
.muted {
  color: var(--muted);
}

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

.stack-tight {
  display: grid;
  gap: 6px;
}

label {
  display: grid;
  gap: 8px;
}

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

.grid-phone {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
}

.phone-code-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  padding: 0 14px;
}

.phone-code-shell input {
  border: 0;
  background: transparent;
  padding-left: 0;
}

.hidden {
  display: none;
}

.auth-shell {
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-card,
.sidebar,
.main-panel,
.dashboard-card,
.hero-panel,
.topbar {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(1100px, 100%);
  padding: 28px;
  border-radius: 28px;
}

.auth-card-wide {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 28px;
}

.auth-copy,
.auth-form-panel {
  border-radius: 24px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.32);
}

.auth-copy {
  display: grid;
  align-content: start;
  gap: 16px;
}

.auth-copy h1,
.auth-copy .lede {
  margin: 0;
}

.auth-logo-shell {
  display: grid;
  place-items: center;
  height: 180px;
  margin-top: 8px;
}

.auth-logo {
  max-width: 100%;
  max-height: 132px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.auth-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  color: var(--muted);
}

.error-banner,
.success-banner {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.error-banner {
  background: rgba(180, 74, 31, 0.12);
  border: 1px solid rgba(180, 74, 31, 0.2);
}

.success-banner {
  background: rgba(54, 119, 88, 0.12);
  border: 1px solid rgba(54, 119, 88, 0.2);
}

.dashboard-body {
  padding-top: 74px;
}

.chat-page-body {
  height: 100vh;
  overflow: hidden;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
}

.topbar-brand,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.user-badge {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
}

.workspace-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  padding: 0;
  height: calc(100vh - 74px);
}

.admin-shell {
  display: grid;
  gap: 24px;
  padding: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 24px;
  border-radius: 0;
  align-self: stretch;
  position: relative;
  top: 0;
  margin: 0;
  border-left: 0;
  border-bottom: 0;
  min-height: calc(100vh - 74px);
  overflow: hidden;
}

.sidebar section {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.panel-title {
  margin-bottom: 12px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.thread-list,
.messages {
  display: grid;
  gap: 12px;
}

.thread-list {
  margin-top: 0;
  align-content: start;
  overflow: auto;
  padding-right: 4px;
}

.thread-action-button {
  width: 100%;
  margin-bottom: 12px;
}

.thread-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.thread-button {
  width: 100%;
  text-align: left;
  background: var(--panel-strong);
  color: var(--ink);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  padding: 10px 12px;
}

.thread-hide-button {
  min-width: 36px;
  padding: 10px 12px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
  font-size: 0.78rem;
}

.thread-hide-button:hover {
  background: rgba(180, 74, 31, 0.1);
}

.thread-button.active {
  background: rgba(180, 74, 31, 0.16);
  border-color: rgba(180, 74, 31, 0.35);
}

.main-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  min-height: calc(100vh - 74px);
  height: calc(100vh - 74px);
  padding: 24px;
  border-radius: 0;
  margin: 0;
  border-right: 0;
  border-bottom: 0;
  overflow: hidden;
}

.hero-panel,
.dashboard-card {
  border-radius: 24px;
  padding: 20px;
}

.hero-header-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(260px, 420px);
  align-items: flex-start;
  gap: 24px;
}

.hero-copy {
  min-width: 0;
}

.hero-copy h2,
.hero-copy p {
  margin: 0;
}

.hero-copy p {
  margin-top: 8px;
}

.hero-documents-column,
.hero-filter-row {
  display: grid;
  align-content: start;
  gap: 8px;
}

.hero-documents-column {
  justify-items: center;
}

.hero-filter-field {
  display: grid;
  gap: 8px;
  width: 100%;
}

.hero-filter-field span,
.hero-control-label {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.hero-documents-button:hover,
.hero-documents-button[aria-expanded="true"] {
  color: #fff7f0;
  background: var(--accent);
}

.documents-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px 20px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  /*max-height: 220px;*/
  overflow: auto;
  font-size: 0.88rem;
}

.documents-panel.hidden {
  display: none;
}

.documents-group h3 {
  margin: 0 0 4px;
  font-size: 0.82rem;
}

.documents-group ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 0;
  color: var(--muted);
  line-height: 1.25;
}

.messages {
  align-content: start;
  overflow: auto;
  padding-right: 4px;
  min-height: 0;
  padding-bottom: 8px;
}

.message {
  max-width: min(860px, 100%);
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
}

.message.user {
  justify-self: end;
  background: rgba(180, 74, 31, 0.12);
}

.message-meta {
  margin-bottom: 8px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.message-body {
  line-height: 1.5;
}

.message-body p,
.message-body ul,
.message-body ol,
.message-body h2,
.message-body h3,
.message-body h4 {
  margin: 0;
}

.message-body p + p,
.message-body p + ul,
.message-body p + ol,
.message-body ul + p,
.message-body ol + p,
.message-body h2 + p,
.message-body h3 + p,
.message-body h4 + p {
  margin-top: 10px;
}

.message-body ul,
.message-body ol {
  padding-left: 20px;
}

.message-body code {
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(26, 29, 32, 0.08);
  font-family: "SFMono-Regular", Menlo, monospace;
  font-size: 0.92em;
}

.citations {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--muted);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

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

.row-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.user-admin-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

.approval-card {
  display: grid;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.danger-button {
  background: rgba(180, 74, 31, 0.14);
  color: var(--accent-dark);
  border: 1px solid rgba(180, 74, 31, 0.24);
  padding: 7px 10px;
  font-size: 0.76rem;
}

.danger-button:hover {
  background: rgba(180, 74, 31, 0.24);
}

.settings-group {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.38);
}

.settings-group h3 {
  margin: 0 0 8px;
}

.spaced-top {
  margin-top: 20px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 247, 240, 0.35);
  border-top-color: #fff7f0;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

.spinner.hidden {
  display: none;
}

.reveal {
  animation: rise 360ms ease;
}

.reveal-left {
  animation: slide 420ms ease;
}

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

@keyframes slide {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .auth-card-wide,
  .workspace-shell,
  .dashboard-grid,
  .grid-two,
  .grid-phone {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    margin: 0;
  }

  .dashboard-body {
    padding-top: 0;
  }

  .chat-page-body {
    height: auto;
    overflow: auto;
  }

  .workspace-shell,
  .main-panel {
    height: auto;
  }

  .hero-header-row {
    grid-template-columns: 1fr;
  }

  .hero-documents-column,
  .hero-filter-row {
    width: 100%;
  }

  .hero-filter-field,
  .hero-documents-button {
    width: 100%;
  }

  .documents-panel {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
  }
}


.topbar {
  background: #F6B738;
}

.topbar .ghost-button:hover,
.topbar .ghost-button:focus-visible,
.topbar .ghost-link:hover,
.topbar .ghost-link:focus-visible {
  color: #ffffff;
}

.auth-shell {
  min-height: 100vh;
  background: rgba(246, 183, 56, 0.22);
}

.auth-form-panel {
  background: #F6B738;
}
