:root {
  --ink: #172033;
  --muted: #6f7786;
  --line: #d8dde6;
  --line-soft: #e8ebf0;
  --page: #ffffff;
  --panel: #f2f3f5;
  --panel-deep: #e9eaed;
  --blue: #1268e8;
  --blue-dark: #0b4fb7;
  --blue-soft: #e9f2ff;
  --user: #edf5ff;
  --code: #f2f2f3;
  --ribbon: #fafafa;
  --sidebar-width: 330px;
  --ribbon-height: 56px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

.app-shell {
  width: 100vw;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: var(--ribbon-height) minmax(0, 1fr);
  overflow: hidden;
  background: white;
}

/* top ribbon */
.app-ribbon {
  position: relative;
  z-index: 20;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 14px;
  background: var(--ribbon);
  border-bottom: 1px solid #cfd4dc;
  box-shadow: 0 1px 2px rgba(20, 29, 43, .03);
}
.ribbon-left, .ribbon-right {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 6px 0 2px;
  text-decoration: none;
  font-weight: 760;
  font-size: 15px;
  letter-spacing: -.015em;
  white-space: nowrap;
}
.brand-mark { position: relative; display: inline-block; width: 28px; height: 24px; flex: 0 0 auto; }
.bubble { position: absolute; border-radius: 7px; width: 19px; height: 14px; }
.bubble::after { content: ""; position: absolute; width: 5px; height: 5px; bottom: -2px; transform: rotate(45deg); border-radius: 1px; }
.bubble-a { left: 0; top: 1px; background: var(--blue); }
.bubble-a::after { left: 4px; background: var(--blue); }
.bubble-b { right: 0; bottom: 0; background: white; border: 2px solid #91bfff; }
.bubble-b::after { right: 3px; background: white; border-right: 2px solid #91bfff; border-bottom: 2px solid #91bfff; }
.ribbon-divider { width: 1px; height: 24px; margin: 0 3px; background: #d7dbe2; }
.ribbon-button {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid #d4d9e0;
  border-radius: 7px;
  color: #30394a;
  background: white;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(20, 29, 43, .02);
}
.ribbon-button:hover:not(:disabled) { background: #f4f5f7; border-color: #c8ced7; }
.ribbon-button:active:not(:disabled) { background: #eceef1; }
.ribbon-button:disabled { opacity: .42; cursor: default; }
.button-icon { color: #566174; font-size: 16px; line-height: 1; font-weight: 500; }
.local-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #697286;
  font-size: 11px;
  font-weight: 620;
  white-space: nowrap;
}
.local-dot { width: 7px; height: 7px; border-radius: 50%; background: #57a668; box-shadow: 0 0 0 2px #e2f0e5; }
.mac-cta {
  height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  border-radius: 7px;
  color: white;
  background: #1e5fca;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.mac-cta:hover { background: #174fae; }

/* fixed application workspace */
.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  overflow: hidden;
}

/* library */
.library-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid #cfd4db;
}
.library-controls { padding: 16px 13px 12px; border-bottom: 1px solid #d8dce2; }
.library-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 3px 11px;
  color: #333b49;
  font-size: 13px;
  font-weight: 760;
}
.library-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #dde0e5;
  color: #657084;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
}
.library-search {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid #c8cdd6;
  border-radius: 7px;
  background: white;
  box-shadow: inset 0 1px 1px rgba(17, 25, 38, .03);
}
.library-search:focus-within { border-color: #77a9f4; box-shadow: 0 0 0 2px rgba(18, 104, 232, .15); }
.library-search > span { color: #6f7888; font-size: 15px; }
.library-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: #303847;
  background: transparent;
  font-size: 12px;
}
.library-search input::placeholder { color: #949ba6; }
.library-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 8px 0 12px;
}
.library-empty {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 28px 24px;
  color: #8a919e;
  text-align: center;
}
.library-empty strong { color: #656d7a; font-size: 12px; }
.library-empty span { font-size: 11px; line-height: 1.5; }
.library-item {
  width: 100%;
  display: block;
  padding: 10px 18px 11px;
  border: 0;
  border-top: 1px solid transparent;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: #262e3b;
  text-align: left;
  cursor: pointer;
}
.library-item:hover { background: #e7e9ed; }
.library-item.active {
  background: #dadcdf;
  border-top-color: #d0d3d8;
  border-bottom-color: #d0d3d8;
}
.library-item-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}
.library-item-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  color: #6e7582;
  font-size: 10px;
  white-space: nowrap;
}
.library-provider {
  padding: 2px 7px;
  border-radius: 5px;
  background: #d2d4d8;
  color: #626975;
  font-size: 9px;
  font-weight: 760;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.library-file {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-footer {
  padding: 9px 13px 10px;
  border-top: 1px solid #d7dbe1;
  color: #8a919c;
  background: rgba(255,255,255,.2);
  font-size: 9.5px;
  line-height: 1.35;
}

/* conversation */
.conversation-pane { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: white; }
.empty-state {
  width: min(580px, calc(100% - 48px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transform: translateY(-2vh);
}
.empty-mark { position: relative; width: 64px; height: 54px; margin-bottom: 22px; }
.empty-bubble { position: absolute; width: 43px; height: 31px; border-radius: 12px; }
.empty-bubble::after { content: ""; position: absolute; width: 10px; height: 10px; bottom: -3px; transform: rotate(45deg); border-radius: 2px; }
.empty-bubble-a { left: 0; top: 0; background: var(--blue); }
.empty-bubble-a::after { left: 8px; background: var(--blue); }
.empty-bubble-b { right: 0; bottom: 0; background: white; border: 3px solid #9dc5ff; }
.empty-bubble-b::after { right: 7px; background: white; border-right: 3px solid #9dc5ff; border-bottom: 3px solid #9dc5ff; }
.empty-state h1 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.empty-state p { max-width: 540px; margin: 12px 0 22px; color: #737b89; font-size: 13px; line-height: 1.6; }
.primary-button {
  height: 38px;
  padding: 0 15px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--blue);
  font-size: 12px;
  font-weight: 720;
  cursor: pointer;
}
.primary-button:hover { background: var(--blue-dark); }
.empty-hint { margin-top: 11px; color: #9aa1ac; font-size: 10px; }
.empty-error { max-width: 520px; margin-top: 16px; padding: 9px 12px; border-radius: 7px; color: #9b3f3f; background: #fff0f0; font-size: 11px; line-height: 1.45; }

.conversation-view {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}
.conversation-header {
  padding: 18px 28px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255,255,255,.98);
}
.conversation-title-row { min-width: 0; display: flex; align-items: center; gap: 10px; }
.conversation-title-row h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #252a31;
  font-size: 20px;
  font-weight: 760;
  letter-spacing: -.025em;
}
.provider-pill {
  flex: 0 0 auto;
  padding: 3px 8px;
  border: 1px solid #d9dce2;
  border-radius: 6px;
  color: #4f5764;
  background: #f8f8f9;
  font-size: 10px;
  font-weight: 690;
}
.conversation-meta {
  margin-top: 8px;
  color: #858b94;
  font-size: 10.5px;
  line-height: 1.4;
}
.conversation-meta .sep { padding: 0 5px; color: #b2b6bd; }
.notice {
  margin: 12px 28px 0;
  padding: 9px 11px;
  border: 1px solid #f0dfaa;
  border-radius: 7px;
  color: #735f28;
  background: #fff9e9;
  font-size: 10.5px;
  line-height: 1.45;
}
.conversation-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
}
.messages {
  width: min(900px, calc(100% - 64px));
  margin: 0 auto;
  padding: 34px 0 90px;
}
.message { margin: 0 0 30px; }
.message-header {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 0 0 7px;
  color: #a0a5ad;
  font-size: 10px;
}
.message-role { color: #777e89; font-weight: 700; }
.message-number { color: #a9aeb5; }
.message-time { margin-left: 2px; color: #aaaeb5; }
.message-body {
  color: #202632;
  font-size: 14px;
  line-height: 1.62;
  overflow-wrap: anywhere;
}
.message.user .message-body {
  padding: 14px 16px;
  border: 1px solid #dbe9fb;
  border-radius: 13px;
  background: var(--user);
}
.message.assistant .message-body,
.message.document .message-body { padding: 0; }
.message.system .message-body {
  padding: 11px 13px;
  border-radius: 9px;
  color: #667080;
  background: #f5f5f6;
  font-size: 12px;
}
.message-body p { margin: 0 0 11px; }
.message-body p:last-child { margin-bottom: 0; }
.message-body strong { font-weight: 760; }
.message-body a { color: #185fc2; text-decoration: none; }
.message-body a:hover { text-decoration: underline; }
.message-body code:not(pre code) {
  padding: 2px 5px;
  border-radius: 4px;
  background: #efeff1;
  font: 12px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.message-body pre {
  overflow-x: auto;
  margin: 13px 0;
  padding: 13px 15px;
  border: 1px solid #e2e2e4;
  border-radius: 11px;
  background: var(--code);
  color: #262b33;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.drop-overlay {
  position: fixed;
  z-index: 100;
  inset: var(--ribbon-height) 0 0 0;
  display: grid;
  place-items: center;
  background: rgba(240, 246, 255, .82);
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.drop-overlay > div {
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 28px 34px;
  border: 2px dashed #72a8f8;
  border-radius: 16px;
  color: #245da9;
  background: rgba(255,255,255,.92);
  text-align: center;
}
.drop-overlay strong { font-size: 16px; }
.drop-overlay span { color: #7186a4; font-size: 11px; }

@media (max-width: 760px) {
  :root { --sidebar-width: 245px; }
  .local-status { display: none; }
  .mac-cta { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
  .messages { width: min(100% - 36px, 760px); }
  .conversation-header { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 560px) {
  :root { --sidebar-width: 0px; }
  .library-pane { display: none; }
  .brand > span:last-child { display: none; }
  .ribbon-divider { display: none; }
  .ribbon-button { padding: 0 9px; }
  .mac-cta { max-width: 124px; font-size: 10px; }
  .messages { width: calc(100% - 28px); padding-top: 24px; }
}
