/* Reference surfaces, authorized by the user's 4 October 2026 request.
   Intent: finding signals and responding to activity while retaining page context.
   Hierarchy: inset search field, editorial archive titles, compact activity rows.
   Palette/depth: blue-black 05/12/14 references with a quiet periwinkle focus.
   Typography: existing Manrope UI + Source Serif editorial; spacing on an 8px grid.
   These rules only compose the real application's existing DOM and controls. */

#overlay {
  --overlay-surface: #0c1018;
  --overlay-line: rgb(195 205 230 / 12%);
  --overlay-strong-line: rgb(195 205 230 / 22%);
  --overlay-muted: #8a93a6;
  background: linear-gradient(135deg, rgb(16 20 28 / 98%), rgb(11 17 25 / 98%));
  border: 1px solid var(--overlay-strong-line);
  box-shadow: 0 24px 64px rgb(0 0 0 / 35%);
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #343d50 transparent;
}
#overlay::backdrop {
  background: rgb(0 3 8 / 55%);
  backdrop-filter: none;
}
#overlay .overlay-head {
  margin-bottom: 16px;
}
#overlay .overlay-head h2 {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
}
#overlay .overlay-head .icon-btn {
  color: #b4bac8;
  min-height: 44px;
  height: 44px;
}
#overlay :is(input, textarea, select) {
  border-color: var(--overlay-line);
  background-color: rgb(0 3 8 / 26%);
}
#overlay :is(input, textarea, select):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#overlay .btn {
  border-radius: 6px;
}
#overlay .btn.primary {
  background: linear-gradient(110deg, #555bf5, #444bce);
  border-color: #6570ed;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 12%);
}

/* 05: search is a near-top command surface, its close affordance shares
   the first row with the field. The title remains available to aria-labelledby. */
#overlay.search-overlay {
  position: fixed;
  inset: 73px auto auto max(16px, calc(50% - 334px));
  margin: 0;
  width: 700px;
  padding: 16px 24px 20px;
  border-radius: 18px;
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 96px);
}
#overlay.search-overlay .overlay-head {
  position: absolute;
  top: 12px;
  right: 24px;
  margin: 0;
}
#overlay.search-overlay .overlay-head h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
#overlay.search-overlay .overlay-head .icon-btn {
  min-width: 112px;
  padding: 10px 0 10px 8px;
  gap: 12px;
  font-size: 12px;
}
#overlay.search-overlay .overlay-head .icon-btn::before {
  content: "Закрыть";
}
#overlay.search-overlay .search-input {
  width: calc(100% - 184px);
  min-height: 38px;
  border-radius: 12px;
  padding-inline: 12px;
  color: #c7cbd7;
}
#overlay.search-overlay .search-input input {
  min-height: 36px;
  padding-block: 8px !important;
  font-size: 14px;
}
#overlay.search-overlay .search-input input:focus {
  outline: none;
}
#overlay.search-overlay .search-tabs {
  margin-top: 8px;
  gap: 24px;
}
#overlay.search-overlay .search-tabs button {
  min-height: 44px;
  padding-inline: 2px;
  font-size: 14px;
}
#overlay.search-overlay .search-results {
  max-height: min(57dvh, 576px);
  overflow: auto;
  margin-top: 8px;
}
#overlay.search-overlay .search-result {
  gap: 24px;
  padding: 14px 16px;
  min-height: 86px;
  border-bottom-color: var(--overlay-line);
}
#overlay.search-overlay .search-result > div {
  min-width: 0;
}
#overlay.search-overlay .search-result b {
  display: block;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
}
#overlay.search-overlay .search-result p {
  font-size: 12px;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
#overlay.search-overlay .search-result img:not(.round) {
  width: 90px;
  height: 78px;
  border: 1px solid var(--overlay-line);
}
#overlay.search-overlay .search-result :is(img.round, .tag-image) {
  width: 56px;
  height: 56px;
  margin-inline: 17px;
  outline-color: var(--overlay-line);
}
#overlay.search-overlay .search-result > .icon {
  display: none;
}
#overlay.search-overlay .search-result .result-type {
  font-size: 10px;
  color: var(--overlay-muted);
}
#overlay.search-overlay .search-result:focus-visible {
  background: rgb(135 148 255 / 12%);
  border-radius: 7px;
  outline-offset: -2px;
}
#overlay.search-overlay .search-help {
  margin-top: 0;
  padding-top: 20px;
  border-top: 1px solid var(--overlay-line);
  min-height: 52px;
  font-size: 12px;
  gap: 28px;
  flex-wrap: wrap;
}
#overlay.search-overlay .search-help kbd {
  font-size: 11px;
  padding: 2px 5px;
}

/* 05/14: the temporary notifications surface remains aligned to its bell. */
#overlay.pulse-overlay {
  position: fixed;
  inset: 65px 18px auto auto;
  width: 365px;
  margin: 0;
  padding: 16px;
  border-radius: 5px;
  max-height: calc(100dvh - 88px);
}
#overlay.pulse-overlay .overlay-head {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--overlay-line);
}
#overlay.pulse-overlay .overlay-subtitle {
  margin: 0 0 4px;
  color: var(--overlay-muted);
  font-size: 11px;
}
#overlay.pulse-overlay .notice-row {
  gap: 12px;
  padding: 16px 0;
  font-size: 12px;
  line-height: 1.5;
}
#overlay.pulse-overlay .notice-row .avatar {
  width: 40px;
  height: 40px;
}
#overlay.pulse-overlay .notice-row p {
  margin-bottom: 4px;
}
#overlay.pulse-overlay .notice-row small {
  color: #737e90;
  font-size: 10px;
}
#overlay.pulse-overlay .notice-row .unread-dot {
  width: 5px;
  height: 5px;
  margin: 10px 1px 0 0;
}
#overlay.pulse-overlay > .full-width {
  margin-top: 0;
  border: 0;
  border-bottom: 1px solid var(--overlay-line);
  color: var(--accent);
  min-height: 40px;
  padding-block: 10px;
  font-size: 12px;
}
#overlay.pulse-overlay > .full-width:last-child {
  border-bottom: 0;
}

/* 14: restrained report, share, account and reaction surfaces. */
#overlay.account-overlay {
  width: 400px;
  padding: 16px;
  border-radius: 8px;
}
#overlay.account-overlay .overlay-head {
  padding-bottom: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--overlay-line);
}
#overlay.account-overlay :is(.muted, legend, .field) {
  font-size: 12px;
  line-height: 1.6;
}
#overlay.account-overlay .radio-row {
  min-height: 44px;
  font-size: 12px;
}
#overlay.account-overlay input[type="radio"] {
  appearance: none;
  width: 14px;
  height: 14px;
  margin: 0 4px 0 0;
  border: 1px solid #727c90;
  border-radius: 50%;
  background: transparent;
}
#overlay.account-overlay input[type="radio"]:checked {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px #10141c;
}
#overlay.account-overlay legend {
  margin-bottom: 8px;
}
#overlay.account-overlay .account-links :is(a, button) {
  padding: 12px 8px;
  min-height: 44px;
  font-size: 13px;
  border-bottom-color: var(--overlay-line);
}
#overlay.account-overlay .account-links :is(a, button):last-child {
  border-bottom: 0;
}
#overlay.account-overlay:has([data-form="report"]) {
  width: 320px;
}
#overlay.account-overlay [data-form="report"] .field {
  margin-block: 16px;
}
#overlay.account-overlay [data-form="report"] textarea {
  min-height: 88px;
}
#overlay.account-overlay [data-form="report"] .btn + p {
  margin: 12px 0 0;
  font-size: 10px;
}
#overlay.account-overlay:has(.reaction-options) {
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 8px;
  border-radius: 18px;
}
#overlay.account-overlay:has(.reaction-options) .overlay-head {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 0;
  margin: 0;
  border: 0;
}
#overlay.account-overlay:has(.reaction-options) .overlay-head h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
#overlay.account-overlay .account-links.reaction-options {
  display: grid;
  grid-template-columns: repeat(6, 44px);
  gap: 4px;
  padding-right: 44px;
}
#overlay.account-overlay .account-links.reaction-options button {
  min-width: 44px;
  max-width: 60px;
  height: 52px;
  min-height: 52px;
  padding: 4px;
  gap: 4px;
  flex-direction: column;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  font-size: 0;
  line-height: 1.2;
  text-align: center;
}
#overlay.account-overlay .reaction-options .reaction-emoji {
  font-size: 24px;
  line-height: 28px;
}
#overlay.account-overlay .reaction-options button[aria-pressed="true"] {
  background: rgb(135 148 255 / 12%);
  color: var(--accent);
}
#overlay.account-overlay .reaction-options button > .icon {
  width: 12px;
  height: 12px;
}
#overlay.account-overlay .account-links.reaction-options button[data-value="remove"] {
  grid-column: 1 / -1;
  max-width: none;
  height: 44px;
  min-height: 44px;
  flex-direction: row;
  font-size: 11px;
}

/* 14 media viewer: the image dominates; metadata and navigation stay quiet. */
#overlay.lightbox-overlay {
  width: min(1180px, calc(100vw - 64px));
  padding: 24px;
  background: #04080d;
  border-radius: 8px;
}
#overlay.lightbox-overlay .overlay-head h2 {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.2;
}
#overlay.lightbox-overlay .lightbox-image {
  max-height: calc(100dvh - 224px);
  min-height: 0;
  object-fit: contain;
  margin-bottom: 16px;
}
#overlay.lightbox-overlay .toolbar {
  border-top: 1px solid var(--overlay-line);
  padding-top: 12px;
}
#overlay.lightbox-overlay .toolbar .btn:not([data-action="save"]) {
  width: 44px;
  padding-inline: 8px;
  border-color: transparent;
}

/* 12 archive and notices are editorial indexes, not a stack of large cards. */
:is(.route-saved, .route-drafts, .route-notifications, .route-search) .page-top {
  margin-bottom: 4px;
  align-items: center;
}
:is(.route-saved, .route-drafts, .route-notifications, .route-search) .page-top .eyebrow {
  display: none;
}
:is(.route-saved, .route-drafts, .route-notifications, .route-search) .page-top .page-heading {
  font-size: 28px;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
:is(.route-saved, .route-drafts, .route-notifications) .page-top .muted {
  margin-bottom: 0;
  font-size: 12px;
}
:is(.route-saved, .route-drafts, .route-notifications) > .tabs {
  margin-top: 8px;
  gap: 24px;
}
:is(.route-saved, .route-drafts) .archive-item {
  position: relative;
  grid-template-columns: 220px minmax(0, 1fr) 44px;
  gap: 24px;
  align-items: start;
  padding: 16px 0 16px 72px;
}
:is(.route-saved, .route-drafts) .archive-item::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
:is(.route-saved, .route-drafts) .archive-item::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 24px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--bg);
  background: var(--accent);
  border-radius: 50%;
  outline: 1px solid var(--accent);
}
:is(.route-saved, .route-drafts) .archive-item .eyebrow {
  position: absolute;
  left: 26px;
  top: 20px;
  width: 44px;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
  font-size: 9px;
  color: var(--muted);
  margin-bottom: 4px;
}
:is(.route-saved, .route-drafts) .archive-item .image-link {
  aspect-ratio: 2.5;
  border: 1px solid var(--border);
  border-radius: 4px;
}
:is(.route-saved, .route-drafts) .archive-item .section-title {
  font-size: 23px;
  line-height: 1.2;
  margin: 0 0 6px;
}
:is(.route-saved, .route-drafts) .archive-item :is(.muted, .archive-excerpt) {
  font-size: 11px;
  margin-bottom: 0;
  line-height: 1.5;
}
:is(.route-saved, .route-drafts) .archive-excerpt {
  margin-top: 4px;
  color: #8a93a6;
  max-width: 600px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.route-notifications .notification-list {
  max-width: none;
  margin: 0;
}
.route-notifications .notice-row {
  padding: 16px 0 16px 20px;
  gap: 16px;
  font-size: 13px;
  position: relative;
}
.route-notifications .notice-row .avatar {
  width: 40px;
  height: 40px;
}
.route-notifications .notice-row .unread-dot {
  position: absolute;
  left: 0;
  top: 28px;
  margin: 0;
  width: 5px;
  height: 5px;
}
.route-notifications .notice-row > div {
  min-width: 0;
}
.route-notifications .notice-row small {
  font-size: 10px;
  color: #737e90;
}
.route-notifications .page-top > .btn {
  color: var(--accent);
  font-size: 12px;
}
.route-search {
  max-width: 1440px;
}
.route-search > .search-input {
  margin-top: 16px;
  max-width: 700px;
}
.route-search .search-results {
  max-width: 1080px;
}
.route-search .search-result > div {
  min-width: 0;
}
.route-search .search-result b {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.2;
}
.route-search .search-result .result-type {
  font-size: 10px;
}

/* 13 boundary states: preserve real errors and actions, with the same calm
   cinematic panel and form proportions as the reference state family. */
.empty-state {
  padding: 48px 24px;
  min-height: 280px;
}
.empty-state h2 {
  font-size: 28px;
  font-weight: 400;
  line-height: 1.2;
}
.empty-state p {
  max-width: 400px;
  font-size: 14px;
  line-height: 1.55;
}
.empty-state > .btn {
  min-width: 240px;
  background: linear-gradient(110deg, #555bf5, #444bce);
  border-color: #6570ed;
  color: #fff;
  border-radius: 6px;
}
.route-not-found .page-top {
  display: none;
}
:is(.route-not-found, .canvas:has(> .empty-state > [data-action="retry-route"])) > .empty-state {
  max-width: 480px;
  margin: 24px auto;
  min-height: 520px;
  padding: 240px 40px 40px;
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgb(3 7 12 / 20%), var(--bg) 50%),
    url("./assets/passage") center top / cover no-repeat;
}
:is(.route-not-found, .canvas:has(> .empty-state > [data-action="retry-route"])) > .empty-state > .icon {
  display: none;
}
:is(.route-not-found, .canvas:has(> .empty-state > [data-action="retry-route"])) > .empty-state > .btn {
  width: 100%;
  min-width: 0;
  margin-top: 16px;
}
.state-panel[aria-busy="true"] {
  width: 100%;
  max-width: 920px;
  min-height: 300px;
  background: rgb(10 16 25 / 35%);
  border-color: var(--border);
  padding: 24px;
}
.state-panel[aria-busy="true"] .skeleton {
  background: linear-gradient(110deg, #131a24, #1b2432 50%, #131a24);
  background-size: 200% 100%;
  border: 1px solid rgb(216 224 255 / 4%);
  border-radius: 6px;
}
.state-panel[aria-busy="true"] .skeleton-image {
  height: 160px;
  margin: 0 0 24px;
}
.state-panel[aria-busy="true"] .skeleton-line {
  height: 12px;
  max-width: 480px;
}
.state-panel[aria-busy="true"] p {
  padding-top: 20px;
  margin-top: 24px;
  margin-bottom: 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
#overlay .empty-state {
  min-height: 200px;
  padding: 24px 12px;
}
#overlay .empty-state h2 {
  font-size: 24px;
}
#overlay .empty-state p {
  font-size: 12px;
}
#overlay .state-panel[aria-busy="true"] {
  min-height: 240px;
  padding: 16px;
}
.action-error {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid rgb(239 99 74 / 32%);
  border-radius: 6px;
  background: rgb(80 28 23 / 18%);
  color: #ef8e78;
  font-size: 12px;
  line-height: 1.5;
}
.action-error::before {
  content: "!";
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border: 1px solid currentColor;
  border-radius: 50%;
  line-height: 1;
}
.notice-row .notice-preview {
  width: 120px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
  margin-left: auto;
}
#overlay .notice-row .notice-preview {
  width: 48px;
  height: 36px;
}
:is(.route-saved, .route-drafts) .archive-time {
  position: absolute;
  left: 26px;
  top: 42px;
  width: 44px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}
.search-result .search-result-summary {
  margin: 4px 0 0;
  font-size: 12px;
  color: #969daf;
}
.search-result .search-result-meta {
  margin: 4px 0 0;
  font-size: 11px;
  color: #848ea1;
}
#toast {
  border-color: rgb(195 205 230 / 18%);
  background: #101720;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 30%);
}

/* Native single-choice selects keep form serialization, keyboard navigation,
   browser light dismiss and disabled semantics. Unsupported engines retain
   their existing OS picker. MDN/WHATWG sources: docs/reference-interactions.md. */
@supports (appearance: base-select) and selector(select::picker(select)) {
  :is(#app, #overlay) select:not([multiple]):is(:not([size]), [size="1"]),
  :is(#app, #overlay) select:not([multiple]):is(:not([size]), [size="1"])::picker(select) {
    appearance: base-select;
  }
  :is(#app, #overlay) select:not([multiple]):is(:not([size]), [size="1"]) {
    align-items: center;
    gap: 12px;
  }
  :is(#app, #overlay) select:not([multiple]):is(:not([size]), [size="1"])::picker(select) {
    min-width: anchor-size(width);
    max-width: calc(100vw - 32px);
    max-height: min(320px, 50dvh);
    overflow: auto;
    padding: 4px;
    margin-top: 6px;
    border: 1px solid rgb(195 205 230 / 22%);
    border-radius: 8px;
    background: #101720;
    color: #e6e9f2;
    font: 13px/1.5 var(--ui);
    box-shadow: 0 12px 32px rgb(0 0 0 / 32%);
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
  :is(#app, #overlay) select:not([multiple]):is(:not([size]), [size="1"])::picker-icon {
    color: var(--muted);
    transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
  }
  :is(#app, #overlay) select:not([multiple]):is(:not([size]), [size="1"]):open::picker-icon {
    transform: rotate(180deg);
    color: var(--accent);
  }
  :is(#app, #overlay) select:not([multiple]):is(:not([size]), [size="1"]) option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    min-height: 44px;
    border: 0;
    border-radius: 4px;
    color: #bfc6d5;
    background: transparent;
    font-weight: 400;
    cursor: pointer;
  }
  :is(#app, #overlay) select:not([multiple]):is(:not([size]), [size="1"]) option:checked {
    color: var(--accent);
    background: rgb(135 148 255 / 10%);
  }
  :is(#app, #overlay) select:not([multiple]):is(:not([size]), [size="1"]) option:is(:hover, :focus-visible) {
    color: #e6e9f2;
    background: rgb(135 148 255 / 16%);
    outline: 1px solid rgb(135 148 255 / 40%);
    outline-offset: -1px;
  }
  :is(#app, #overlay) select:not([multiple]):is(:not([size]), [size="1"]) option::checkmark {
    order: 1;
    margin-inline-start: auto;
    color: var(--accent);
  }
  :is(#app, #overlay) select:not([multiple]):is(:not([size]), [size="1"]) option:disabled {
    color: #657084;
    background: transparent;
    cursor: default;
  }
}

@media (max-width: 1024px) {
  #overlay.search-overlay {
    left: max(16px, calc(50% - 350px));
  }
  :is(.route-saved, .route-drafts) .archive-item {
    grid-template-columns: 168px minmax(0, 1fr) 40px;
    gap: 16px;
    padding-left: 48px;
  }
  :is(.route-saved, .route-drafts) .archive-item .section-title {
    font-size: 21px;
  }
  :is(.route-saved, .route-drafts) .archive-item .eyebrow {
    position: static;
    width: auto;
  }
  :is(.route-saved, .route-drafts) .archive-time {
    position: static;
    display: inline;
    width: auto;
  }
}
@media (max-width: 700px) {
  #overlay.search-overlay {
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    background: #080d14;
  }
  #overlay.search-overlay .overlay-head {
    top: 17px;
    right: 12px;
  }
  #overlay.search-overlay .overlay-head .icon-btn {
    min-width: 44px;
    padding: 10px;
  }
  #overlay.search-overlay .overlay-head .icon-btn::before {
    content: none;
  }
  #overlay.search-overlay .search-input {
    width: calc(100% - 48px);
    min-height: 40px;
    border-radius: 8px;
  }
  #overlay.search-overlay .search-tabs {
    margin-top: 12px;
    gap: 20px;
  }
  #overlay.search-overlay .search-tabs button {
    min-height: 44px;
    font-size: 11px;
  }
  #overlay.search-overlay .search-results {
    max-height: calc(100dvh - 204px - env(safe-area-inset-bottom));
  }
  #overlay.search-overlay .search-result {
    gap: 12px;
    min-height: 76px;
    padding: 12px 0;
  }
  #overlay.search-overlay .search-result b {
    font-size: 12px;
  }
  #overlay.search-overlay .search-result p {
    font-size: 10px;
  }
  #overlay.search-overlay .search-result img:not(.round) {
    width: 84px;
    height: 64px;
  }
  #overlay.search-overlay .search-result :is(img.round, .tag-image) {
    width: 44px;
    height: 44px;
    margin-inline: 20px;
  }
  #overlay.search-overlay .search-help {
    font-size: 10px;
    gap: 12px;
    padding-top: 16px;
  }
  #overlay.search-overlay .search-help kbd {
    font-size: 9px;
  }
  #overlay.pulse-overlay {
    inset: auto 0 0;
    width: 100%;
    max-width: 100vw;
    max-height: 82dvh;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
    background: #10151d;
  }
  #overlay.pulse-overlay::before {
    margin: -4px auto 12px;
    width: 36px;
    background: #59616f;
  }
  #overlay.pulse-overlay .overlay-head {
    margin-bottom: 8px;
  }
  #overlay.pulse-overlay .notice-row {
    padding-block: 16px;
  }
  #overlay.account-overlay {
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 40px);
    border-radius: 10px;
  }
  #overlay.account-overlay:has(.reaction-options) {
    width: 360px;
  }
  #overlay.account-overlay .account-links.reaction-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  #overlay.account-overlay .account-links.reaction-options button {
    max-width: none;
    height: 60px;
    font-size: 10px;
  }
  #overlay.lightbox-overlay {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    padding: 16px;
    border: 0;
    border-radius: 0;
  }
  #overlay.lightbox-overlay[open] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 16px;
  }
  #overlay.lightbox-overlay .overlay-head {
    margin-bottom: 0;
  }
  #overlay.lightbox-overlay .overlay-head h2 {
    font-size: 20px;
  }
  #overlay.lightbox-overlay .lightbox-image {
    height: 100%;
    max-height: none;
    margin-bottom: 0;
  }
  #overlay.lightbox-overlay audio.lightbox-image {
    height: 54px;
    align-self: center;
  }
  #overlay.lightbox-overlay .toolbar {
    gap: 8px;
    font-size: 10px;
  }
  #overlay.lightbox-overlay .toolbar .btn {
    font-size: 11px;
  }
  :is(.route-saved, .route-drafts, .route-notifications, .route-search) .page-top {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
  :is(.route-saved, .route-drafts, .route-notifications, .route-search) .page-top .page-heading {
    font-size: 24px;
  }
  :is(.route-saved, .route-drafts, .route-notifications) .page-top > .btn {
    font-size: 10px;
    white-space: normal;
    min-height: 44px;
    max-width: 132px;
    padding: 8px;
    flex-shrink: 0;
  }
  :is(.route-saved, .route-drafts, .route-notifications) .page-top .muted {
    font-size: 10px;
  }
  :is(.route-saved, .route-drafts, .route-notifications) > .tabs {
    gap: 20px;
  }
  :is(.route-saved, .route-drafts) .archive-item {
    grid-template-columns: 64px minmax(0, 1fr) 44px;
    padding: 16px 0 16px 20px;
    gap: 10px;
  }
  :is(.route-saved, .route-drafts) .archive-item::before {
    left: 4px;
  }
  :is(.route-saved, .route-drafts) .archive-item::after {
    left: 0;
    top: 22px;
  }
  :is(.route-saved, .route-drafts) .archive-item .image-link {
    aspect-ratio: 1;
  }
  :is(.route-saved, .route-drafts) .archive-item .section-title {
    font-size: 18px;
    line-height: 1.25;
  }
  :is(.route-saved, .route-drafts) .archive-item .eyebrow {
    position: static;
    width: auto;
    font-size: 8px;
  }
  :is(.route-saved, .route-drafts) .archive-item .muted {
    font-size: 9px;
  }
  :is(.route-saved, .route-drafts) .archive-item .archive-excerpt {
    display: none;
  }
  :is(.route-saved, .route-drafts) .archive-item > .icon-btn {
    padding: 10px;
    min-width: 44px;
    height: 44px;
  }
  .route-notifications .notice-row {
    gap: 12px;
    font-size: 12px;
    padding-left: 12px;
  }
  .route-notifications .notice-row .avatar {
    width: 36px;
    height: 36px;
  }
  .route-notifications .notice-row .notice-preview {
    width: 56px;
    height: 44px;
  }
  .route-search .search-result {
    gap: 12px;
    padding-block: 16px;
  }
  .route-search .search-result b {
    font-size: 18px;
  }
  .route-search .search-result p {
    font-size: 10px;
  }
  .route-search .search-result img:not(.round) {
    width: 84px;
    height: 64px;
  }
  .empty-state {
    padding: 40px 16px;
  }
  .empty-state h2 {
    font-size: 25px;
  }
  .empty-state p {
    font-size: 13px;
  }
  :is(.route-not-found, .canvas:has(> .empty-state > [data-action="retry-route"])) > .empty-state {
    padding: 200px 24px 32px;
    min-height: 460px;
    margin: 0 auto;
    background-size: auto, cover;
  }
  .state-panel[aria-busy="true"] {
    padding: 16px;
    min-height: 260px;
  }
}
@media (max-width: 360px) {
  #overlay.search-overlay .search-tabs {
    gap: 16px;
  }
  #overlay.search-overlay .search-tabs button {
    font-size: 10px;
  }
  #overlay.search-overlay .search-help {
    gap: 8px;
    font-size: 9px;
  }
  #overlay.search-overlay .search-result img:not(.round) {
    width: 68px;
    height: 56px;
  }
  #overlay.search-overlay .search-result :is(img.round, .tag-image) {
    margin-inline: 12px;
  }
  :is(.route-saved, .route-drafts) .archive-item {
    grid-template-columns: 48px minmax(0, 1fr) 44px;
    gap: 8px;
  }
  :is(.route-saved, .route-drafts) .archive-item .section-title {
    font-size: 17px;
  }
}

/* Context actions follow the clicked control. app.js supplies measured
   left/top coordinates and viewport collision handling for this nonmodal
   native dialog. Modal form flows retain their existing separate surface. */
body:has(#overlay.context-popover[open]) {
  overflow: auto;
}
#overlay.context-popover {
  position: fixed;
  inset: auto;
  margin: 0;
  width: 320px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  padding: 12px;
  border-radius: 10px;
  z-index: 80;
  background: linear-gradient(135deg, #131a24, #0c131d);
  border-color: rgb(195 205 230 / 22%);
  box-shadow: 0 12px 32px rgb(0 0 0 / 40%);
}
#overlay.context-popover .overlay-head {
  border: 0;
  margin-bottom: 8px;
  padding-bottom: 0;
}
#overlay.context-popover .overlay-head h2 {
  font-size: 13px;
  color: #a9b3c6;
}
#overlay.context-popover .account-summary {
  gap: 12px;
  padding: 4px 8px 12px;
}
#overlay.context-popover .account-links :is(a, button) {
  min-height: 44px;
  padding: 10px 12px;
  gap: 12px;
  border-radius: 6px;
  border-bottom: 0;
  font-size: 12px;
}
#overlay.context-popover .account-links :is(a, button):focus-visible {
  outline-offset: -2px;
  background: rgb(135 148 255 / 12%);
}
#overlay.context-popover .account-links :is(
  [data-action="delete-post"], [data-action="delete-comment"],
  [data-action="block-author"], [data-action="ban-member"]
) {
  color: #e7877c;
}
#overlay.context-popover.reaction-popover {
  width: 346px;
  padding: 8px;
  border-radius: 16px;
}
#overlay.context-popover.reaction-popover .overlay-head {
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
  padding: 0;
}
#overlay.context-popover.reaction-popover .overlay-head h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
#overlay.context-popover.reaction-popover .reaction-options button {
  padding: 4px;
  justify-content: center;
  gap: 4px;
}
#overlay.context-popover.reaction-popover .overlay-head [data-action="close"] {
  display: none;
}
#overlay.context-popover.reaction-popover .account-links.reaction-options {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  padding-right: 0;
}
@media (max-width: 700px) {
  #overlay.context-popover.reaction-popover .account-links.reaction-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* Keep contextual actions together and reachable during viewport reflow. */
#overlay.post-menu-popover{width:280px;padding:8px}
#overlay.post-menu-popover .overlay-head{margin-bottom:4px;padding:4px 8px}
#overlay.post-menu-popover .account-links>a,#overlay.post-menu-popover .account-links>button{min-height:36px;padding:8px 10px;gap:8px;font-size:12px}
#overlay.post-menu-popover .overlay-head h2{font-size:13px}
#overlay.post-menu-popover .account-links svg{width:16px;height:16px}
@media(pointer:coarse){#overlay.post-menu-popover .account-links>a,#overlay.post-menu-popover .account-links>button{min-height:44px}}
.telegram-login-code{display:flex;flex-direction:column;gap:6px;text-align:center;margin:24px 0}
.telegram-login-code strong{font-size:30px;letter-spacing:.18em;font-variant-numeric:tabular-nums}
.telegram-login-code span{font-size:12px;overflow-wrap:anywhere;color:var(--muted,#9299a7)}
/* User request: pointer interactions have no blue focus frame. */
:is(#app,#overlay) :focus{outline:none!important}
html[data-input-modality="keyboard"] :is(#app,#overlay) :focus-visible{outline:2px solid #b5bac7!important;outline-offset:3px}
:is(#app,#overlay) :is(.reading-comment-form,.search-input):focus-within{border-color:var(--border,#252a33)!important}
#app .editor-page .editor-rich-text:focus{border-color:transparent!important}
#app .settings-form .field :is(input,select,textarea):focus-visible{border-color:var(--border,#252a33)!important}
#app .settings-switch-row input:focus-visible+.settings-switch{outline:none}
html[data-input-modality="keyboard"] #app .settings-switch-row input:focus-visible+.settings-switch{outline:2px solid #b5bac7;outline-offset:4px}
:is(#app,#overlay) select option:is(:hover,:focus-visible){outline:none!important}
