:root {
  --chat-surface: #15151b;
  --chat-surface-strong: #1d1d29;
  --chat-accent: #8fa8ff;
  --chat-accent-soft: rgba(143, 168, 255, .14);
  --chat-secondary: #88d8e9;
  --chat-gold: #bdb2ff;
  --chat-danger: #ff9aaa;
}

.chats-page {
  min-height: 100vh;
}

.chats-main a {
  color: inherit;
  text-decoration: none;
}

.chats-page button,
.chats-page input {
  font: inherit;
}

.chats-page button {
  cursor: pointer;
}

.chats-page svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.chats-main {
  max-width: none;
  margin: 0 0 0 232px;
  padding: 0 32px 68px;
}

.chats-main .page-header {
  min-height: 132px;
  padding: 18px 2px 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  border-bottom: 1px solid var(--app-line);
}

.chats-main .eyebrow {
  color: var(--chat-accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.chats-main .page-header h1 {
  margin: 5px 0 9px;
  color: var(--app-ink);
  font: 600 42px/1.03 "Syne", Georgia, serif;
}

.chats-main .page-header p {
  max-width: 640px;
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 1.55;
}

.chats-main .header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.chats-main .primary-button,
.chats-main .secondary-button {
  min-height: 43px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--app-line-bright);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.chats-main .primary-button {
  border-color: #6576bd;
  background: #303452;
  color: #e7e9ff;
}

.chats-main .primary-button:hover {
  border-color: #8fa8ff;
  background: #3a4068;
  transform: translateY(-1px);
}

.chats-main .secondary-button {
  background: var(--chat-surface-strong);
  color: var(--app-ink);
}

.chats-main .secondary-button:hover {
  border-color: #62627e;
  background: #292a40;
  transform: translateY(-1px);
}

.chats-main .primary-button svg,
.chats-main .secondary-button svg {
  width: 16px;
  height: 16px;
}

.chats-main .chat-toolbar {
  min-height: 77px;
  padding: 14px 0;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--app-line);
}

.chats-main .search-field {
  width: min(390px, 100%);
  height: 48px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--app-line);
  border-top-color: var(--app-line-bright);
  border-radius: 13px;
  background: var(--chat-surface);
  color: var(--app-quiet);
  box-shadow: none;
}

.chats-main .search-field:focus-within {
  border-color: #6576bd;
  box-shadow: 0 0 0 3px rgba(143, 168, 255, .1);
}

.chats-main .search-field input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--app-ink);
  font-size: 12px;
}

.chats-main .search-field input::placeholder {
  color: var(--app-quiet);
}

.chats-main .search-field svg {
  width: 17px;
  color: var(--app-quiet);
}

.chats-main .chat-tabs {
  min-width: 0;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  border: 1px solid var(--app-line);
  border-top-color: var(--app-line-bright);
  border-radius: 13px;
  background: #111216;
  scrollbar-width: none;
}

.chats-main .chat-tabs::-webkit-scrollbar {
  display: none;
}

.chats-main .chat-tabs button {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--app-muted);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.chats-main .chat-tabs button:hover {
  color: var(--app-ink);
  background: rgba(255,255,255,.06);
}

.chats-main .chat-tabs button.active {
  background: #8fa8ff;
  color: #0e1020;
}

.chats-main .recent-section {
  padding-top: 48px;
}

.chats-main .section-heading {
  margin-bottom: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.chats-main .section-heading h2 {
  margin: 7px 0 0;
  color: var(--app-ink);
  font: 600 34px/1.08 "Syne", Georgia, serif;
}

.chats-main .chat-count {
  min-width: 34px;
  height: 30px;
  padding: 0 9px;
  display: grid;
  place-items: center;
  border: 1px solid var(--app-line);
  border-radius: 10px;
  color: var(--app-quiet);
  font-size: 10px;
}

.chats-main .chat-list {
  display: grid;
  gap: 10px;
}

.chats-main .chat-row {
  min-height: 102px;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
  padding: 12px;
  border: 1px solid var(--app-line);
  border-top-color: var(--app-line-bright);
  border-radius: 16px;
  background: var(--chat-surface);
  box-shadow: none;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.chats-main .chat-row:hover {
  border-color: #5b5d82;
  background: #1d1d29;
  transform: translateY(-1px);
}

.chats-main .chat-avatar {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--app-line-bright);
  border-radius: 14px;
  background: linear-gradient(145deg, #43517d, #292a40);
  color: var(--app-ink);
  font: 700 24px/1 "Syne", Georgia, serif;
}

.chats-main .chat-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.chats-main .chat-avatar.group {
  position: relative;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  padding: 3px;
}

.chats-main .chat-avatar.group img,
.chats-main .chat-avatar.group span {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #292a40;
  font-size: 11px;
}

.chats-main .chat-copy {
  min-width: 0;
}

.chats-main .chat-kind {
  display: block;
  color: var(--chat-accent);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.chats-main .chat-copy h3 {
  margin: 5px 0 3px;
  overflow: hidden;
  color: var(--app-ink);
  font: 600 17px/1.2 "Syne", Georgia, serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chats-main .chat-copy p {
  margin: 0;
  overflow: hidden;
  color: var(--app-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chats-main .chat-copy time {
  display: block;
  margin-top: 6px;
  color: var(--app-quiet);
  font-size: 9px;
}

.chats-main .chat-row-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.chats-main .open-chat {
  min-height: 38px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--app-line-bright);
  border-radius: 11px;
  background: var(--chat-surface-strong);
  color: var(--app-ink);
  font-size: 10px;
  font-weight: 700;
}

.chats-main .open-chat:hover {
  border-color: #6576bd;
  background: #292a40;
}

.chats-main .delete-chat {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--app-line);
  border-radius: 11px;
  background: transparent;
  color: var(--app-quiet);
}

.chats-main .delete-chat:hover {
  border-color: rgba(239,141,150,.4);
  color: var(--chat-danger);
}

.chats-main .empty-state {
  padding: 70px 24px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--app-line-bright);
  border-radius: 16px;
  background: rgba(255,255,255,.012);
  text-align: center;
}

.chats-main .empty-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid var(--app-line-bright);
  border-radius: 16px;
  background: var(--chat-surface-strong);
  color: var(--chat-accent);
}

.chats-main .empty-state h2 {
  margin: 18px 0 7px;
  color: var(--app-ink);
  font: 600 24px/1.1 "Syne", Georgia, serif;
}

.chats-main .empty-state p {
  margin: 0;
  color: var(--app-muted);
  font-size: 11px;
}

.chats-main .empty-state > div {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.chats-main .group-callout {
  min-height: 180px;
  margin-top: 58px;
  padding: 28px 30px;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  align-items: center;
  gap: 30px;
  border: 1px solid var(--app-line);
  border-radius: 16px;
  background: linear-gradient(110deg, rgba(143,168,255,.12), rgba(136,216,233,.06) 55%, var(--chat-surface));
}

.chats-main .callout-visual {
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chats-main .callout-visual span {
  width: 54px;
  height: 54px;
  margin-left: -11px;
  display: grid;
  place-items: center;
  border: 2px solid #222029;
  border-radius: 50%;
  background: #303452;
  color: var(--chat-accent);
  box-shadow: 0 12px 25px rgba(0,0,0,.22);
}

.chats-main .callout-visual span:nth-child(2) {
  transform: translateY(-13px);
  background: #203a46;
  color: var(--chat-gold);
}

.chats-main .callout-visual span:nth-child(3) {
  transform: translateY(8px);
  background: #302d4c;
  color: #d7d3ff;
}

.chats-main .group-callout h2 {
  margin: 8px 0;
  color: var(--app-ink);
  font: 600 27px/1.08 "Syne", Georgia, serif;
}

.chats-main .group-callout p {
  max-width: 570px;
  margin: 0;
  color: var(--app-muted);
  font-size: 11px;
  line-height: 1.65;
}

.chats-main .text-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--chat-secondary);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.chats-main .text-link:hover {
  color: var(--app-ink);
}

.chats-page > .toast {
  max-width: min(420px, calc(100% - 32px));
  padding: 11px 15px;
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  border: 1px solid var(--app-line-bright);
  border-radius: 10px;
  background: #1d1d29;
  color: var(--app-ink);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.chats-page > .toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1180px) {
  .chats-main {
    margin-left: 210px;
    padding-inline: 24px;
  }

  .chats-main .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .chats-main .header-actions {
    justify-content: flex-start;
  }

  .chats-main .group-callout {
    grid-template-columns: 100px minmax(0, 1fr);
  }

  .chats-main .group-callout .text-link {
    grid-column: 2;
  }
}

@media (max-width: 780px) {
  .chats-main {
    margin-left: 0;
    padding: 0 10px 38px;
  }

  .chats-main .page-header {
    min-height: 136px;
    padding: 26px 4px 16px;
    gap: 22px;
  }

  .chats-main .page-header h1 {
    margin-top: 8px;
    font-size: 36px;
  }

  .chats-main .page-header p {
    font-size: 11px;
  }

  .chats-main .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .chats-main .header-actions a {
    min-width: 0;
    padding-inline: 10px;
  }

  .chats-main .chat-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 15px 0;
  }

  .chats-main .search-field {
    width: 100%;
  }

  .chats-main .chat-tabs {
    width: fit-content;
    max-width: 100%;
  }

  .chats-main .recent-section {
    padding-top: 30px;
  }

  .chats-main .section-heading {
    align-items: flex-start;
  }

  .chats-main .section-heading h2 {
    font-size: 29px;
  }

  .chats-main .chat-row {
    grid-template-columns: 58px minmax(0, 1fr) auto;
    gap: 11px;
    padding: 12px;
  }

  .chats-main .chat-avatar {
    width: 58px;
    height: 58px;
  }

  .chats-main .chat-copy p {
    max-width: 45vw;
  }

  .chats-main .open-chat {
    width: 38px;
    padding: 0;
    justify-content: center;
  }

  .chats-main .open-chat span,
  .chats-main .delete-chat {
    display: none;
  }

  .chats-main .empty-state > div {
    width: 100%;
    max-width: 230px;
    flex-direction: column;
  }

  .chats-main .group-callout {
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .chats-main .callout-visual {
    display: none;
  }

  .chats-main .group-callout .text-link {
    grid-column: 1;
  }

  .chats-page > .toast {
    bottom: 92px;
  }
}

@media (max-width: 430px) {
  .chats-main .page-header h1 {
    font-size: 34px;
  }

  .chats-main .chat-row {
    grid-template-columns: 49px minmax(0, 1fr) auto;
  }

  .chats-main .chat-avatar {
    width: 49px;
    height: 49px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chats-main .primary-button,
  .chats-main .secondary-button,
  .chats-main .chat-row,
  .chats-page > .toast {
    transition-duration: .01ms;
  }
}

/* Compact history and a single explicit action menu per chat. */
.chats-main .page-header{min-height:100px;align-items:center;gap:18px}
.chats-main .page-header h1{margin:0;font-size:34px}
.chats-main .recent-section{padding-top:22px}
.chats-main .section-heading h2{font-size:22px;margin:0}
.chats-main .chat-toolbar{gap:10px}
.chats-main .search-field input{font-size:16px}
.chats-main .chat-kind{text-transform:none;letter-spacing:0;font-size:12px;color:var(--ds-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chats-main .chat-copy p{font-size:13px}
.chats-main .chat-copy time{font-size:11px}
.chats-main .chat-row{position:relative;min-height:92px;grid-template-columns:64px minmax(0,1fr) auto}
.chats-main .chat-avatar{width:64px;height:64px;border:0;background:var(--ds-raised)}
.chats-main :is(.primary-button,.secondary-button,.chat-tabs button,.open-chat){min-height:44px;border-radius:999px}
.chats-main .chat-actions-menu{position:relative;flex:none}
.chat-actions-menu summary{display:grid;place-items:center;width:44px;height:44px;list-style:none;cursor:pointer;border-radius:50%;background:var(--ds-raised);color:var(--ds-text)}
.chat-actions-menu summary::-webkit-details-marker{display:none}
.chat-actions-menu>div{position:absolute;right:0;top:calc(100% + 6px);z-index:8;width:180px;padding:6px;border-radius:18px;background:var(--ds-raised);box-shadow:0 12px 28px #0006}
.chat-actions-menu button{display:flex;align-items:center;gap:8px;min-height:44px;width:100%;padding:8px 10px;border:0;border-radius:12px;background:transparent;color:var(--ds-text);font:inherit;text-align:left}
.chat-actions-menu button:hover{background:var(--ds-hover)}
.chats-main .chat-row:has(details[open]){z-index:5;transform:none}
.rename-chat-dialog{width:min(440px,calc(100% - 24px));max-height:calc(100dvh - 24px);overflow:auto;padding:24px;border:0;border-radius:24px;background:var(--ds-surface);color:var(--ds-text)}
.rename-chat-dialog h2{margin:0 0 10px;font-size:24px}
.rename-chat-dialog p{color:var(--ds-secondary);line-height:1.5}
.rename-chat-dialog label{display:block;margin:18px 0 8px}
.rename-chat-dialog input{width:100%;min-height:48px;padding:10px 12px;font:inherit;font-size:16px;border:0;border-radius:14px;background:var(--ds-raised);color:var(--ds-text)}
.rename-chat-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:22px}
.rename-chat-actions button{min-height:44px;border-radius:999px;padding-inline:18px}
.rename-chat-dialog::backdrop{background:#0009}
@media(max-width:780px){
  .chats-main .page-header{padding:18px 4px 14px;gap:14px;min-height:0}
  .chats-main .page-header h1{font-size:28px}
  .chats-main .header-actions{gap:8px}
  .chats-main .header-actions a{font-size:13px}
  .chats-main .chat-toolbar{padding:12px 0}
  .chats-main .chat-tabs button{font-size:13px}
  .chats-main .recent-section{padding-top:18px}
  .chats-main .section-heading{margin-bottom:12px}
  .chats-main .chat-row{grid-template-columns:46px minmax(0,1fr) 44px;gap:10px;padding:12px 10px}
  .chats-main .chat-avatar{width:46px;height:52px;border-radius:12px}
  .chats-main .chat-copy h3{font-size:16px}
  .chats-main .chat-copy p{max-width:none}
  .chats-main .open-chat{display:none}
  .chats-main .chat-row-actions{gap:0}
  .chats-main .chat-kind{font-size:11px}
  .chats-main .chat-copy time{font-size:11px}
  .chats-main .empty-state{padding:32px 16px}
}

/* History page: keep navigation and the list visible without a tall hero. */
body.memora-ui.chats-page .chats-main .page-header{
  min-height:0;
  padding:4px 0 18px;
  flex-direction:row;
  align-items:center;
  text-align:left;
}
body.memora-ui.chats-page .chats-main .page-header h1{
  margin:0;
  font-size:30px;
  line-height:1.2;
}
body.memora-ui.chats-page .chats-main .header-actions{width:auto;display:flex;justify-content:flex-end}
body.memora-ui.chats-page .chats-main .chat-toolbar{min-height:0;padding:12px 0;gap:12px}
body.memora-ui.chats-page .chats-main .search-field{flex:1 1 340px;width:auto;max-width:540px}
body.memora-ui.chats-page .chats-main .recent-section{padding-top:14px}
body.memora-ui.chats-page .chats-main .section-heading{align-items:center;margin-bottom:10px}
body.memora-ui.chats-page .chats-main .section-heading h2{margin:0;font-size:20px}
body.memora-ui.chats-page .chats-main .chat-row{min-height:82px;padding:10px 8px;grid-template-columns:48px minmax(0,1fr) auto;gap:12px}
body.memora-ui.chats-page .chats-main .chat-avatar{width:48px;height:48px;border-radius:8px}
body.memora-ui.chats-page .chats-main .chat-copy h3{margin:2px 0 3px;font-size:16px}
body.memora-ui.chats-page .chats-main .chat-copy time{margin-top:4px}
body.memora-ui.chats-page .chats-main .empty-state{padding:38px 16px}
body.memora-ui.chats-page .chats-main .empty-state h2{font-size:20px}
body.memora-ui.chats-page .chats-main .chat-tabs button,
body.memora-ui.chats-page .chats-main .chat-row,
body.memora-ui.chats-page .chat-actions-menu summary{
  transition:background-color 180ms ease,color 180ms ease;
}
body.memora-ui.chats-page .chats-main .chat-row:focus-visible{outline:2px solid var(--ds-primary);outline-offset:-2px}
@media(max-width:780px){
  body.memora-ui.chats-page .chats-main .page-header{align-items:flex-start;flex-direction:column;gap:14px;padding:0 0 14px}
  body.memora-ui.chats-page .chats-main .page-header h1{font-size:26px}
  body.memora-ui.chats-page .chats-main .header-actions{width:100%;display:grid;grid-template-columns:1fr 1fr}
  body.memora-ui.chats-page .chats-main .chat-toolbar{align-items:stretch;flex-direction:column}
  body.memora-ui.chats-page .chats-main .search-field{flex:none;width:100%;max-width:none}
  body.memora-ui.chats-page .chats-main .chat-tabs{width:100%;justify-content:space-between}
  body.memora-ui.chats-page .chats-main .chat-tabs button{flex:1}
  body.memora-ui.chats-page .chats-main .chat-row{grid-template-columns:44px minmax(0,1fr) 44px;gap:10px}
  body.memora-ui.chats-page .chats-main .chat-avatar{width:44px;height:44px}
}
@media(prefers-reduced-motion:reduce){
  body.memora-ui.chats-page .chats-main .chat-tabs button,
  body.memora-ui.chats-page .chats-main .chat-row,
  body.memora-ui.chats-page .chat-actions-menu summary{transition-duration:.01ms}
}
