/* ---------------------------------------------------------------
   Auour AI Portal — design tokens
   navy-deep  #0D1A2B   sidebar / structure
   navy       #16283F   raised panels on navy
   gold       #C9A227   accent, provenance, brand
   gold-soft  #E8D9A8   quiet gold highlights
   paper      #F7F5F0   working surface
   ink        #1C2530   primary text on paper
   slate      #66707E   secondary text
--------------------------------------------------------------- */
:root {
  --navy-deep: #0D1A2B;
  --navy: #16283F;
  --navy-line: #24405f;
  --gold: #C9A227;
  --gold-soft: #E8D9A8;
  --paper: #F7F5F0;
  --card: #FFFFFF;
  --ink: #1C2530;
  --slate: #66707E;
  --line: #E3DED2;
  --display: 'Spectral', Georgia, serif;
  --body: 'Inter', -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.55;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--navy-deep);
  color: #D7DEE8;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 14px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--gold);
  padding: 0 6px 20px;
  border-bottom: 1px solid var(--navy-line);
}

.brand-text { flex: 1; min-width: 0; }

.sidebar-close,
.sidebar-open,
.sidebar-backdrop {
  display: none;
}

.compass { width: 34px; height: 34px; flex: none; }

.wordmark {
  font-family: var(--display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.22em;
  display: block;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8DA0B8;
}

.new-conv {
  margin: 18px 0 14px;
  padding: 10px 12px;
  font-family: var(--body);
  font-weight: 500;
  font-size: 13.5px;
  color: var(--gold-soft);
  background: transparent;
  border: 1px solid var(--gold);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s ease;
}
.new-conv:hover { background: rgba(201,162,39,0.12); }
.new-conv:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.conv-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-line) transparent;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 6px;
  color: #C4CEDB;
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  font-family: var(--body);
}
.conv-item:hover { background: var(--navy); }
.conv-item.active { background: var(--navy); color: #fff; box-shadow: inset 2px 0 0 var(--gold); }
.conv-item .conv-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item .conv-del {
  border: none; background: none; color: #6E819A;
  cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px;
  border-radius: 4px; visibility: hidden;
}
.conv-item:hover .conv-del { visibility: visible; }
.conv-item .conv-del:hover { color: var(--gold-soft); }

.sidebar-foot {
  border-top: 1px solid var(--navy-line);
  padding-top: 12px;
  margin-top: 10px;
}

.user-chip {
  font-size: 12.5px;
  color: #AEBBCB;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-chip span { overflow: hidden; text-overflow: ellipsis; }
.user-chip .sign-out {
  color: var(--gold-soft);
  font-size: 11px;
  text-decoration: none;
  flex: none;
}
.user-chip .sign-out:hover { text-decoration: underline; }

.storage-note {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5E7290;
  margin-top: 4px;
}

/* ---------- Main ---------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.model-picker { display: flex; gap: 6px; flex-wrap: wrap; }

.model-btn {
  font-family: var(--body);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.model-btn.active {
  border-color: var(--navy-deep);
  background: var(--navy-deep);
  color: var(--gold-soft);
}
.model-btn:disabled {
  color: var(--slate);
  background: transparent;
  cursor: default;
  opacity: 0.75;
}
.model-btn .phase-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--slate);
  margin-left: 6px;
}
.model-btn:focus-visible { outline: 2px solid var(--navy-deep); outline-offset: 2px; }

.placeholder-banner {
  padding: 9px 28px;
  background: #FBF3DC;
  border-bottom: 1px solid #EADFB9;
  color: #6B5A1E;
  font-size: 13px;
}

/* ---------- Messages ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--slate);
  max-width: 420px;
}
.empty-state .compass-lg {
  width: 64px; height: 64px; color: var(--gold); margin-bottom: 18px;
}
.empty-state h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 26px;
  color: var(--ink);
  margin-bottom: 8px;
}
.empty-state p { font-size: 14px; }

.msg { max-width: 760px; width: 100%; margin: 0 auto; }

.msg-user .msg-body {
  background: var(--navy-deep);
  color: #EDF1F6;
  border-radius: 12px 12px 3px 12px;
  padding: 12px 16px;
  margin-left: auto;
  max-width: 78%;
  width: fit-content;
  white-space: pre-wrap;
}

.msg-assistant .msg-body {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 3px 12px 12px 12px;
  padding: 14px 18px;
}
.msg-assistant .msg-body:not(.md) { white-space: pre-wrap; }

/* Rendered markdown */
.md p { margin: 0 0 10px; }
.md p:last-child, .md ul:last-child, .md ol:last-child { margin-bottom: 0; }
.md h3, .md h4, .md h5, .md h6 {
  font-family: var(--display);
  font-weight: 600;
  color: var(--ink);
  margin: 16px 0 8px;
}
.md h3:first-child, .md h4:first-child { margin-top: 0; }
.md h3 { font-size: 17px; }
.md h4 { font-size: 15.5px; }
.md h5, .md h6 { font-size: 14.5px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.md code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}
.md pre {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0 0 10px;
}
.md pre code { border: none; background: none; padding: 0; white-space: pre; }
.md a { color: var(--navy); text-decoration: underline; }
.md strong { font-weight: 600; }

/* Signature: provenance line */
.provenance {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--slate);
}
.provenance .tick {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); flex: none;
}

.msg-error .msg-body {
  background: #FBECEA;
  border: 1px solid #EBCFCB;
  color: #7A2E24;
  border-radius: 8px;
  padding: 12px 16px;
}

.thinking { color: var(--slate); font-style: italic; }

/* ---------- Attachments ---------- */
.file-chips {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.file-chips:not(:empty) { margin-bottom: 8px; }

.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--slate);
  max-width: 240px;
}
.att-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip button {
  border: none; background: none; color: var(--slate);
  cursor: pointer; font-size: 13px; line-height: 1; padding: 0;
}
.att-chip button:hover { color: var(--ink); }

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.msg-user .msg-attachments { justify-content: flex-end; }

.attach-btn {
  border: none;
  background: none;
  color: var(--slate);
  cursor: pointer;
  padding: 8px 4px;
  border-radius: 6px;
  flex: none;
  display: inline-flex;
  align-items: center;
}
.attach-btn:hover { color: var(--navy-deep); }
.attach-btn:focus-visible { outline: 2px solid var(--navy-deep); outline-offset: 2px; }

/* ---------- Composer ---------- */
.composer-wrap { padding: 14px 28px 18px; border-top: 1px solid var(--line); }

.composer {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.composer:focus-within { border-color: var(--navy-deep); }

.composer textarea {
  flex: 1;
  border: none;
  resize: none;
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: transparent;
  max-height: 180px;
}
.composer textarea:focus { outline: none; }

.composer button {
  font-family: var(--body);
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 18px;
  border-radius: 7px;
  border: none;
  background: var(--gold);
  color: var(--navy-deep);
  cursor: pointer;
}
.composer button:hover { background: #D6B23A; }
.composer button:disabled { opacity: 0.5; cursor: default; }
.composer button:focus-visible { outline: 2px solid var(--navy-deep); outline-offset: 2px; }

.composer-note {
  max-width: 760px;
  margin: 8px auto 0;
  font-size: 11.5px;
  color: var(--slate);
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    z-index: 30;
    transform: translateX(-105%);
    transition: transform .2s ease;
  }

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

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(13, 26, 43, 0.45);
  }

  .sidebar-backdrop[hidden] { display: none; }

  .sidebar-open {
    display: inline-flex;
    align-items: center;
    font-family: var(--body);
    font-size: 12.5px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    cursor: pointer;
    flex: none;
  }

  .sidebar-close {
    display: inline-flex;
    margin-left: auto;
    font-family: var(--body);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--navy-line);
    background: transparent;
    color: #AEBBCB;
    cursor: pointer;
  }

  .topbar { padding: 12px 16px; }
  .messages, .composer-wrap { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
