/* ============================================
   BalGPT — design tokens
   Color:  ink (#12211D) / ink-soft (#1B2F29) / parchment (#F4EEE1)
           brass (#C98A3E) / sage (#8FAF9B) / rust (#A8503A, sparing)
   Type:   Fraunces (display) + IBM Plex Sans (UI) + IBM Plex Mono (code)
   ============================================ */

:root {
  --ink: #12211D;
  --ink-soft: #1B2F29;
  --ink-softer: #223A32;
  --parchment: #F4EEE1;
  --parchment-dim: #C9C3B4;
  --brass: #C98A3E;
  --brass-bright: #E0A559;
  --sage: #8FAF9B;
  --rust: #A8503A;
  --border: rgba(244, 238, 225, 0.10);

  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --radius: 14px;
  --sidebar-w: 272px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--font-ui);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, textarea, input {
  font-family: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 2px;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--ink-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  gap: 18px;
  overflow-y: auto;
}

.brand {
  padding: 4px 2px 6px;
}

.brand__mark {
  position: relative;
  display: inline-block;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--parchment);
}

.brand__mark em {
  font-style: italic;
  font-weight: 500;
  color: var(--brass-bright);
}

.brand__underline {
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 100%;
  height: 10px;
}

.brand__underline path {
  fill: none;
  stroke: var(--sage);
  stroke-width: 1.6;
  stroke-linecap: round;
  opacity: 0.85;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--parchment);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.new-chat:hover {
  background: var(--ink-softer);
  border-color: var(--brass);
}

.sidebar__section-label {
  font-size: 12.5px;
  color: var(--parchment-dim);
  margin-top: 6px;
  padding: 0 2px;
}

.history {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.history__empty {
  color: var(--parchment-dim);
  font-size: 13.5px;
  padding: 6px 2px;
  margin: 0;
}

.history__item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--parchment);
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history__item:hover {
  background: var(--ink-softer);
}

.sidebar__foot {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.sidebar__foot p {
  margin: 0;
  font-size: 12.5px;
  color: var(--parchment-dim);
  line-height: 1.5;
}

.sidebar__foot code {
  font-family: var(--font-mono);
  background: var(--ink-softer);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}

/* ---------- Main chat pane ---------- */

.chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
}

.chat__topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--parchment);
  cursor: pointer;
  padding: 4px;
}

.chat__topbar-title {
  font-size: 14px;
  color: var(--parchment-dim);
}

.stream {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.welcome {
  margin: auto 0;
  max-width: 620px;
  align-self: center;
  text-align: center;
  padding: 40px 20px;
}

.welcome h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 34px;
  margin: 0 0 10px;
  color: var(--parchment);
}

.welcome p {
  color: var(--parchment-dim);
  margin: 0 0 24px;
  font-size: 15px;
}

.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.suggestion {
  background: var(--ink-soft);
  border: 1px solid var(--border);
  color: var(--parchment);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.suggestion:hover {
  border-color: var(--brass);
}

.msg {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  gap: 12px;
}

.msg__avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
}

.msg--user .msg__avatar {
  background: var(--ink-softer);
  color: var(--sage);
}

.msg--bot .msg__avatar {
  background: var(--brass);
  color: var(--ink);
}

.msg__body {
  padding-top: 4px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg__body p {
  margin: 0 0 10px;
}

.msg__body p:last-child {
  margin-bottom: 0;
}

.msg--typing .msg__body {
  color: var(--parchment-dim);
  font-style: italic;
}

/* ---------- Composer ---------- */

.composer {
  max-width: 680px;
  width: calc(100% - 48px);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--ink-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 10px 10px 16px;
}

.composer__input {
  flex: 1;
  background: transparent;
  border: none;
  resize: none;
  color: var(--parchment);
  font-size: 15px;
  line-height: 1.5;
  max-height: 160px;
  padding: 6px 0;
}

.composer__input::placeholder {
  color: var(--parchment-dim);
}

.composer__send {
  background: var(--brass);
  border: none;
  color: var(--ink);
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.composer__send:hover {
  background: var(--brass-bright);
}

.composer__send:disabled {
  background: var(--ink-softer);
  color: var(--parchment-dim);
  cursor: not-allowed;
}

.composer__hint {
  text-align: center;
  font-size: 12px;
  color: var(--parchment-dim);
  margin: 10px 0 18px;
}

/* ---------- Responsive ---------- */

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 20px 0 40px rgba(0,0,0,0.35);
  }

  .icon-btn {
    display: flex;
  }

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

  .composer {
    width: calc(100% - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .new-chat, .suggestion, .composer__send {
    transition: none;
  }
}
