:root {
    --navy: #18275a;
    --navy-dark: #111d44;
    --gold: #caa64b;
    --cream: #f1eee6;
    --text: #1f2933;
    --muted: #667085;
    --line: #ded8c8;
    --white: #fff;
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--cream);
}

header {
    background: linear-gradient(135deg, var(--navy), var(--navy-dark));
    color: white;
    padding: 18px 32px;
    border-bottom: 4px solid var(--gold);
}

h1,
h2,
h3 {
    margin: 0;
}

h1 {
    font-family: Georgia, serif;
    font-size: 30px;
}

.eyebrow {
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: .22em;
    font-weight: 800;
    font-size: 11px;
    margin-bottom: 5px;
}

main {
    height: calc(100vh - 92px);
    padding: 18px;
    overflow: hidden;
}

.panel {
    max-width: 760px;
    margin: 0 auto;
    background: white;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 12px 40px rgba(17, 29, 68, .08);
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-top: 24px;
}

.account-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fffaf0;
    padding: 22px;
    cursor: pointer;
    transition: .15s ease;
}

.account-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(17, 29, 68, .12);
}

.account-card h3 {
    font-family: Georgia, serif;
    color: var(--navy-dark);
    font-size: 28px;
    margin-bottom: 12px;
}

.stats {
    display: grid;
    gap: 6px;
    color: #475467;
    font-size: 14px;
}

.hidden {
    display: none !important;
}

.layout {
    height: 100%;
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 18px;
}

.sidebar,
.viewer {
    background: white;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(17, 29, 68, .08);
    min-height: 0;
}

.sidebar {
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-right: 1px solid var(--line);
    overflow: hidden;
    height: 100%;
    padding: 0;
}

.sidebar-results-count {
    color: var(--muted);
    font-size: 14px;
    margin-top: 12px;
}

.sidebar-results-count:empty {
    display: none;
}

.side-head {
    flex: 0 0 auto;
    background: var(--white);
    padding: 18px 16px 10px;
    border-bottom: 1px solid var(--line);
    z-index: 2;
}

.sidebar-results-pane {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.side-head h1 {
    font-size: 22px;
    margin: 0 0 18px;
    line-height: 1.15;
}

.side-section {
    margin: 0;
}

.account-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.icon-back-button {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 999px;
    background: var(--navy);
    color: white;
    cursor: pointer;
    font-weight: 800;
    font-size: 18px;
    line-height: 1;
}

#account-title {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
}

.side-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 7px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.searchbox {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f7f7;
    color: var(--text);
    font-size: 15px;
}

.searchbox:focus {
    outline: none;
    border-color: var(--gold);
    background: white;
}

.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.search-header .side-label {
    margin: 0;
}

.search-mode-toggle {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
    background: white;
    flex: 0 0 auto;
}

.search-mode-toggle label {
    cursor: pointer;
}

.search-mode-toggle input {
    display: none;
}

.search-mode-toggle span {
    display: block;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    line-height: 1;
}

.search-mode-toggle label + label span {
    border-left: 1px solid var(--line);
}

.search-mode-toggle input:checked + span {
    background: var(--navy);
    color: white;
}

.conversation-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.conversation-toolbar.hidden {
  display: none;
}

.conversation-tabs {
  display: inline-flex;
  width: fit-content;
  overflow: hidden;
  border: 1px solid #d9cfbd;
  border-radius: 999px;
  background: #fff;
}

.conversation-tab,
.attachment-filter {
  min-height: 30px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.conversation-tab {
  border: 0;
  border-right: 1px solid #d9cfbd;
  border-radius: 0;
  background: transparent;
  color: #5d6a80;
  padding: 6px 14px;
}

.conversation-tab:last-child {
  border-right: 0;
}

.conversation-tab:hover {
  background: #f7f2e8;
}

.conversation-tab.active {
  background: #182a63;
  color: #fff;
}

.side-divider {
    height: 1px;
    background: var(--line);
    margin: 16px 0 18px;
}

.status {
    color: var(--muted);
    font-size: 14px;
    margin-top: 12px;
}

.back-button {
    align-self: flex-start;
    border: none;
    background: var(--navy);
    color: white;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 700;
    margin-bottom: 18px;
}

.search {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
}







.conversation-list {
    overflow: auto;
    display: block;
    padding: 0;
}

.conversation-item {
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    padding: 12px 16px;
    cursor: pointer;
    background: #fff;
}

.conversation-item:hover,
.conversation-item.active {
    border-color: var(--gold);
    background: #fffaf0;
}

.conversation-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.conversation-main {
    min-width: 0;
}

.conversation-title {
    font-weight: 800;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-main .meta {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-date {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    padding-top: 2px;
}




.meta,
.muted {
    color: var(--muted);
    font-size: 14px;
}

.viewer {
    display: flex;
    flex-direction: column;
}

.conversation-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px 22px 12px;
    border-bottom: 1px solid var(--line);
    background: #fffaf0;
}

#conversation-header-content h2 {
    margin: 0 0 2px;
}

#conversation-header-content .muted {
    margin: 0;
    font-size: 15px;
}

#conversation-count {
    margin: 12px 0 0;
}

#conversation-pane {
    display: block;
}

body.sidebar-global-mode #conversation-pane {
    display: none;
}

body.sidebar-conversations-mode #global-results-pane {
    display: none;
}

#message-search {
    width: 100%;
    max-width: 500px;
    align-self: flex-start;
}

.messages {
    padding: 22px;
    overflow: auto;
    display: grid;
    gap: 14px;
}

.conversation-list,
.messages {
    min-height: 0;
    overflow: auto;
}

.messages-inner {
    max-width: 900px;
    display: grid;
    gap: 14px;
}

.message {
    max-width: 600px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: white;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message.outgoing {
    margin-left: auto;
    background: #d9fdd3;
    border-color: #b7e8aa;
}

.message.system-message {
    color: var(--muted);
    font-style: italic;
}

.message .top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.message-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-search-row .search-wrapper {
    width: 100%;
    max-width: 500px;
    flex: 1;
}

.message-search-row .search {
    width: 100%;
    max-width: 500px;
    align-self: flex-start;
}

.message-search-nav {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
}

.message-search-nav button {
    border: 1px solid var(--line);
    background: white;
    color: var(--navy);
    border-radius: 999px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-weight: 800;
}

.message-search-nav button:hover {
    border-color: var(--gold);
    background: #fffaf0;
}

.search-wrapper {
    position: relative;
    flex: 1;
}

.search-wrapper input {
    width: 100%;
    padding-right: 34px;
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;

    border: none;
    border-radius: 50%;

    background: #b8bec7;
    color: white;

    font-size: 13px;
    font-weight: 700;
    line-height: 18px;

    cursor: pointer;
    padding: 0;

    transition: background .15s ease, opacity .15s ease;
}

.search-clear:hover {
    background: #8f98a5;
}

.search-clear.hidden {
    display: none;
}

.load-more-button {
    justify-self: center;
    border: 1px solid var(--line);
    background: #fffaf0;
    color: var(--navy);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 700;
    cursor: pointer;
    margin: 8px 0;
}

.load-more-button:hover {
    border-color: var(--gold);
    background: white;
}

.sender {
    font-weight: 800;
    color: var(--navy-dark);
}

.text {
    white-space: pre-wrap;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.attachments {
    margin-top: 10px;
    display: grid;
    gap: 6px;
}

.attachment {
    font-size: 13px;
    padding: 8px;
    background: #f7f4ec;
    border-radius: 8px;
}

.quote {
    border-left: 4px solid var(--muted);
    color: var(--muted);
    padding: 6px 8px;
    margin: 4px 0 8px;
    background: rgba(128, 128, 128, .12);
    border-radius: 7px;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.reactions {
    font-size: 15px;
    margin-top: 6px;
}

.edited-indicator {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.empty {
    color: var(--muted);
    font-style: italic;
}

.attachment-card {
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(128, 128, 128, .08);
    max-width: 100%;
    overflow: hidden;
}

.attachment-head {
    display: flex;
    gap: 9px;
    align-items: flex-start;
}

.attachment-icon {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--line);
    font-size: 18px;
}

.attachment-main {
    min-width: 0;
    flex: 1;
}

.attachment-title {
    font-weight: 700;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.attachment-type,
.attachment-path {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.attachment-meta {
    color: var(--muted);
    font-size: 12px;
    margin-top: 7px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.attachment-pill {
    border: 1px solid var(--line);
    background: white;
    border-radius: 999px;
    padding: 3px 7px;
}

.attachment-tech {
    margin-top: 8px;
}

.attachment-tech summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 12px;
}

.attachment-preview {
    margin-top: 8px;
}

.attachment-preview img {
    max-width: min(420px, 100%);
    max-height: 320px;
    border-radius: 12px;
    border: 1px solid var(--line);
    display: block;
    cursor: pointer;
}

.attachment-preview video {
    max-width: min(520px, 100%);
    border-radius: 12px;
    border: 1px solid var(--line);
    display: block;
}

.attachment-preview audio {
    width: min(420px, 100%);
    display: block;
}

.attachment-actions {
    margin-top: 9px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.attachment-actions a {
    display: inline-block;
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 9px;
    color: var(--text);
    background: white;
    font-size: 12px;
}

.attachment-actions a:hover {
    background: var(--cream);
}

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .82);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 24px;
}

.lightbox.open {
    display: flex;
}

.lightbox img {
    max-width: 95vw;
    max-height: 92vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 18px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .95);
    color: #111;
    padding: 8px 12px;
    font-size: 16px;
    cursor: pointer;
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10001;
  border: 0;
  background: rgba(255, 255, 255, 0.85);
  color: #182a63;
  font-size: 48px;
  line-height: 1;
  width: 54px;
  height: 70px;
  border-radius: 14px;
  cursor: pointer;
}

.lightbox-prev {
  left: 22px;
}

.lightbox-next {
  right: 22px;
}

.lightbox-nav:hover {
  background: #fff;
}

.lightbox-nav.hidden {
  display: none;
}

.lightbox-content {
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-content img {
  max-width: 92vw;
  max-height: calc(92vh - 86px);
  object-fit: contain;
}

.lightbox-info {
  width: min(92vw, 1100px);
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: #182a63;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.lightbox-info.hidden {
  display: none;
}

.lightbox-title {
  font-weight: 800;
  font-size: 14px;
  word-break: break-word;
}

.lightbox-meta {
  font-size: 12px;
  color: #5d6a80;
  margin-top: 3px;
}

.lightbox-jump {
  border: 1px solid #d9cfbd;
  background: #182a63;
  color: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.lightbox-jump:hover {
  background: #223a86;
}

.date-separator {
    text-align: center;
    margin: 24px 0 18px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.date-separator span {
    background: white;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px;
}

mark {
    background: #ffe066;
    color: #111;
}

.jump-highlight {
    outline: 3px solid var(--gold);
    box-shadow: 0 0 0 6px rgba(202, 166, 75, .25);
    transition: outline .2s ease, box-shadow .2s ease;
}

.global-results {
    padding: 0;
    border-top: 0;
}

.global-result {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}

.global-result:hover {
    background: #fffaf0;
}

.global-results:empty {
    display: none;
}

.global-result-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 3px;
}

.global-result-meta {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.global-result-snippet {
    font-size: 13px;
    line-height: 1.35;
}

#global-search-status:empty {
    display: none;
}

body.conversation-mode header {
    display: none;
}

body.conversation-mode main {
    height: 100vh;
    padding: 18px;
}

body.conversation-mode .layout {
    height: 100%;
}

.attachment-browser {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 18px;
}

.attachment-browser-item {
  border: 1px solid #d9cfbd;
  border-radius: 14px;
  background: #fffaf1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.attachment-browser-preview {
  height: 180px;
  background: #f4ead9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.attachment-browser-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  display: block;
}

.attachment-browser-icon {
  font-size: 42px;
  opacity: 0.75;
}

.attachment-browser-meta {
  padding: 12px;
  font-size: 13px;
  line-height: 1.35;
}

.attachment-browser-meta strong {
  display: block;
  margin-bottom: 4px;
  word-break: break-word;
}

.attachment-browser-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.attachment-browser-actions a,
.attachment-browser-actions button {
  border: 1px solid #d9cfbd;
  background: #fff;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: #182a63;
  text-decoration: none;
  cursor: pointer;
}

.attachment-browser-actions a:hover,
.attachment-browser-actions button:hover {
  background: #f7f2e8;
}

.attachment-browser-shell {
  display: flex;
  flex-direction: column;
}

.attachment-filter-row {
  display: flex;
}

.attachment-filter-row.hidden {
  display: none;
}

.attachment-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.attachment-filter {
  border: 1px solid #d9cfbd;
  border-radius: 999px;
  background: #fff;
  color: #5d6a80;
}

.attachment-filter:hover {
  background: #f7f2e8;
}

.attachment-filter.active {
  background: #182a63;
  color: #fff;
  border-color: #182a63;
}

.attachment-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 4px;
    line-height: 1.25;
    word-break: break-word;
}

.attachment-name-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.attachment-browser-media,
.attachment-browser-pdf {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}

.attachment-browser-pdf {
  background: #fff;
}

.attachment-browser-audio {
  width: 100%;
  height: 100%;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.attachment-browser-audio audio {
  width: 100%;
}

.attachment-status {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
}

.attachment-status.available {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.attachment-status.missing {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
}

@media(max-width:900px) {
    .layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .sidebar,
    .viewer {
        min-height: 420px;
    }
}