:root {
  --font-sans: "Avenir Next", Avenir, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --brand: #00e577;
  --danger: #e9606e;
  --warning: #c78a35;
  font-family: var(--font-sans);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #09090a;
  --chrome: #0c0c0d;
  --panel: #101011;
  --panel-raised: #151516;
  --panel-strong: #1b1b1d;
  --panel-hover: #202023;
  --line: #2b2b2e;
  --line-soft: #202023;
  --ink: #f3f3f0;
  --ink-strong: #ffffff;
  --muted: #8c8c93;
  --muted-strong: #c2c2c7;
  --control: #141416;
  --selection: #f1f1ee;
  --selection-ink: #171719;
  --selection-muted: #66666c;
  --bubble: #141917;
  --bubble-line: #27352f;
  --bubble-out: #15382d;
  --bubble-out-ink: #cef4e5;
  --shadow: rgba(0, 0, 0, .45);
  --accent: #63d9ad;
  --accent-strong: #23bd87;
  --accent-soft: #10251e;
  --accent-line: #245c49;
}

:root[data-theme="light"] {
  color-scheme: light;
  --canvas: #ecece8;
  --chrome: #ffffff;
  --panel: #f6f6f3;
  --panel-raised: #ffffff;
  --panel-strong: #ebebe7;
  --panel-hover: #e5e5e1;
  --line: #d4d4cf;
  --line-soft: #e1e1dc;
  --ink: #1a1a1c;
  --ink-strong: #050506;
  --muted: #6f6f74;
  --muted-strong: #454549;
  --control: #ffffff;
  --selection: #1b1b1d;
  --selection-ink: #ffffff;
  --selection-muted: #b9b9bd;
  --bubble: #ffffff;
  --bubble-line: #d7d7d2;
  --bubble-out: #165b43;
  --bubble-out-ink: #ffffff;
  --shadow: rgba(15, 15, 18, .14);
  --accent: #087553;
  --accent-strong: #056345;
  --accent-soft: #e1f3eb;
  --accent-line: #a6d4c2;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--canvas); color: var(--ink); margin: 0; overflow: hidden; }
button, input, select { color: inherit; font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .5; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.app-shell { background: var(--canvas); display: grid; grid-template-rows: 58px minmax(0, 1fr); height: 100dvh; min-height: 620px; }
.app-topbar { align-items: center; background: var(--chrome); border-bottom: 1px solid var(--line); display: grid; gap: 28px; grid-template-columns: 210px minmax(0, 1fr) auto; padding: 0 16px; position: relative; z-index: 30; }
.brand { align-items: center; color: var(--ink); display: flex; gap: 10px; min-width: 0; text-decoration: none; }
.brand img { height: 30px; object-fit: contain; width: 30px; }
.brand > span { display: flex; flex-direction: column; min-width: 0; }
.brand strong { font-size: 13px; letter-spacing: -.015em; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 9px; margin-top: 3px; }
.top-navigation { align-items: center; display: flex; gap: 4px; height: 100%; }
.top-link { align-items: center; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--muted); display: inline-flex; font-size: 11px; font-weight: 700; gap: 7px; min-height: 32px; padding: 0 11px; text-decoration: none; }
.top-link span { font-size: 13px; }
.top-link:hover { background: var(--panel-raised); color: var(--ink); }
.top-link.is-active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

.profile-menu-wrap { position: relative; }
.profile-trigger { align-items: center; background: transparent; border: 1px solid transparent; border-radius: var(--radius-md); display: grid; gap: 8px; grid-template-columns: auto minmax(0, 1fr) auto; min-height: 42px; padding: 4px 7px; text-align: left; width: 188px; }
.profile-trigger:hover, .profile-trigger[aria-expanded="true"] { background: var(--panel-raised); border-color: var(--line); }
.rail-avatar, .workspace-avatar, .contact-avatar, .inspector-avatar, .conversation-avatar, .contact-card-avatar { align-items: center; background: var(--panel-strong); border: 1px solid var(--line); color: var(--ink); display: inline-flex; flex: 0 0 auto; font-weight: 800; justify-content: center; overflow: hidden; position: relative; text-transform: uppercase; }
.contact-avatar img, .inspector-avatar img, .conversation-avatar img, .contact-card-avatar img { height: 100%; inset: 0; object-fit: cover; position: absolute; width: 100%; }
.rail-avatar { border-radius: 8px; font-size: 9px; height: 30px; width: 30px; }
.profile-identity { display: flex; flex-direction: column; min-width: 0; }
.profile-identity strong { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-identity small { color: var(--muted); font-size: 8px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-chevron { color: var(--muted); font-size: 12px; transform: translateY(-1px); }
.profile-menu { background: var(--panel-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 20px 60px var(--shadow); padding: 12px; position: absolute; right: 0; top: calc(100% + 7px); width: 286px; }
.profile-menu-heading { display: flex; flex-direction: column; padding: 2px 2px 10px; }
.profile-menu-heading strong { font-size: 11px; }
.profile-menu-heading small { color: var(--muted); font-size: 9px; margin-top: 2px; }
.theme-selector { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 9px; display: grid; gap: 3px; grid-template-columns: repeat(3, 1fr); padding: 3px; }
.theme-selector button { background: transparent; border: 0; border-radius: 6px; color: var(--muted); font-size: 9px; font-weight: 750; min-height: 30px; }
.theme-selector button[aria-checked="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); color: var(--accent); }
.logout-button { background: transparent; border: 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; font-weight: 700; margin-top: 11px; padding: 11px 3px 1px; text-align: left; width: 100%; }
.logout-button:hover { color: var(--ink); }

.app-workspace { display: grid; grid-template-columns: clamp(320px, 21vw, 370px) minmax(420px, 1fr) 310px; min-height: 0; overflow: hidden; position: relative; }
.conversation-pane { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.pane-header { align-items: center; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; min-height: 63px; padding: 11px 14px; }
.pane-header p, .auth-kicker, .inspector-profile p { color: var(--accent); font-size: 7px; font-weight: 850; letter-spacing: .16em; margin: 0 0 4px; }
.pane-header h1 { color: var(--accent); font-size: 19px; letter-spacing: -.035em; line-height: 1; margin: 0; }
.header-actions { align-items: center; display: flex; gap: 6px; }
.icon-button, .secondary-button, .filter-button, .load-more, .history-action button, .mobile-back { background: var(--panel-raised); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--muted-strong); font-size: 9px; font-weight: 750; min-height: 31px; padding: 6px 9px; }
.icon-button { font-size: 15px; padding: 2px; width: 31px; }
.header-actions .icon-button, .header-actions .secondary-button { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.icon-button:hover, .secondary-button:hover, .filter-button:hover, .load-more:hover, .history-action button:hover, .mobile-back:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.workspace-summary { align-items: center; display: flex; justify-content: space-between; padding: 11px 14px 7px; }
.workspace-summary > div { align-items: center; display: flex; gap: 8px; min-width: 0; }
.workspace-summary > div > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.workspace-summary strong { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-summary small { color: var(--muted); font-size: 8px; margin-top: 2px; }
.workspace-avatar { border-radius: 8px; font-size: 9px; height: 31px; width: 31px; }
.count-badge { background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 999px; color: var(--accent); font-size: 8px; font-weight: 850; padding: 4px 7px; }

.filters { border-bottom: 1px solid var(--line-soft); padding: 6px 14px 11px; }
.search-field { display: flex; flex-direction: column; gap: 4px; }
.search-field > label, .filter-row label > span, .management-filters label > span, .date-jump-form > label, .inspector-search > label { color: var(--muted); font-size: 8px; font-weight: 750; }
.search-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.search-field input, .filter-row select, .management-filters select, .date-jump-form input, .inspector-search input { background: var(--control); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); min-height: 34px; outline: 0; padding: 7px 9px; width: 100%; }
.search-field input { font-size: 11px; letter-spacing: -.01em; }
.search-control input, .inspector-search div input, .date-jump-form div input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.search-control button, .inspector-search div button, .date-jump-form div button { background: var(--panel-strong); border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--muted-strong); font-size: 8px; font-weight: 800; padding: 0 9px; }
.search-control button:hover, .inspector-search div button:hover, .date-jump-form div button:hover { background: var(--panel-hover); color: var(--ink); }
.search-control button, .inspector-search div button, .date-jump-form div button { border-color: var(--accent-line); color: var(--accent); }
input::placeholder { color: var(--muted); opacity: .75; }
input:focus, select:focus { border-color: var(--accent-line); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 14%, transparent); position: relative; z-index: 1; }
.search-scope, .conversation-kind-filter { background: var(--canvas); border: 1px solid var(--line-soft); border-radius: 8px; display: grid; gap: 2px; margin-top: 6px; padding: 2px; }
.search-scope { grid-template-columns: repeat(2, 1fr); }
.search-scope button, .conversation-kind-filter button { background: transparent; border: 0; border-radius: 5px; color: var(--muted); font-size: 8px; font-weight: 800; min-height: 25px; }
.search-scope button[aria-pressed="true"], .conversation-kind-filter button[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); color: var(--accent); }
.management-filters { display: grid; gap: 7px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 8px; }
.management-filters label, .filter-row label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.management-filters select, .filter-row select { font-size: 9px; min-height: 33px; }
.filter-row { align-items: end; display: grid; gap: 7px; grid-template-columns: minmax(0, 1fr) auto; margin-top: 8px; }
.filter-button { min-height: 33px; }
.filter-button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.conversation-kind-filter { grid-template-columns: repeat(3, 1fr); margin-top: 8px; }
.conversation-kind-filter button { min-height: 27px; padding: 5px; }

.conversation-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 7px 8px; scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
.conversation-item { background: transparent; border: 1px solid transparent; border-radius: var(--radius-md); color: inherit; display: grid; gap: 8px; grid-template-columns: auto minmax(0, 1fr) auto; margin: 1px 0; padding: 9px 8px; text-align: left; width: 100%; }
.conversation-item:hover { background: var(--panel-raised); }
.conversation-item.is-active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.conversation-item.is-search-result { border-color: var(--line-soft); margin-bottom: 4px; }
.conversation-item.is-search-result .conversation-copy > p { -webkit-box-orient: vertical; -webkit-line-clamp: 2; display: -webkit-box; line-height: 1.4; white-space: normal; }
.conversation-avatar { border-radius: 10px; font-size: 9px; height: 36px; width: 36px; }
.conversation-item.is-active .conversation-avatar { background: color-mix(in srgb, var(--accent) 9%, transparent); border-color: var(--accent-line); color: var(--accent); }
.conversation-copy { min-width: 0; }
.conversation-title { align-items: center; display: flex; gap: 6px; }
.conversation-title strong { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-copy > p { color: var(--muted); font-size: 9px; line-height: 1.3; margin: 4px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-owner { color: var(--muted-strong); display: block; font-size: 7px; font-weight: 750; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-tags { display: flex; gap: 4px; margin-top: 5px; overflow: hidden; }
.conversation-tags span, .metadata-chip { background: var(--panel-strong); border: 1px solid var(--line); border-radius: 999px; color: var(--muted-strong); display: inline-flex; font-size: 7px; font-weight: 750; max-width: 110px; overflow: hidden; padding: 2px 5px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item.is-active .conversation-copy > p, .conversation-item.is-active .conversation-owner, .conversation-item.is-active .conversation-meta time { color: color-mix(in srgb, var(--accent) 62%, var(--muted)); }
.conversation-item.is-active .conversation-tags span { background: color-mix(in srgb, var(--accent) 8%, transparent); border-color: var(--accent-line); color: var(--accent); }
.conversation-meta { align-items: flex-end; display: flex; flex-direction: column; gap: 6px; }
.conversation-meta time { color: var(--muted); font-size: 7px; white-space: nowrap; }
.unread-badge { align-items: center; background: var(--ink); border-radius: 999px; color: var(--panel); display: flex; font-size: 7px; font-weight: 900; height: 16px; justify-content: center; min-width: 16px; padding: 0 4px; }
.conversation-item.is-active .unread-badge { background: var(--accent); color: var(--accent-soft); }
.search-result-context { color: var(--muted-strong); font-size: 7px; font-weight: 800; margin-top: 5px; }
.deleted-result-badge { background: rgba(199, 138, 53, .12); border: 1px solid rgba(199, 138, 53, .4); border-radius: 999px; color: var(--warning); display: inline-flex; font-size: 6px; letter-spacing: .03em; margin-right: 4px; padding: 2px 4px; text-transform: uppercase; }
.load-more { margin: 0 14px 10px; }

.thread-pane { background: var(--canvas); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.thread-header { align-items: center; background: var(--chrome); border-bottom: 1px solid var(--line); display: grid; gap: 9px; grid-template-columns: auto minmax(0, 1fr) auto; min-height: 63px; padding: 9px 16px; }
.contact-avatar { border-radius: 10px; font-size: 10px; height: 38px; width: 38px; }
.thread-identity { display: flex; flex-direction: column; min-width: 0; }
.thread-identity strong { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-identity small { color: var(--muted); font-size: 8px; margin-top: 3px; }
.thread-metadata { align-items: center; display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.metadata-chip.stage { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.mobile-back { display: none; }
.thread-empty { align-items: center; display: flex; flex: 1; flex-direction: column; justify-content: center; padding: 28px; text-align: center; }
.thread-empty img { filter: grayscale(1); height: 54px; opacity: .22; width: 54px; }
.thread-empty h2 { font-size: 17px; letter-spacing: -.03em; margin: 15px 0 0; }
.thread-empty p { color: var(--muted); font-size: 10px; line-height: 1.55; margin: 7px 0 0; max-width: 360px; }
.thread-content { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.history-action { display: flex; justify-content: center; min-height: 38px; padding: 7px; }
.history-action button { min-height: 27px; }
.history-newer { min-height: 34px; padding-block: 4px; }
.message-list { display: flex; flex: 1; flex-direction: column; gap: 6px; min-height: 0; overflow-y: auto; padding: 7px clamp(18px, 4vw, 58px) 18px; scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
.message { align-self: flex-start; background: var(--bubble); border: 1px solid var(--bubble-line); border-radius: 11px; color: var(--ink); max-width: min(650px, 78%); padding: 8px 10px 6px; }
.message.has-image { max-width: min(760px, 88%); width: min(760px, 88%); }
.message.is-outbound { align-self: flex-end; background: var(--bubble-out); border-color: var(--bubble-out); color: var(--bubble-out-ink); }
.message.is-system { align-self: center; color: var(--muted); max-width: 86%; text-align: center; }
.message.is-preview { border-style: dashed; margin-top: auto; opacity: .9; }
.message.is-highlighted { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.message.is-deleted { border-color: color-mix(in srgb, var(--warning) 55%, var(--bubble-line)); }
.message-deleted-state { color: var(--warning); display: block; font-size: 7px; font-weight: 800; margin-bottom: 5px; }
.message-sync-state { color: var(--muted-strong); display: block; font-size: 7px; font-weight: 800; margin-bottom: 5px; }
.message-refresh-hint { align-self: center; color: var(--muted); font-size: 7px; margin: 1px 0 auto; }
.message-sender { color: var(--accent); display: block; font-size: 7px; font-weight: 800; margin-bottom: 4px; }
.message p { font-size: 10px; line-height: 1.45; margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.message-attachment { background: color-mix(in srgb, currentColor 5%, transparent); border: 1px solid color-mix(in srgb, currentColor 12%, transparent); border-radius: 8px; margin-bottom: 6px; overflow: hidden; }
.message-attachment img, .message-attachment video { background: #050506; display: block; max-height: 520px; object-fit: contain; width: 100%; }
.media-open-button { background: #050506; border: 0; color: #fff; cursor: zoom-in; display: block; padding: 0; position: relative; width: 100%; }
.media-open-hint { background: rgba(5, 5, 6, .78); border: 1px solid rgba(255, 255, 255, .22); border-radius: 999px; bottom: 8px; color: #fff; font-size: 8px; font-weight: 800; opacity: 0; padding: 5px 8px; pointer-events: none; position: absolute; right: 8px; transform: translateY(3px); transition: opacity .15s ease, transform .15s ease; }
.media-open-button:hover .media-open-hint, .media-open-button:focus-visible .media-open-hint { opacity: 1; transform: translateY(0); }
.message-attachment audio { display: block; margin: 8px; max-width: calc(100% - 16px); min-width: min(260px, calc(100vw - 90px)); }
.message-media-meta { align-items: center; display: flex; flex-wrap: wrap; font-size: 8px; gap: 6px; padding: 7px 8px; }
.message-media-meta span { color: var(--accent); font-weight: 800; }
.message-media-meta strong { font-size: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-media-meta small { color: var(--muted); margin-left: auto; }
.media-unavailable { color: var(--muted); display: block; font-size: 8px; line-height: 1.4; padding: 10px; }
.message-attachment.is-placeholder { border-style: dashed; }
.message footer { align-items: center; color: var(--muted); display: flex; font-size: 7px; gap: 4px; justify-content: flex-end; margin-top: 4px; }
.message.is-outbound footer { color: color-mix(in srgb, var(--bubble-out-ink) 60%, transparent); }
.read-only-note { align-items: center; background: var(--chrome); border-top: 1px solid var(--line); display: flex; gap: 9px; min-height: 46px; padding: 8px 16px; }
.read-only-note span { background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 999px; color: var(--accent); font-size: 7px; font-weight: 850; padding: 4px 7px; white-space: nowrap; }
.read-only-note p { color: var(--muted); font-size: 8px; margin: 0; }

.contact-inspector { background: var(--panel); border-left: 1px solid var(--line); min-width: 0; overflow-y: auto; scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
.inspector-empty { align-items: center; color: var(--muted); display: flex; flex-direction: column; height: 100%; justify-content: center; padding: 24px; text-align: center; }
.inspector-empty-mark { align-items: center; border: 1px solid var(--line); border-radius: 50%; display: flex; font-family: Georgia, serif; font-size: 12px; height: 30px; justify-content: center; margin-bottom: 10px; width: 30px; }
.inspector-empty strong { color: var(--ink); font-size: 11px; }
.inspector-empty p { font-size: 9px; line-height: 1.5; margin: 6px 0 0; max-width: 210px; }
.inspector-content { min-height: 100%; }
.inspector-profile { align-items: center; background: var(--chrome); border-bottom: 1px solid var(--line); display: flex; gap: 10px; min-height: 82px; padding: 13px 14px; }
.inspector-avatar { border-radius: 11px; font-size: 11px; height: 42px; width: 42px; }
.inspector-profile > div { display: flex; flex-direction: column; min-width: 0; }
.inspector-profile strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inspector-profile small { color: var(--muted); font-size: 8px; margin-top: 3px; }
.inspector-section { border-bottom: 1px solid var(--line-soft); padding: 13px 14px; }
.inspector-section h2 { color: var(--accent); font-size: 8px; font-weight: 850; letter-spacing: .08em; margin: 0 0 10px; text-transform: uppercase; }
.inspector-data { display: flex; flex-direction: column; margin: 0; }
.inspector-data > div { align-items: baseline; display: grid; gap: 10px; grid-template-columns: minmax(78px, .75fr) minmax(0, 1.25fr); padding: 5px 0; }
.inspector-data dt { color: var(--muted); font-size: 8px; }
.inspector-data dd { color: var(--ink); font-size: 8px; font-weight: 700; margin: 0; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.inspector-data dd.mono { direction: rtl; font-family: var(--font-mono); font-size: 7px; font-weight: 500; }
.inspector-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.inspector-labels span { background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 999px; color: var(--accent); font-size: 7px; font-weight: 750; padding: 3px 6px; }
.inspector-labels span.is-empty { background: transparent; border-style: dashed; color: var(--muted); }
.inspector-search, .date-jump-form { display: flex; flex-direction: column; gap: 4px; }
.inspector-search > div, .date-jump-form > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.inspector-search input, .date-jump-form input { font-size: 9px; min-height: 33px; }
.date-jump-form { margin-top: 9px; }
.latest-button { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); margin-top: 7px; width: 100%; }
.inspector-search-results { background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; margin-top: 7px; max-height: 180px; overflow-y: auto; padding: 3px; }
.inspector-search-results button { background: transparent; border: 0; border-bottom: 1px solid var(--line-soft); color: var(--ink); display: flex; flex-direction: column; padding: 7px; text-align: left; width: 100%; }
.inspector-search-results button:last-child { border-bottom: 0; }
.inspector-search-results button:hover { background: var(--panel-raised); }
.inspector-search-results button span { -webkit-box-orient: vertical; -webkit-line-clamp: 2; display: -webkit-box; font-size: 8px; line-height: 1.35; overflow: hidden; }
.inspector-search-results button small { color: var(--muted); font-size: 7px; margin-top: 4px; }
.inspector-search-state { color: var(--muted); font-size: 8px; line-height: 1.4; padding: 8px; text-align: center; }
.inspector-search-state.is-error { color: var(--danger); }

.empty-list, .error-list { align-items: center; color: var(--muted); display: flex; flex-direction: column; font-size: 9px; justify-content: center; min-height: 190px; padding: 24px; text-align: center; }
.empty-list strong, .error-list strong { color: var(--ink); font-size: 10px; margin-bottom: 5px; }
.error-list strong { color: var(--danger); }
.skeleton-row { align-items: center; display: grid; gap: 8px; grid-template-columns: 36px minmax(0, 1fr); padding: 10px 8px; }
.skeleton-row i, .skeleton-row span { animation: skeleton-pulse 1.25s ease-in-out infinite alternate; background: var(--panel-strong); border-radius: 6px; display: block; }
.skeleton-row i { height: 36px; }
.skeleton-row span { height: 7px; margin: 5px 0; width: 80%; }
.skeleton-row span:last-child { opacity: .65; width: 58%; }
.message-list .skeleton-row { align-self: flex-start; width: 55%; }
.message-list .skeleton-row.is-wide { width: 68%; }
.message-list .skeleton-row.is-right { align-self: flex-end; }
@keyframes skeleton-pulse { to { opacity: .45; } }

.auth-screen { align-items: center; background: var(--canvas); display: flex; inset: 0; justify-content: center; min-height: 100dvh; padding: 20px; position: fixed; }
.auth-card { background: var(--panel-raised); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 28px 90px var(--shadow); color: var(--ink); overflow: hidden; width: min(400px, 100%); }
.auth-brand { align-items: center; background: var(--chrome); border-bottom: 1px solid var(--line); display: flex; gap: 10px; padding: 15px 18px; }
.auth-brand img { height: 32px; width: 32px; }
.auth-brand span { display: flex; flex-direction: column; }
.auth-brand strong { font-size: 12px; }
.auth-brand small { color: var(--muted); font-size: 8px; margin-top: 2px; }
.auth-body { padding: 23px; }
.auth-body form { display: flex; flex-direction: column; }
.auth-body h1 { font-size: 23px; letter-spacing: -.045em; line-height: 1.06; margin: 0; }
.auth-body form > p:not(.auth-kicker) { color: var(--muted); font-size: 10px; line-height: 1.55; margin: 8px 0 17px; }
.auth-body label { color: var(--muted-strong); font-size: 8px; font-weight: 800; margin: 9px 0 4px; }
.auth-body input { background: var(--control); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); min-height: 39px; outline: 0; padding: 8px 10px; }
.primary-button { background: var(--accent-strong); border: 1px solid var(--accent-strong); border-radius: 8px; color: #ffffff; font-size: 10px; font-weight: 850; margin-top: 15px; min-height: 39px; padding: 9px 12px; }
.primary-button:hover { opacity: .88; }
.text-button { align-self: center; background: transparent; border: 0; color: var(--muted-strong); font-size: 8px; font-weight: 800; margin-top: 11px; }
.auth-error { background: color-mix(in srgb, var(--danger) 10%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); border-radius: 8px; color: var(--danger); font-size: 8px; line-height: 1.4; margin-top: 9px; padding: 7px 8px; }
.toast { background: var(--selection); border: 1px solid var(--selection); border-radius: 8px; bottom: 14px; box-shadow: 0 14px 40px var(--shadow); color: var(--selection-ink); font-size: 9px; font-weight: 750; left: 50%; max-width: min(430px, calc(100vw - 32px)); padding: 9px 11px; position: fixed; transform: translateX(-50%); z-index: 100; }
.media-viewer { background: var(--chrome); border: 1px solid var(--accent-line); border-radius: 14px; box-shadow: 0 30px 110px rgba(0, 0, 0, .7); color: var(--ink); height: min(94dvh, 1000px); margin: auto; max-height: none; max-width: none; overflow: hidden; padding: 0; width: min(96vw, 1500px); }
.media-viewer::backdrop { backdrop-filter: blur(6px); background: rgba(0, 0, 0, .82); }
.media-viewer-bar { align-items: center; background: var(--chrome); border-bottom: 1px solid var(--line); display: flex; height: 54px; justify-content: space-between; padding: 8px 12px 8px 16px; }
.media-viewer-bar > div { display: flex; flex-direction: column; min-width: 0; }
.media-viewer-bar strong { color: var(--accent); font-size: 11px; }
.media-viewer-bar small { color: var(--muted); font-size: 8px; margin-top: 2px; }
.media-viewer-bar button { background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 7px; color: var(--accent); font-size: 9px; font-weight: 800; min-height: 31px; padding: 6px 10px; }
.media-viewer-stage { align-items: center; background: #050506; display: flex; height: calc(100% - 54px); justify-content: center; overflow: auto; }
.media-viewer-image { cursor: zoom-in; display: block; max-height: 100%; max-width: 100%; object-fit: contain; }
.media-viewer-image.is-zoomed { cursor: zoom-out; max-height: none; max-width: none; }

.contacts-workspace { background: var(--canvas); min-height: 0; overflow-y: auto; padding: clamp(22px, 3vw, 42px); }
.contacts-heading, .contact-metrics, .contact-directory-panel { margin-inline: auto; max-width: 1380px; }
.contacts-heading { align-items: flex-end; display: flex; gap: 24px; justify-content: space-between; }
.contacts-heading > div { min-width: 0; }
.contacts-heading p { color: var(--accent); font-size: 7px; font-weight: 850; letter-spacing: .16em; margin: 0 0 6px; }
.contacts-heading h1 { color: var(--ink-strong); font-size: clamp(24px, 3vw, 38px); letter-spacing: -.055em; line-height: .95; margin: 0; }
.contacts-heading > div > span { color: var(--muted); display: block; font-size: 10px; line-height: 1.5; margin-top: 9px; max-width: 620px; }
.contacts-heading > button { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); min-width: 96px; }
.contact-metrics { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 24px; }
.contact-metrics article { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 3px; min-width: 0; padding: 14px 16px; }
.contact-metrics span { color: var(--accent); font-size: 8px; font-weight: 800; }
.contact-metrics strong { color: var(--ink-strong); font-size: 22px; letter-spacing: -.035em; }
.contact-metrics small { color: var(--muted); font-size: 8px; }
.contact-directory-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; margin-top: 12px; overflow: hidden; }
.contact-directory-toolbar { align-items: end; border-bottom: 1px solid var(--line); display: grid; gap: 12px; grid-template-columns: minmax(280px, 1fr) minmax(180px, 260px); padding: 13px; }
.contact-directory-toolbar form, .contact-directory-toolbar > label { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.contact-directory-toolbar label, .contact-directory-toolbar > label > span { color: var(--muted); font-size: 8px; font-weight: 800; }
.contact-directory-toolbar form > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.contact-directory-toolbar input, .contact-directory-toolbar select { background: var(--control); border: 1px solid var(--line); color: var(--ink); font-size: 10px; min-height: 36px; outline: 0; padding: 7px 10px; }
.contact-directory-toolbar input { border-radius: 8px 0 0 8px; }
.contact-directory-toolbar form button { background: var(--accent-soft); border: 1px solid var(--accent-line); border-left: 0; border-radius: 0 8px 8px 0; color: var(--accent); font-size: 9px; font-weight: 800; min-width: 74px; }
.contact-directory-toolbar select { border-radius: 8px; }
.contact-directory-list { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); min-height: 260px; padding: 12px; }
.contact-directory-card { background: var(--panel-raised); border: 1px solid var(--line); border-radius: 11px; display: grid; gap: 9px; grid-template-columns: auto minmax(0, 1fr) auto; min-width: 0; padding: 11px; }
.contact-directory-card:hover { border-color: var(--accent-line); }
.contact-card-avatar { border-radius: 11px; font-size: 10px; height: 42px; width: 42px; }
.contact-card-copy { display: flex; flex-direction: column; min-width: 0; }
.contact-card-copy strong, .contact-card-copy span, .contact-card-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-card-copy strong { color: var(--ink-strong); font-size: 10px; }
.contact-card-copy span { color: var(--muted-strong); font-size: 8px; margin-top: 3px; }
.contact-card-copy small { color: var(--muted); font-size: 7px; margin-top: 5px; }
.contact-card-status { align-items: flex-end; display: flex; flex-direction: column; gap: 6px; }
.contact-card-status span { background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 999px; color: var(--accent); font-size: 7px; font-weight: 800; max-width: 105px; overflow: hidden; padding: 3px 6px; text-overflow: ellipsis; white-space: nowrap; }
.contact-card-status span.is-muted { background: transparent; border-color: var(--line); color: var(--muted); }
.contact-card-status time { color: var(--muted); font-size: 7px; white-space: nowrap; }
.contact-card-labels { border-top: 1px solid var(--line-soft); display: flex; gap: 4px; grid-column: 1 / -1; min-height: 25px; overflow: hidden; padding-top: 7px; }
.contact-card-labels span { background: var(--panel-strong); border-radius: 999px; color: var(--muted-strong); font-size: 7px; font-weight: 750; max-width: 100px; overflow: hidden; padding: 3px 6px; text-overflow: ellipsis; white-space: nowrap; }
.contact-card-labels span.is-empty { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.contact-card-open { background: transparent; border: 0; color: var(--accent); font-size: 8px; font-weight: 850; grid-column: 1 / -1; justify-self: end; padding: 2px 0; }
.contact-card-open:disabled { color: var(--muted); }
.contact-directory-load-more { display: block; margin: 0 auto 12px; }
.contact-directory-empty { align-items: center; color: var(--muted); display: flex; flex-direction: column; grid-column: 1 / -1; justify-content: center; min-height: 260px; padding: 28px; text-align: center; }
.contact-directory-empty > span { align-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); display: flex; font-size: 16px; height: 42px; justify-content: center; margin-bottom: 12px; width: 42px; }
.contact-directory-empty strong { color: var(--ink); font-size: 12px; }
.contact-directory-empty p { font-size: 9px; line-height: 1.5; margin: 6px 0 0; }
.contact-directory-empty.is-error > span, .contact-directory-empty.is-error strong { color: var(--danger); }
.contact-card-skeleton { background: var(--panel-raised); border: 1px solid var(--line); border-radius: 11px; display: grid; gap: 7px; grid-template-columns: 42px 1fr; padding: 11px; }
.contact-card-skeleton i, .contact-card-skeleton span, .contact-card-skeleton b { animation: skeleton-pulse 1.25s ease-in-out infinite alternate; background: var(--panel-strong); border-radius: 6px; display: block; }
.contact-card-skeleton i { grid-row: 1 / 3; height: 42px; }
.contact-card-skeleton span { height: 8px; margin-top: 4px; }
.contact-card-skeleton b { grid-column: 1 / -1; height: 25px; margin-top: 5px; }

@media (min-width: 1660px) { .app-workspace { grid-template-columns: 380px minmax(520px, 1fr) 330px; } }
@media (max-width: 1260px) {
  .app-workspace { grid-template-columns: 320px minmax(390px, 1fr) 282px; }
  .app-topbar { grid-template-columns: 190px minmax(0, 1fr) auto; }
  .profile-trigger { width: 166px; }
  .message-list { padding-inline: 22px; }
  .contact-directory-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1040px) {
  .app-workspace { grid-template-columns: 310px minmax(360px, 1fr); }
  .contact-inspector { box-shadow: -14px 0 40px var(--shadow); display: none; inset: 0 0 0 auto; position: absolute; width: 286px; z-index: 20; }
  body.thread-open .contact-inspector { display: block; }
  .profile-identity { display: none; }
  .profile-trigger { grid-template-columns: auto auto; width: auto; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .app-shell { grid-template-rows: 52px minmax(0, 1fr); min-height: 540px; }
  .app-topbar { gap: 10px; grid-template-columns: auto minmax(0, 1fr) auto; padding-inline: 10px; }
  .brand span { display: none; }
  .brand img { height: 28px; width: 28px; }
  .top-navigation { justify-content: center; }
  .top-link { font-size: 9px; padding-inline: 8px; }
  .profile-chevron { display: none; }
  .app-workspace { grid-template-columns: 1fr; }
  .conversation-pane { border: 0; grid-column: 1; grid-row: 1; }
  .thread-pane { display: none; grid-column: 1; grid-row: 1; }
  .contact-inspector, body.thread-open .contact-inspector { display: none; }
  body.thread-open .conversation-pane { display: none; }
  body.thread-open .thread-pane { display: flex; }
  .thread-header { grid-template-columns: auto auto minmax(0, 1fr); min-height: 60px; padding: 9px 11px; }
  .mobile-back { display: inline-flex; }
  .contact-avatar { grid-column: 2; }
  .thread-identity { grid-column: 3; }
  .thread-metadata { display: none; }
  .message-list { padding: 7px 12px 18px; }
  .message { max-width: 88%; }
  .message.has-image { max-width: 96%; width: 96%; }
  .read-only-note { padding-inline: 11px; }
  .contacts-workspace { padding: 18px 12px; }
  .contacts-heading { align-items: flex-start; }
  .contact-metrics { grid-template-columns: 1fr; }
  .contact-directory-toolbar, .contact-directory-list { grid-template-columns: 1fr; }
}
@media (max-width: 430px) {
  .top-link span { display: none; }
  .top-link { padding-inline: 7px; }
  .profile-menu { right: -3px; width: min(286px, calc(100vw - 20px)); }
}
@media (prefers-reduced-motion: no-preference) {
  button, .conversation-item, .top-link, .profile-trigger { transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease, transform .1s ease; }
  button:active { transform: translateY(1px); }
}
@media (prefers-reduced-motion: reduce) { .skeleton-row i, .skeleton-row span { animation: none; } }
