
:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-soft: #f0f2ef;
  --sidebar: #eef1ee;
  --text: #18201f;
  --muted: #66706e;
  --line: #d9dfdc;
  --accent: #173f42;
  --accent-2: #315f62;
  --verified: #1d6b4f;
  --warning: #8d5b16;
  --danger: #a63535;
  --shadow: 0 20px 50px rgba(21, 35, 33, .12);
  --sidebar-width: 282px;
  --radius: 18px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

button, input, textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(23, 63, 66, .25);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  z-index: 30;
  transition: transform .22s ease;
}

.sidebar-head,
.brand,
.account-button,
.nav-item,
.footer-button,
.new-chat-button,
.search-box {
  display: flex;
  align-items: center;
}

.sidebar-head {
  justify-content: space-between;
  min-height: 44px;
}

.brand {
  gap: 10px;
  text-decoration: none;
}

.brand-mark,
.welcome-mark {
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
  font-weight: 750;
  letter-spacing: -.03em;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 12px;
}

.brand-copy {
  display: grid;
  line-height: 1.1;
}

.brand-copy small,
.account-copy small,
.topbar-title small {
  color: var(--muted);
  font-size: 11px;
}

.icon-button,
.dialog-close {
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 10px;
}

.icon-button {
  width: 40px;
  height: 40px;
  font-size: 20px;
}

.icon-button:hover,
.dialog-close:hover {
  background: rgba(23, 63, 66, .08);
}

.new-chat-button,
.nav-item,
.footer-button,
.account-button,
.settings-row {
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 12px;
}

.new-chat-button {
  gap: 10px;
  padding: 12px;
  background: var(--accent);
  color: white;
  justify-content: center;
  font-weight: 650;
}

.search-box {
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .55);
}

.search-box input {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
}

.platform-nav {
  display: grid;
  gap: 3px;
  margin-top: 2px;
}

.nav-item,
.footer-button {
  gap: 10px;
  padding: 10px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active,
.footer-button:hover,
.account-button:hover,
.conversation-row:hover,
.conversation-row.active {
  background: rgba(23, 63, 66, .08);
}

.history-label {
  padding: 8px 8px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.conversation-list {
  flex: 1;
  min-height: 100px;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 3px;
}

.conversation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
  padding: 8px 6px 8px 10px;
  border-radius: 11px;
}

.conversation-open {
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-menu {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  opacity: .65;
}

.conversation-menu:hover {
  background: rgba(23, 63, 66, .1);
  opacity: 1;
}

.conversation-actions {
  grid-column: 1 / -1;
  display: none;
  gap: 6px;
  padding-top: 4px;
}

.conversation-row.menu-open .conversation-actions {
  display: flex;
}

.conversation-actions button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
  font-size: 12px;
}

.sidebar-footer {
  display: grid;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.account-button {
  gap: 9px;
  padding: 8px;
  text-align: left;
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.account-copy {
  flex: 1;
  min-width: 0;
  display: grid;
}

.main-panel {
  min-height: 100dvh;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  border-bottom: 1px solid rgba(217, 223, 220, .75);
  background: rgba(247, 247, 244, .88);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 15;
}

.topbar-title {
  display: grid;
  flex: 1;
}

.status-badges {
  display: flex;
  gap: 6px;
}

.badge {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(23, 63, 66, .08);
  font-size: 11px;
  font-weight: 650;
}

.view {
  display: none;
  flex: 1;
}

.active-view {
  display: flex;
}

#chatView {
  min-height: calc(100dvh - 64px);
  flex-direction: column;
}

.welcome {
  width: min(760px, calc(100% - 32px));
  margin: auto;
  padding: 44px 0 140px;
  text-align: center;
}

.welcome-mark {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  margin: 0 auto 20px;
}

.welcome h1,
.info-card h1 {
  margin: 0 0 10px;
  letter-spacing: -.04em;
  font-size: clamp(30px, 5vw, 48px);
}

.welcome > p {
  max-width: 600px;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.7;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
}

.prompt-grid button {
  min-height: 72px;
  padding: 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
}

.prompt-grid button:hover {
  border-color: var(--accent-2);
  transform: translateY(-1px);
}

.welcome-footnote {
  margin-top: 24px !important;
  font-size: 12px;
}

.messages {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 24px 18px 160px;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 14px;
  padding: 18px 0;
}

.message-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-soft);
  font-weight: 750;
  font-size: 11px;
}

.message.user .message-avatar::after { content: "You"; }
.message.assistant .message-avatar {
  color: white;
  background: var(--accent);
}
.message.assistant .message-avatar::after { content: "ESC"; }

.message-content {
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.semantic-details {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.semantic-details summary {
  cursor: pointer;
  padding: 10px 12px;
  color: var(--accent);
  font-weight: 650;
}

.semantic-details dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 12px;
  margin: 0;
  padding: 0 12px 12px;
  font-size: 13px;
}

.semantic-details dt { color: var(--muted); }
.semantic-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.composer-wrap {
  position: fixed;
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  padding: 20px max(16px, calc((100vw - var(--sidebar-width) - 860px) / 2));
  background: linear-gradient(
    to top,
    var(--bg) 68%,
    rgba(247, 247, 244, 0)
  );
  z-index: 12;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: end;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer textarea {
  width: 100%;
  max-height: 188px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  line-height: 1.5;
  padding: 8px 0;
}

.send-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 15px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 20px;
}

.send-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.composer-note {
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.info-view {
  padding: 32px 18px 100px;
}

.info-card {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.principle-grid,
.evidence-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 24px;
}

.evidence-stat-grid {
  grid-template-columns: repeat(4, 1fr);
}

.principle-grid article,
.evidence-stat-grid article,
.atom-item {
  display: grid;
  gap: 5px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-soft);
}

.principle-grid span,
.evidence-stat-grid span {
  color: var(--muted);
  font-size: 13px;
}

.evidence-stat-grid strong {
  color: var(--accent);
  font-size: 23px;
}

.bounded-note {
  margin-top: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.atom-list {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
}

.modal {
  width: min(430px, calc(100% - 24px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
}

.modal::backdrop {
  background: rgba(14, 20, 19, .48);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  display: grid;
  gap: 15px;
  padding: 26px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  font-size: 22px;
}

.modal-card h2 {
  margin: 0;
  letter-spacing: -.025em;
}

.modal-card > p:not(.eyebrow):not(.form-error) {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal-card label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
}

.modal-card input:not([type="checkbox"]) {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.check-row {
  display: flex !important;
  align-items: center;
  font-weight: 400 !important;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  border: 0;
  border-radius: 11px;
  padding: 12px 15px;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
}

.danger-button {
  background: var(--danger);
  color: white;
}

.text-button {
  background: transparent;
  color: var(--accent);
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

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

.account-modal {
  gap: 5px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.danger-row {
  color: var(--danger);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 20, 19, .35);
  z-index: 25;
}

.mobile-only { display: none; }

body.sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

body.sidebar-collapsed .main-panel {
  margin-left: 0;
}

body.sidebar-collapsed .composer-wrap {
  left: 0;
}

@media (max-width: 900px) {
  .sidebar {
    box-shadow: var(--shadow);
    transform: translateX(-105%);
  }

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

  .main-panel {
    margin-left: 0;
  }

  .composer-wrap {
    left: 0;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

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

  .status-badges .badge:nth-child(2) {
    display: none;
  }

  .principle-grid,
  .evidence-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .topbar {
    padding-inline: 10px;
  }

  .topbar-title small,
  .status-badges {
    display: none;
  }

  .welcome {
    padding-top: 28px;
  }

  .prompt-grid,
  .principle-grid,
  .evidence-stat-grid {
    grid-template-columns: 1fr;
  }

  .info-card {
    padding: 22px;
    border-radius: 18px;
  }

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

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