*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Loading overlay ── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(98, 87, 127, .72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity .4s;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  color: #F4F0F7;
  font-size: .95rem;
  letter-spacing: .03em;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(244, 240, 247, .2);
  border-top-color: #D0AE7B;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

:root {
  --main:   #F4F0F7;
  --accent: #62577F;
  --mid:    #6F6B72;
}

html {
  height: 100%;
  overflow: hidden;
  /* Почти весь текст в проекте задан в rem, поэтому базовый font-size здесь -
     единственный рычаг, которым можно сразу и пропорционально уменьшить всё
     на мобильном и увеличить на десктопе, не трогая каждое правило отдельно. */
  font-size: 15px;
}

@media (min-width: 769px) {
  html {
    font-size: 17px;
  }
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, #FCFAFD 0%, var(--main) 60%, #D0AE7B 100%);
  position: fixed;
  inset: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Auth screen ── */
#auth-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #FCFAFD 0%, var(--main) 60%, #D0AE7B 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

#auth-screen.hidden {
  display: none;
}

.auth-box {
  width: 100%;
  max-width: 340px;
  padding: 32px;
  text-align: center;
}

.auth-box h2 {
  color: #20202A;
  font-size: 1.2rem;
  margin-bottom: 20px;
}

.auth-box input {
  width: 100%;
  background: #fff;
  border: 1.5px solid rgba(111, 107, 114, .25);
  border-radius: 24px;
  color: #20202A;
  padding: 11px 16px;
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(111, 107, 114, .07);
  transition: border-color .2s, box-shadow .2s;
}

.auth-box input:focus {
  border-color: var(--mid);
  box-shadow: 0 2px 12px rgba(111, 107, 114, .18);
}

.auth-error {
  color: #b0413e;
  font-size: .82rem;
  min-height: 1.2em;
  margin-bottom: 8px;
}

.auth-forgot {
  text-align: right;
  margin: -6px 0 10px;
  font-size: .8rem;
}
.auth-forgot a {
  color: var(--mid);
  text-decoration: none;
}
.auth-forgot a:hover { text-decoration: underline; }

.consent-block {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  font-size: .78rem;
  color: var(--mid);
  line-height: 1.4;
  margin-bottom: 10px;
  cursor: pointer;
}

.consent-block input[type="checkbox"] {
  width: auto;
  margin: 2px 0 0;
  flex-shrink: 0;
}

.consent-block a {
  color: #6F6B72;
  text-decoration: underline;
}

.legal-disclaimer {
  text-align: center;
  font-size: .74rem;
  color: var(--mid);
  margin-top: 10px;
}
.legal-disclaimer a {
  color: var(--mid);
  text-decoration: underline;
}

#auth-submit-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent) 0%, #B58A58 100%);
  border: none;
  border-radius: 26px;
  color: #F4F0F7;
  padding: 12px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(98, 87, 127, .22);
  transition: opacity .2s;
}

#auth-submit-btn:hover {
  opacity: .9;
}

.auth-switch {
  margin-top: 16px;
  font-size: .82rem;
  color: var(--mid);
}

.auth-switch a {
  color: #B58A58;
  font-weight: 600;
  text-decoration: none;
  margin-left: 4px;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* ── App shell: sidebar + topbar (shared across every page) ── */
.app-shell-body {
  overflow: hidden;
  align-items: stretch;
}

.app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid rgba(111, 107, 114, .12);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  margin-bottom: 28px;
}

.sidebar-logo {
  /* Icon-only monogram by default (mobile's cramped horizontal bar has no
     room for the wordmark). Desktop switches to the full lockup - icon +
     "Центр развития компетенций аутсорсеров «Бета»" - below. */
  width: 34px;
  height: 45px;
  flex-shrink: 0;
  background-image: url('/logo-icon-dark.png?v=1');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

@media (min-width: 769px) {
  .sidebar-logo {
    /* Matches the full lockup artwork's own aspect ratio (878:927) so the
       wordmark stays legible instead of being squeezed. */
    width: 168px;
    height: 177px;
    background-image: url('/logo-full-dark.png?v=2');
  }
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  color: #20202A;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  text-align: left;
}

.sidebar-nav-item:hover {
  background: rgba(111, 107, 114, .08);
}

.sidebar-nav-item.active {
  background: rgba(111, 107, 114, .12);
  color: var(--accent);
  font-weight: 700;
}

/* «Афиша мероприятий» nav item - click opens a flyout popup instead of
   navigating, same markup pasted into every page's sidebar (see
   events-widget.js, shared across all 4 pages). */
.events-nav-wrap {
  position: relative;
}

.events-popup {
  /* position: fixed (not absolute) and moved to a direct child of <body> by
     events-widget.js when opened, with top/left computed from the trigger's
     getBoundingClientRect() - .sidebar has overflow-y: auto, which per spec
     forces overflow-x: auto too and was silently clipping an absolutely
     positioned popup that tried to extend past the sidebar's own box. */
  position: fixed;
  width: 280px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(111, 107, 114, .18);
  padding: 14px;
  z-index: 1000;
}

.events-popup-title {
  font-size: .82rem;
  font-weight: 700;
  color: #20202A;
  margin-bottom: 10px;
}

.events-popup-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.events-popup-empty {
  font-size: .82rem;
  color: var(--mid);
}

.events-popup-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.events-popup-item-date {
  flex-shrink: 0;
  font-size: .76rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  padding-top: 1px;
}

.events-popup-item-title {
  font-size: .85rem;
  color: #20202A;
  line-height: 1.3;
}

.events-popup-item-location {
  font-size: .76rem;
  color: var(--mid);
  margin-top: 2px;
}

.events-popup-edit-btn {
  width: 100%;
  margin-top: 12px;
  background: rgba(111, 107, 114, .1);
  color: var(--mid);
  border: 1px solid rgba(111, 107, 114, .3);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: .8rem;
  font-family: inherit;
}
.events-popup-edit-btn:hover { background: rgba(111, 107, 114, .18); }

.sidebar-nav-icon {
  flex-shrink: 0;
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(111, 107, 114, .12);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 28px;
  border-bottom: 1px solid rgba(111, 107, 114, .1);
}

.topbar-search-wrap {
  position: relative;
  flex: 1;
  max-width: 440px;
}

.topbar-search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--mid);
  pointer-events: none;
}

.topbar-search {
  width: 100%;
  background: #FCFAFD;
  border: 1.5px solid rgba(111, 107, 114, .18);
  border-radius: 22px;
  padding: 10px 18px 10px 40px;
  font-size: .88rem;
  font-family: inherit;
  color: #20202A;
  outline: none;
  box-sizing: border-box;
}
.topbar-search:focus { border-color: var(--mid); }

.topbar-new-post {
  background: linear-gradient(135deg, var(--accent) 0%, #B58A58 100%);
  border: none;
  border-radius: 22px;
  color: #F4F0F7;
  padding: 10px 20px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* Generic scrollable content area to the right of the sidebar/under the topbar */
.page-content {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  padding: 26px 32px 40px;
}

/* Compact site-wide footer - same markup pasted into every page's .main-area,
   sits below the scrollable content the same way .topbar sits above it. */
.site-footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 20px;
  padding: 7px 28px;
  background: var(--accent);
  color: rgba(244, 240, 247, .8);
  font-size: .72rem;
  line-height: 1.45;
}
.site-footer-org {
  display: flex;
  flex-direction: column;
}
.site-footer-org strong {
  color: #F4F0F7;
  font-weight: 600;
}
.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 14px;
}
.site-footer-links a,
.site-footer-copyright {
  color: rgba(244, 240, 247, .8);
}
.site-footer-links a { text-decoration: underline; }
.site-footer-links a:hover { color: #F4F0F7; }
.site-footer-copyright-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.site-footer-ai-note {
  font-size: .5rem;
  color: rgba(244, 240, 247, .12);
}
.site-footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.site-footer-social { display: flex; gap: 10px; }
.site-footer-social a {
  color: rgba(244, 240, 247, .8);
  display: flex;
}
.site-footer-social a:hover { color: #F4F0F7; }
.site-footer-social svg { width: 14px; height: 14px; }

/* Desktop: .site-footer-details is a transparent wrapper (display: contents)
   so .site-footer-org/-links/-right stay direct flex children of
   .site-footer, same row layout as before the wrapper existed - the
   collapse toggle below only takes effect on mobile. */
.site-footer-toggle-checkbox { display: none; }
.site-footer-summary { display: none; }
.site-footer-details { display: contents; }

@media (max-width: 768px) {
  /* The full footer (org details, 3 legal links, social icons) was eating
     close to half the screen on a phone. Collapsed by default down to one
     compact line; tap it to expand the rest in place - .page-content
     already scrolls internally (untouched here, unlike the sticky-topbar
     attempt that broke real Safari), so it just gets a bit shorter when
     the footer grows. */
  .site-footer {
    flex-direction: column;
    padding: 4px 16px;
  }
  .site-footer-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 5px 0;
    font-size: .68rem;
    color: rgba(244, 240, 247, .85);
    cursor: pointer;
  }
  .site-footer-toggle-icon {
    font-size: .55rem;
    transition: transform .15s;
  }
  .site-footer-toggle-checkbox:checked ~ .site-footer-summary .site-footer-toggle-icon {
    transform: rotate(180deg);
  }
  .site-footer-details {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-bottom: 6px;
  }
  .site-footer-toggle-checkbox:checked ~ .site-footer-details {
    display: flex;
  }
  .site-footer-org { align-items: center; }
  .site-footer-links { justify-content: center; }
  .site-footer-copyright-col { align-items: center; }
  /* Even more of an afterthought on mobile than on desktop. */
  .site-footer-ai-note { font-size: .4rem; }
}

@media (max-width: 768px) {
  /* The fixed-width column sidebar doesn't fit a phone screen - it becomes a
     bottom tab bar instead (icon + visible label per item, like a native
     app), pinned below the content via flex order rather than hiding any of
     its links - every page and the logout button stay reachable. The brand
     mark drops out here; it isn't part of a bottom tab bar's job and there's
     no room to show it without crowding the labels. */
  .app-shell { flex-direction: column; }
  .main-area { order: 1; }
  .sidebar {
    order: 2;
    width: 100%;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    border-right: none;
    border-top: 1px solid rgba(111, 107, 114, .12);
    overflow-x: auto;
    gap: 0;
  }
  .sidebar-brand { display: none; }
  .sidebar-nav, .sidebar-bottom {
    flex-direction: row;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex-shrink: 0;
    gap: 0;
  }
  .sidebar-nav-item {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 54px;
    padding: 6px 4px;
    border-radius: 10px;
  }
  .sidebar-nav-icon .icon-svg { width: 21px; height: 21px; }
  .sidebar-nav-label {
    /* Visible again here (desktop hides nothing - this just undoes the old
       icon-only clip-to-1px trick) since a bottom tab bar with unlabeled
       icons is exactly what read as unclear on a real phone. */
    font-size: .58rem;
    line-height: 1.15;
    text-align: center;
  }
  .topbar { padding: 14px 16px; flex-wrap: wrap; }
  .topbar-user-pill { max-width: 44px; }
  #topbar-user-name, .topbar-user-chevron { display: none; }
  .page-content { padding: 18px 16px 32px; }
  /* Reverted: making .main-area scroll (footer "unpinned", topbar sticky)
     broke mobile Safari - a white sticky-topbar layer stuck covering
     ~half the screen, unscrollable. Footer stays pinned on mobile like
     it always was; not worth re-attempting without a real device to test
     against. */
}

/* ── Header (legacy top-bar pages not yet migrated to .app-shell) ── */
header {
  width: 100%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #B58A58 100%);
  display: flex;
}

.header-inner {
  width: 100%;
  padding: 28px 32px 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-icon {
  width: 92px;
  height: 92px;
  flex-shrink: 0;
  /* Full lockup (emblem + "Центр развития компетенций аутсорсеров «Бета»"
     wordmark), not just the emblem - white cutout of logo.jpg, alpha-matted
     from the navy line art and tightly cropped to its own content so the
     text isn't wasted-pixel-tiny at this size. Matches betazentr.tilda.ws,
     which shows the full lockup in its header rather than an icon-only mark.
     Regenerate from logo.jpg (luminance -> alpha, fill white, crop to
     alpha>10 bbox with padding) if the source logo is ever replaced. */
  background-image: url('/logo-white.png?v=1');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* The auth screen sits on a light background (not the dark header), so it
   needs the original navy logo instead of the white cutout above. */
.auth-box .brand-icon {
  background-image: url('/logo-icon.png?v=2');
}

.brand-text {
  min-width: 0;
}

.brand-name {
  color: #F4F0F7;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: .03em;
  line-height: 1.2;
  overflow-wrap: break-word;
}

.brand-sub {
  color: #D0AE7B;
  font-size: .85rem;
  margin-top: 2px;
}

/* When "БетаУм" is dropped from the header (everywhere except the assistant
   page), .brand-sub is the only label left - style it as the primary
   heading instead of a secondary caption. */
.brand-sub-solo {
  color: #F4F0F7;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: .02em;
  margin-top: 0;
}

#clear-btn {
  background: rgba(244, 240, 247, .12);
  border: 1px solid rgba(244, 240, 247, .25);
  color: #D0AE7B;
  padding: 5px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: .78rem;
  letter-spacing: .02em;
  transition: background .2s, border-color .2s;
}
#clear-btn:hover {
  background: rgba(244, 240, 247, .22);
  border-color: rgba(244, 240, 247, .45);
}

/* Scoped to .dropdown-panel so this beats the generic
   .dropdown-panel select styling (a plain class selector alone is less
   specific than that ancestor+type rule and would otherwise lose). */
.dropdown-panel .nav-select {
  width: auto;
  background: rgba(111, 107, 114, .1);
  border: 1px solid rgba(111, 107, 114, .25);
  border-radius: 20px;
  color: var(--accent);
  padding: 5px 10px;
  cursor: pointer;
  font-size: .78rem;
  font-family: inherit;
  margin-right: 8px;
  margin-bottom: 0;
}

.nav-select option {
  color: #20202A;
}

#upload-btn {
  width: auto;
  background: rgba(111, 107, 114, .1);
  border: 1px solid rgba(111, 107, 114, .25);
  color: var(--accent);
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
  transition: background .2s, border-color .2s;
  margin-right: 8px;
}
#upload-btn:hover {
  background: rgba(111, 107, 114, .18);
  border-color: rgba(111, 107, 114, .4);
}
#upload-btn:disabled {
  opacity: .5;
  cursor: default;
}

/* ── Messages ── */
#messages {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

#empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--mid);
  pointer-events: none;
  padding-bottom: 60px;
}

#empty-state .empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--mid) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .35;
}

#empty-state p {
  font-size: .9rem;
  opacity: .7;
}

/* ── Bubbles ── */
.msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 82%;
}

.msg.user  { align-self: flex-end; align-items: flex-end; }
.msg.bot   { align-self: flex-start; }

.label {
  font-size: .7rem;
  color: var(--mid);
  padding: 0 6px;
  opacity: .8;
}

.msg-time {
  margin-left: 6px;
  opacity: .7;
}

.bubble {
  padding: 11px 16px;
  border-radius: 18px;
  font-size: .9rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .bubble {
  background: linear-gradient(135deg, var(--accent) 0%, #B58A58 100%);
  color: #F4F0F7;
  border-bottom-right-radius: 5px;
  box-shadow: 0 2px 12px rgba(98, 87, 127, .18);
}

.msg.bot .bubble {
  background: linear-gradient(160deg, #FCFAFD 0%, #FCFAFD 100%);
  color: #20202A;
  border: 1px solid rgba(111, 107, 114, .15);
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 10px rgba(111, 107, 114, .08);
  /* content is HTML from marked.parse(), not raw text - the inherited
     pre-wrap from .bubble would render marked's own inter-tag newlines
     as extra blank lines on top of the paragraph/list margins below */
  white-space: normal;
}

/* markdown inside bot bubbles */
.msg.bot .bubble p  { margin: 0 0 .5em; }
.msg.bot .bubble p:last-child { margin-bottom: 0; }
.msg.bot .bubble ul,
.msg.bot .bubble ol { margin: .25em 0 .5em 1.2em; padding: 0; }
.msg.bot .bubble li { margin-bottom: .2em; }
.msg.bot .bubble strong { font-weight: 600; }
.msg.bot .bubble a  { color: #6F6B72; }

.sources {
  font-size: .75rem;
  color: var(--mid);
  opacity: .8;
  padding: 0 6px;
  word-break: break-word;
}

.sources a {
  color: #6F6B72;
  text-decoration: underline;
}

.feedback-block {
  display: flex;
  gap: 6px;
  padding: 0 6px;
}

.feedback-btn {
  background: none;
  border: 1px solid rgba(111, 107, 114, .2);
  border-radius: 8px;
  font-size: .82rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  opacity: .6;
  transition: opacity .15s, border-color .15s;
}

.feedback-btn:hover:not(:disabled) {
  opacity: 1;
  border-color: var(--mid);
}

.feedback-btn:disabled {
  cursor: default;
}

.feedback-btn.feedback-selected {
  opacity: 1;
  border-color: var(--mid);
  background: rgba(111, 107, 114, .12);
}

/* thinking animation */
.thinking .bubble {
  color: #D0AE7B;
  font-style: italic;
}

.dot-flash {
  display: inline-flex;
  gap: 4px;
  vertical-align: middle;
  margin-left: 6px;
}

.dot-flash span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mid);
  opacity: .4;
  animation: blink 1.2s ease-in-out infinite;
}
.dot-flash span:nth-child(2) { animation-delay: .2s; }
.dot-flash span:nth-child(3) { animation-delay: .4s; }

@keyframes blink { 0%,80%,100%{opacity:.2} 40%{opacity:1} }

/* ── Input ── */
#input-area {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  flex-shrink: 0;
  padding: 12px 20px 28px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#user-input {
  flex: 1;
  background: #fff;
  border: 1.5px solid rgba(111, 107, 114, .25);
  border-radius: 23px;
  color: #20202A;
  padding: 11px 16px;
  font-size: .9rem;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
  min-height: 46px;
  max-height: 160px;
  overflow-y: auto;
  box-shadow: 0 2px 8px rgba(111, 107, 114, .07);
  transition: border-color .2s, box-shadow .2s;
}

#user-input::placeholder { color: #D0AE7B; }

#user-input:focus {
  border-color: var(--mid);
  box-shadow: 0 2px 12px rgba(111, 107, 114, .18);
}

#send-btn {
  background: linear-gradient(135deg, var(--accent) 0%, #B58A58 100%);
  border: none;
  border-radius: 50%;
  color: #F4F0F7;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(98, 87, 127, .22);
  transition: opacity .2s, transform .1s;
}
#send-btn:disabled { opacity: .45; cursor: default; }
#send-btn:not(:disabled):hover { opacity: .88; }
#send-btn:not(:disabled):active { transform: scale(.95); }

/* ── Nav buttons / dropdowns ── */
.nav-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hidden { display: none !important; }

/* The rounded, semi-transparent "plate" look shared by every pill-style
   button on the site - the active sidebar-nav-item, ☰ Меню, etc. */
.nav-btn {
  position: relative;
  background: rgba(111, 107, 114, .1);
  border: 1px solid rgba(111, 107, 114, .25);
  color: var(--accent);
  padding: 5px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
  transition: background .2s, border-color .2s;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.request-done-btn {
  width: auto !important;
  margin-top: 8px;
  background: rgba(46, 125, 79, .12) !important;
  color: #2e7d4f !important;
  border: 1px solid rgba(46, 125, 79, .3);
  padding: 5px 12px !important;
  font-size: .75rem !important;
  border-radius: 8px !important;
}

.request-done-badge {
  display: inline-block;
  margin-top: 8px;
  color: #2e7d4f;
  font-size: .75rem;
  font-weight: 600;
}

.nav-btn:hover {
  background: rgba(111, 107, 114, .18);
  border-color: rgba(111, 107, 114, .4);
}

.dropdown-wrap {
  position: relative;
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  max-height: 400px;
  overflow-y: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(98, 87, 127, .25);
  padding: 16px;
  z-index: 100;
  text-align: left;
}

.dropdown-panel h3 {
  color: #20202A;
  font-size: .9rem;
  margin-bottom: 12px;
}

.dropdown-panel input,
.dropdown-panel textarea,
.dropdown-panel select,
.menu-accordion-content input,
.menu-accordion-content textarea,
.menu-accordion-content select {
  width: 100%;
  background: #FCFAFD;
  border: 1.5px solid rgba(111, 107, 114, .2);
  border-radius: 10px;
  color: #20202A;
  padding: 9px 12px;
  font-size: .85rem;
  font-family: inherit;
  outline: none;
  margin-bottom: 10px;
  resize: none;
  box-sizing: border-box;
}

/* Single-line fields read as pills to match the reference site; a
   multi-line textarea stays rectangular (a pill-shaped textarea looks odd
   once it wraps to several lines), so it keeps the base radius above. */
.dropdown-panel input,
.dropdown-panel select,
.menu-accordion-content input,
.menu-accordion-content select {
  border-radius: 20px;
}

.dropdown-panel input:focus,
.dropdown-panel textarea:focus,
.menu-accordion-content input:focus,
.menu-accordion-content textarea:focus {
  border-color: var(--mid);
}

.dropdown-panel button,
.menu-accordion-content button {
  width: 100%;
  background: linear-gradient(135deg, var(--accent) 0%, #B58A58 100%);
  border: none;
  border-radius: 22px;
  color: #F4F0F7;
  padding: 10px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}

.consult-success {
  color: #2e7d4f;
  font-size: .82rem;
  min-height: 1.2em;
  margin-bottom: 8px;
}

.dropdown-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dropdown-list-item {
  background: #FCFAFD;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: .82rem;
  color: #20202A;
  transition: background .15s;
}
.dropdown-list-item:hover {
  background: #D0AE7B;
}

.dropdown-list-item .item-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.dropdown-list-item .item-meta {
  font-size: .72rem;
  color: var(--mid);
}

.doc-list-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  cursor: default;
}
.doc-list-item .doc-item-main { width: 100%; min-width: 0; }
.doc-category-select {
  font-size: .72rem;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid rgba(111, 107, 114, .25);
  background: #fff;
  color: #20202A;
  max-width: 100%;
}
.doc-downloadable-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  color: var(--mid);
  cursor: pointer;
}
.doc-downloadable-toggle input { width: auto; margin: 0; }

.dropdown-panel-wide {
  width: 420px;
}

/* ── Unified "☰ Меню" accordion ── */
.menu-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 4px 4px 14px;
  border-bottom: 1px solid rgba(111, 107, 114, .12);
  margin-bottom: 4px;
}
.menu-row select {
  flex: 1;
  min-width: 0;
  width: auto;
  margin-bottom: 0;
}
.menu-row button {
  width: auto !important;
  flex-shrink: 0;
}

.menu-accordion-item {
  border-bottom: 1px solid rgba(111, 107, 114, .12);
}
.menu-accordion-item:last-of-type {
  border-bottom: none;
}

.dropdown-panel .menu-accordion-toggle {
  width: 100%;
  background: none;
  border: none;
  color: #20202A;
  text-align: left;
  padding: 11px 4px;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  display: block;
  position: relative;
}
.dropdown-panel .menu-accordion-toggle:hover {
  color: var(--mid);
}

.menu-accordion-content {
  padding: 0 4px 14px;
}
.menu-accordion-content h3 {
  margin-top: 0;
}

.menu-divider {
  height: 1px;
  background: rgba(111, 107, 114, .12);
  margin: 4px 0 8px;
}

.dropdown-panel .menu-action-btn {
  width: 100%;
  background: none;
  border: none;
  color: #20202A;
  text-align: left;
  padding: 10px 4px;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  display: block;
  text-decoration: none;
}
.dropdown-panel .menu-action-btn:hover {
  color: var(--mid);
}

.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: default;
}

.admin-user-info {
  flex: 1;
  min-width: 0;
}

.admin-user-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.admin-action-btn {
  width: auto !important;
  padding: 5px 10px !important;
  font-size: .72rem !important;
  border-radius: 8px !important;
}

.admin-action-btn.role {
  background: rgba(111, 107, 114, .12) !important;
  color: var(--mid) !important;
  border: 1px solid rgba(111, 107, 114, .3);
}

.admin-action-btn.block {
  background: rgba(176, 65, 62, .12) !important;
  color: #b0413e !important;
  border: 1px solid rgba(176, 65, 62, .3);
}

.admin-action-btn.unblock {
  background: rgba(46, 125, 79, .12) !important;
  color: #2e7d4f !important;
  border: 1px solid rgba(46, 125, 79, .3);
}

.admin-blocked-badge {
  color: #b0413e;
  font-size: .72rem;
  font-weight: 600;
}

.dropdown-list-empty {
  color: var(--mid);
  font-size: .82rem;
  text-align: center;
  padding: 12px 0;
}

/* ── Modals (conversation history + source preview) ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(98, 87, 127, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
}

.modal-box {
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  background: #fff;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(111, 107, 114, .15);
}

.modal-header h3 {
  color: #20202A;
  font-size: 1rem;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--mid);
  cursor: pointer;
}

#conversation-modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-body-preview {
  padding: 20px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .85rem;
  line-height: 1.6;
  color: #20202A;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(111, 107, 114, .15);
  display: flex;
  justify-content: flex-end;
}

.modal-download-btn {
  background: linear-gradient(135deg, var(--accent) 0%, #B58A58 100%);
  color: #F4F0F7;
  border: none;
  padding: 8px 18px;
  border-radius: 20px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(98, 87, 127, .18);
}

/* iOS Safari auto-zooms the page on focus of any text input/textarea with
   font-size under 16px - that zoom-and-imperfect-reset is what caused the
   layout to "drift" and "spill off screen" on mobile. Force 16px on mobile only. */
@media (max-width: 768px) {
  #user-input,
  .auth-box input,
  .dropdown-panel input,
  .dropdown-panel textarea {
    font-size: 16px;
  }

  /* The big Stepik-style header title comfortably fits a wide desktop header
     but is too wide for a narrow phone screen at the same size - scale it
     back down on mobile specifically (separate from the general mobile/desktop
     root font-size split, which alone wasn't enough to keep it on one line). */
  .brand-name {
    font-size: 1.15rem;
  }
  .brand-sub {
    font-size: .72rem;
  }
  .brand-sub-solo {
    font-size: 1rem;
  }
  .header-inner {
    padding: 18px 20px 18px 0;
  }
  .brand-icon {
    width: 62px;
    height: 62px;
  }

  /* Dropdown panels are absolutely positioned relative to their toggle button
     with a fixed width - on a narrow screen that easily pushes them past the
     viewport edge with no way to scroll/move them into view. Detach them from
     the button and center them as a fixed, screen-sized modal instead. */
  .dropdown-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: 92vw;
    max-width: 360px;
    max-height: 80dvh;
  }
}
