/* Approved Cosmos-inspired shell. Original messages and media stay complete. */
:root { background: #fff; --surface: #f6f7f9; --ink: #242833; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.app-shell { display: block; }
.library-header { position: sticky; top: 0; z-index: 5; background: #fff; }
.library-topbar { display: grid; grid-template-columns: minmax(210px,1fr) minmax(280px,560px) minmax(190px,1fr); gap: 28px; align-items: center; max-width: 1920px; margin: auto; padding: 24px 32px 18px; }
.brand { padding: 0; margin: 0; gap: 10px; font-size: 23px; white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; }
.search-tools { display: flex; align-items: center; min-width: 0; position: relative; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); padding: 4px; }
.search-tools:focus-within { border-color: #94a6ee; box-shadow: 0 0 0 2px #eef1fd; }
.search { height: 42px; border: 0; background: transparent; padding: 0 10px 0 14px; gap: 10px; min-width: 0; border-radius: 99px; color: var(--muted); }
.search:focus-within { border: 0; box-shadow: none; }
.search svg { flex-shrink: 0; }
.search input { font-size: 14px; color: var(--ink); }
.search input::placeholder { color: var(--muted); }
.search input:focus-visible { outline: 0; }
.search kbd { background: #fff; color: var(--muted); }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.button { border-radius: 99px; min-height: 42px; padding: 10px 18px; font-size:14px; }
.telegram-link, .primary { color: white; background: var(--ink); border-color: var(--ink); }
.control-disclosure { position: relative; flex-shrink: 0; }
.search-tools .control-disclosure { position: static; }
.control-button { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink); cursor: pointer; list-style: none; position: relative; }
.control-button::-webkit-details-marker { display: none; }
.control-button::marker { content: ''; }
.filter-toggle { border: 0; background: transparent; }
.control-disclosure[open] > .control-button, .has-filters > .control-button { background: #fff; box-shadow: 0 0 0 1px var(--line); }
.filter-count { position: absolute; top: 0; right: 0; width: 16px; height: 16px; display: grid; place-items: center; background: var(--ink); color: white; border-radius: 50%; font-size:14px; font-variant-numeric: tabular-nums; }
.control-panel { position: absolute; top: calc(100% + 10px); right: 0; z-index: 6; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: 0 12px 40px #202a4914; }
.filter-panel { width: min(280px,calc(100vw - 40px)); display: flex; flex-direction: column; gap: 10px; }
.filter-panel label { font-size:14px; color: var(--muted); }
.filter-panel label:not(:first-child) { margin-top: 8px; }
.filter-panel select { width: 100%; color: var(--ink); border-radius: 10px; background: var(--surface); font-size: 14px; }
.filter-panel .text-button { align-self: flex-start; font-size:14px; color: var(--ink); }
.account-panel { padding: 6px; min-width: 170px; }
.account-panel .text-button { padding: 12px; width: 100%; text-align: left; border-radius: 12px; font-size:14px; color: var(--ink); }
#categories { display: flex; flex-direction: row; gap: 6px; max-width: 1920px; margin: auto; padding: 0 32px 16px; overflow-x: auto; scrollbar-width: none; scroll-padding-inline: 32px; }
#categories::-webkit-scrollbar { display: none; }
.category-button { flex-shrink: 0; width: auto; white-space: nowrap; border-radius: 99px; padding: 11px 18px; gap: 8px; background: transparent; color: var(--muted); min-height: 42px; font-size:14px; }
.category-button.active { background: var(--surface); color: var(--ink); }
.category-button, .category-button.active { font-weight: 650; }
.category-button .count { color: var(--muted); margin: 0; font-size:14px; }
.category-button.active .count { color: var(--muted); }
.workspace { display: block; }
main { max-width: 1920px; padding: 24px 32px 64px; margin: auto; }
.results-meta { margin: 0 0 20px; font-size:14px; color: var(--muted); }
.connect-panel { margin: 20px 0; padding: 16px; background: var(--surface); border-color: var(--line); }
.connect-panel .button { margin: 0; }
.cards { --columns: 3; gap: 24px; }
.card { border: 0; background: transparent; overflow: visible; box-shadow: none; }
.card-visual { border: 0; border-radius: var(--radius); }
.card-visual:has(img) { height: auto; }
.card-body { padding: 14px 4px 4px; }
.card-meta { margin-bottom: 8px; color: var(--muted); font-size:14px; }
.card-title { font-size: 15px; color: var(--ink); }
.card-bottom { border: 0; padding-top: 8px; }
.category-tag { background: var(--surface); color: var(--muted); border-radius: 99px; padding: 5px 9px; font-size:14px; max-width: 65%; overflow-wrap: anywhere; }
.card-date { color: var(--muted); }
.card-delete { margin-left: 2px; }
.message-card .card-body { padding: 0; }
.message-bubble {
  position: relative;
  isolation: isolate;
  padding: 22px;
  border: 0;
  border-radius: 26px;
  background: linear-gradient(180deg, #f0fae8 0%, #def3e5 55%, #d0ece3 calc(100% - 24px));
  box-shadow: none;
}
.message-bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  bottom: 0;
  width: 28px;
  height: 24px;
  z-index: -1;
  pointer-events: none;
  background: #d0ece3;
  /* A curved incoming-message tail, joined to the bubble's lower edge. */
  clip-path: path('M 8 0 H 28 V 24 H 23 C 15 24 11 22 9 20 C 6 22 3 23 0 23 C 7 19 8 11 8 0 Z');
}
.message-bubble .card-bottom { flex-wrap: wrap; }
.message-bubble .category-tag { background: #ffffff70; color: #597769; }
.message-bubble .card-title { color: #2e5544; }
.message-bubble .link-preview { margin-top: 16px; }
.message-photos .card-visual:last-child { margin-bottom: 0; }
.message-photos:has(+ .message-content) { margin-bottom: 14px; }
.message-text.is-collapsed { max-height: 10lh; overflow: hidden; }
.message-bubble .message-toggle { color: var(--green-ink); text-decoration: underline; }
.tiktok-poster { position: relative; border-radius: var(--radius); overflow: hidden; }
.tiktok-poster:focus-visible { outline-offset: -3px; }
.tiktok-play { position: absolute; inset: 0; margin: auto; border: 0; background: var(--ink); color: #fff; pointer-events: none; }
.card.media-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.media-card > .card-visual,
.media-card > .tiktok-poster { border-radius: 0; }
.media-card .card-body { padding: 16px 18px 14px; }
.media-card .card-title { margin: 0; line-height: 1.5; }
.media-card .card-meta { margin: 6px 0 0; font-size:14px; line-height: 1.5; }
.media-card .card-bottom { margin-top: 14px; padding: 0; gap: 12px; }
.media-card .card-delete { margin-left: auto; }
.media-card:focus-within { border-color: #94a6ee; }
.card-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.card-actions .card-delete { margin: 0; }
.card-download { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; text-decoration: none; background: transparent; }
.message-photos .card-download { position: absolute; right: 10px; bottom: 10px; background: #fff; border: 1px solid var(--line); }
.category-tag.category-select {
  appearance: none;
  field-sizing: content;
  min-width: 0;
  max-width: 60%;
  min-height: 34px;
  padding: 6px 28px 6px 10px;
  border: 0;
  border-radius: 99px;
  font-weight: 400;
  line-height: 1.4;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%233f6354' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-repeat: no-repeat;
}
.category-select option { background: #fff; color: var(--ink); }
.card-status .text-button { display: inline; margin-left: 8px; text-decoration: underline; }
.media-card h2.card-title:hover { color: var(--ink); }
dialog .button { min-height: 42px; }
#confirm-delete .detail-actions { border-top: 0; }
@media (hover:hover) {
  .telegram-link:hover, .primary:hover { color: #fff; background: #303746; border-color: #303746; }
  .category-button:hover, .category-button.active:hover, .control-button:hover, .account-panel .text-button:hover { background: var(--surface); color: var(--ink); }
  .card:not(.media-card):hover { box-shadow: none; border-color: transparent; }
}
@media (min-width:1440px) { .cards { --columns: 4; } }
@media (max-width:1100px) {
  .library-topbar { grid-template-columns: auto minmax(220px,1fr) auto; gap: 20px; padding-inline: 24px; }
  .brand { font-size: 20px; }
  .header-actions { gap: 8px; }
  #categories { padding-inline: 24px; }
  main { padding-inline: 24px; }
  .cards { --columns: 3; gap: 20px; }
}
@media (max-width:900px) {
  .library-topbar { grid-template-columns: 1fr auto; gap: 16px; padding: 20px 24px 14px; }
  .search-tools { grid-row: 2; grid-column: 1 / -1; }
  .header-actions { grid-row: 1; grid-column: 2; }
  .brand { font-size: 23px; }
  .cards { --columns: 2; }
}
@media (max-width:600px) {
  .library-topbar { padding: 16px 20px 12px; gap: 14px; }
  .brand { font-size: 20px; gap: 7px; letter-spacing: -.7px; }
  .brand-mark { width: 30px; height: 30px; }
  .telegram-link { font-size:14px; padding: 10px 12px; min-height: 40px; }
  .header-actions { gap: 6px; }
  .control-button { width: 40px; height: 40px; }
  .search { height: 40px; }
  .search input { font-size: 16px; }
  #categories { padding: 0 20px 12px; scroll-padding-inline: 20px; gap: 4px; }
  .category-button { padding: 10px 15px; font-size:14px; }
  main { padding: 20px 20px 40px; }
  .cards { --columns: 1; gap: 20px; }
  .results-meta { margin: 0 0 16px; }
  .message-bubble { padding: 20px; }
  .card-title { font-size: 15px; }
  .filter-panel select { font-size: 16px; }
}
@media (max-width:380px) {
  .brand { font-size: 18px; }
  .brand-mark { width: 26px; height: 26px; }
  .library-topbar { padding-inline: 16px; gap: 12px; }
  #categories { padding-inline: 16px; }
  main { padding-inline: 16px; }
  .telegram-link { padding-inline: 10px; }
}

/* Text contrast: >= 4.5:1, including the darkest green gradient stop. */
:root { --muted: #596170; --green-ink: #3f6354; font-weight: 400; }
.subtle, .small, .eyebrow, .text-button, .card-meta, .card-description,
.card-date, .category-tag, .domain-caption, .empty-state p, .results-meta,
.category-button, .category-button .count, .category-button.active .count,
.filter-panel label, .loading-screen p, .login-card .subtle,
.media-card .card-meta, .search, .search input::placeholder, kbd { color: var(--muted); }
.message-bubble > .card-meta, .message-bubble .card-date,
.message-bubble .category-tag, .message-bubble .card-status,
.message-bubble .link-preview .card-meta, .link-preview .card-description { color: var(--green-ink); }
.category-button.active { color: var(--ink); box-shadow: inset 0 0 0 1px #596170; }
.message-bubble .card-download { color: var(--muted); text-decoration: none; }
.icon-button, .card-download, .card-delete { color: var(--muted); }
.message-bubble .card-delete { color: var(--green-ink); }
.card-status { color: #725617; }
.error, .danger { color: #963c34; }
.card-delete:hover { color: #963c34; }
.message-bubble .text-button:hover { color: #28694d; }
.button, .control-button, .search-tools, .filter-panel select { border-color: #7b8291; }
.telegram-link, .primary { border-color: var(--ink); }
.search-tools:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.filter-count { min-width: 20px; width: auto; height: 20px; padding: 0 3px; }
.icon-button.card-delete, .icon-button.card-download { width: 34px; height: 34px; }
@media (max-width:600px) {
  .brand { font-size: 18px; }
  .brand-mark { width: 26px; height: 26px; }
  .header-actions { gap: 4px; }
  .telegram-link { padding-inline: 10px; }
  .category-tag.category-select { font-size: 16px; }
}
@media (max-width:350px) {
  .library-topbar { grid-template-columns: minmax(0,1fr) auto; }
  .brand span { max-width: 110px; white-space: normal; line-height: 1.15; }
}
