:root {
  --ink: #292423;
  --muted: #716a67;
  --line: #e5dfdb;
  --canvas: #f8f6f3;
  --paper: #fff;
  --plum: #6c3147;
  --plum-dark: #512236;
  --red: #a33d36;
  --green: #297254;
  --focus: #b56882;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font:
    15px/1.5 "DM Sans",
    sans-serif;
}
.shell {
  max-width: 1240px;
  margin: auto;
  padding: 0 28px;
}
header {
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
}
.brand small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--plum);
  color: white;
}
nav {
  display: flex;
  gap: 5px;
}
button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 10px 13px;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.nav-button {
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 13px;
}
.nav-button.active {
  background: #f3ebee;
  color: var(--plum);
}
.app-view {
  display: none;
}
.app-view.active {
  display: block;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--plum);
  margin: 0 0 10px;
}
.chat-hero {
  padding: 60px 0 34px;
}
.chat-hero h1,
.intro h1 {
  max-width: 720px;
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: -0.04em;
  line-height: 1.08;
  margin: 0;
}
.chat-hero > p:last-child,
.lede {
  max-width: 620px;
  color: var(--muted);
  font-size: 17px;
  margin: 16px 0 0;
}
.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
  padding-bottom: 54px;
}
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.chat-messages {
  min-height: 350px;
  max-height: 520px;
  overflow: auto;
  padding: 26px;
}
.message {
  max-width: 85%;
  padding: 14px 16px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: #f5f0ed;
}
.message.user {
  background: #f3e9ed;
  margin-left: auto;
}
.message > strong:first-child,
.message-author {
  display: block;
  font-size: 12px;
  color: var(--plum);
  margin-bottom: 4px;
}
.message-body {
  margin: 5px 0 0;
  line-height: 1.6;
  font-size: 15px;
}
.message-body p {
  margin: 0 0 10px;
}
.message-body p:last-child {
  margin-bottom: 0;
}
.message-body strong {
  font-weight: 700;
  color: inherit;
  font-size: inherit;
}
.message-body ul,
.message-body ol {
  margin: 8px 0 12px 20px;
  padding: 0;
}
.message-body li {
  margin-bottom: 5px;
}
.message-body h2,
.message-body h3,
.message-body h4 {
  margin: 14px 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.message-body code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "DM Mono", monospace;
  font-size: 13px;
}
.message-body pre {
  background: #231f20;
  color: #f8f6f3;
  padding: 12px 14px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 13px;
  margin: 10px 0;
}
.message-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}
.message-body a {
  color: var(--plum);
  text-decoration: underline;
}
.message-body a:hover {
  color: var(--plum-dark);
}
.message-body blockquote {
  border-left: 3px solid var(--plum);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--muted);
  font-style: italic;
}
.thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 20px;
}
.thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--plum);
  animation: thinking-pulse 1s infinite ease-in-out;
}
.thinking span:nth-child(2) {
  animation-delay: 0.15s;
}
.thinking span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes thinking-pulse {
  0%,
  80%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}
.chat-form {
  margin: 0;
  padding: 18px;
  border-top: 1px solid var(--line);
}
.chat-form textarea {
  min-height: 82px;
}
.chat-form > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}
.chat-aside {
  border-left: 1px solid var(--line);
  padding: 10px 0 0 24px;
}
.chat-aside h2 {
  font-size: 15px;
  margin: 0 0 10px;
}
.chat-aside p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 18px;
}
.suggestion {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  margin-bottom: 10px;
  padding: 10px 14px;
  line-height: 1.4;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.suggestion:hover {
  background: #faf6f8;
  border-color: var(--plum);
  color: var(--plum-dark);
}
.intro {
  padding: 54px 0 40px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
}
.count {
  text-align: right;
}
.count strong {
  display: block;
  font-size: 32px;
}
.count span {
  color: var(--muted);
  font-size: 13px;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.84fr) minmax(460px, 1.4fr);
  gap: 24px;
  padding-bottom: 54px;
}
.editor {
  height: max-content;
  padding: 28px;
}
.panel-head,
.records-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}
.panel h2 {
  font-size: 18px;
  margin: 0;
}
.panel p {
  margin: 5px 0;
  color: var(--muted);
  font-size: 13px;
}
form {
  margin-top: 26px;
}
label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin: 17px 0 7px;
}
input,
textarea {
  width: 100%;
  font: inherit;
  border: 1px solid #d5ceca;
  border-radius: 6px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}
textarea {
  resize: vertical;
  min-height: 136px;
}
input:focus,
textarea:focus {
  outline: 0;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px #f2dfe5;
}
.field-error {
  min-height: 18px !important;
  color: var(--red) !important;
  margin: 4px 0 0 !important;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}
.form-status {
  font-size: 13px;
  color: var(--muted);
}
.primary {
  background: var(--plum);
  color: #fff;
}
.primary:hover {
  background: var(--plum-dark);
}
.secondary {
  background: #fff;
  border-color: #d7d0cc;
  color: var(--ink);
}
.text-button {
  padding: 4px;
  background: transparent;
  color: var(--plum);
}
.records-head {
  padding: 28px 28px 18px;
}
.transfer {
  display: flex;
  gap: 8px;
}
.file-label {
  display: inline-block;
  padding: 9px 11px;
  font-size: 13px;
  cursor: pointer;
}
.file-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}
.toolbar {
  display: flex;
  gap: 10px;
  padding: 0 28px 18px;
  border-bottom: 1px solid var(--line);
}
.toolbar input {
  flex: 1;
  padding: 9px 11px;
}
.danger-outline {
  border-color: #dab9b5;
  color: var(--red);
  background: #fff;
  padding: 8px 10px;
  font-size: 13px;
}
.records-list {
  min-height: 260px;
}
.record {
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 12px;
  align-items: start;
}
.record:last-child {
  border: 0;
}
.record input[type="checkbox"] {
  margin: 5px 0;
  width: 16px;
  height: 16px;
  accent-color: var(--plum);
}
.record h3 {
  margin: 0;
  font-size: 15px;
}
.preview {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 510px;
}
.meta {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  color: var(--muted);
  font:
    11px "DM Mono",
    monospace;
}
.tag {
  background: #f4f0ed;
  padding: 3px 5px;
  border-radius: 3px;
}
.record-actions {
  display: flex;
  gap: 3px;
}
.record-actions button {
  padding: 5px 7px;
  background: #fff;
  color: var(--plum);
  font-size: 12px;
}
.record-actions .remove {
  color: var(--red);
}
details {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
summary {
  cursor: pointer;
  color: var(--plum);
}
pre {
  white-space: pre-wrap;
  word-break: break-all;
  background: #faf8f6;
  border: 1px solid var(--line);
  padding: 9px;
  font:
    11px "DM Mono",
    monospace;
}
.empty {
  padding: 56px 30px;
  text-align: center;
  color: var(--muted);
}
.notice {
  margin-bottom: 22px;
  border: 1px solid #b7d7c6;
  background: #f0f8f3;
  color: var(--green);
  padding: 11px 14px;
  border-radius: 6px;
}
.notice.error {
  border-color: #e2c1bd;
  background: #fcf3f2;
  color: #87352f;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  max-width: 400px;
  color: var(--ink);
}
dialog form {
  margin: 0;
  padding: 25px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}
.danger {
  background: var(--red);
  color: white;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
@media (max-width: 850px) {
  .workspace,
  .chat-layout {
    grid-template-columns: 1fr;
  }
  .chat-aside {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 20px 0;
  }
  .intro {
    padding-top: 36px;
  }
}
@media (max-width: 560px) {
  .shell {
    padding: 0 16px;
  }
  .chat-hero {
    padding-top: 36px;
  }
  .intro {
    display: block;
    padding-bottom: 28px;
  }
  .count {
    text-align: left;
    margin-top: 22px;
  }
  .editor {
    padding: 21px;
  }
  .records-head,
  .toolbar {
    padding-left: 20px;
    padding-right: 20px;
  }
  .records-head {
    display: block;
  }
  .transfer {
    margin-top: 14px;
  }
  .record {
    padding: 15px 20px;
    grid-template-columns: 20px 1fr;
  }
  .record-actions {
    grid-column: 2;
  }
  .preview {
    max-width: 220px;
  }
}

/* Compact, paginated library rows */
.library-summary {
  display: flex;
  justify-content: space-between;
  padding: 13px 28px;
  background: #fcfbfa;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.record { grid-template-columns: 24px minmax(0, 1fr) auto; gap: 14px; }
.record-select { min-height: 18px; }
.record-main { min-width: 0; }
.record-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.record h3 { line-height: 1.35; min-width: 0; }
.preview { max-width: none; }
.source-badge { display: inline-block; flex: 0 0 auto; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: #f4e9ed; color: var(--plum); padding: 3px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.source-badge.managed { background: #edf4ef; color: var(--green); }
.source-badge.web { background: #eaf1fa; color: #1e5a8a; }
.source-badge.calc { background: #fef3c7; color: #92400e; }
.chat-sources { margin-top: 8px; font-size: 13px; color: var(--muted); }
.chat-sources a { color: var(--plum); text-decoration: underline; }
.chat-sources a:hover { color: var(--plum-dark); }
.read-only { color: var(--muted); font-size: 12px; white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; color: var(--muted); font-size: 13px; }
.pagination div { display: flex; gap: 8px; }
.page-button { padding: 7px 11px; font-size: 12px; }
@media (max-width: 560px) {
  .record { grid-template-columns: 20px minmax(0, 1fr); }
  .record-actions { grid-column: 2; }
  .record-title { align-items: flex-start; flex-direction: column; gap: 5px; }
  .preview { max-width: 100%; }
  .library-summary, .pagination { padding-left: 20px; padding-right: 20px; }
  .pagination { align-items: flex-start; flex-direction: column; gap: 12px; }
}
