:root {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #6b6f76;
  --line: #deded8;
  --accent: #0f766e;
  --accent-strong: #0b5d57;
  --danger: #b42318;
  --shadow: 0 10px 24px rgba(32, 33, 36, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.chat-page {
  height: var(--chat-viewport-height, 100dvh);
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.9);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; color: var(--ink); }
.brand:hover { text-decoration: none; }
.logo {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--accent);
  font-weight: 900;
}
.nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nav a, button, .button {
  border: 0;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 7px;
  font: inherit;
  cursor: pointer;
}
.nav a:hover,
button:not(.primary):hover,
.button:not(.primary):hover {
  background: #f1f1ee;
  text-decoration: none;
}
.nav a.active {
  background: transparent;
  color: var(--ink);
}
.button.primary, button.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: white;
}
.button.primary:hover, button.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.nav a.new-question-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
}
.nav a.new-question-button svg {
  width: 21px;
  height: 21px;
  display: block;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  fill: none;
}
.nav a.new-question-button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  text-decoration: none;
}

[data-feed-search-toggle] {
  border: 1px solid var(--line);
}
.bordered-button {
  border: 1px solid var(--line);
}
.submit-button {
  width: min(100%, 400px);
  justify-self: center;
}
.vote-selected {
  background: #dff3df;
}
.admin-log {
  min-height: 140px;
  max-height: 320px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfbf8;
  color: var(--muted);
  white-space: pre-wrap;
}
.control-actions {
  display: grid;
  gap: 12px;
}
.control-actions article {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.control-actions h2,
.control-actions p {
  margin: 0;
}
.control-actions button {
  justify-self: start;
}
.control-tiles {
  margin-top: 18px;
}
.current-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 10px;
  background: transparent;
  border: none;
}
.user-menu-wrap {
  position: relative;
}
.user-menu {
  position: absolute;
  right: 0;
  top: 42px;
  width: 148px;
  display: none;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  padding: 6px;
}
.user-menu.open {
  display: grid;
}
.user-menu a,
.user-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 5px;
}
.user-menu-separator {
  height: 1px;
  margin: 5px 4px;
  background: var(--line);
}
.user-menu a:hover,
.user-menu button:hover {
  background: #f0f8f6;
  text-decoration: none;
}
.avatar-thumb {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 50%;
  object-fit: cover;
  background: var(--line);
}
.avatar-report-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.avatar-report-button:disabled {
  opacity: 1;
}
.chat-avatar-menu-wrap {
  width: 32px;
  display: block;
  z-index: 5;
}
.chat-avatar-menu-wrap:has(.chat-avatar-dropdown.open) {
  z-index: 35;
}
.chat-avatar-dropdown {
  left: 0;
  right: auto;
  top: 36px;
  z-index: 20;
}
.profile-avatar-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: center;
  gap: 0px;
}
.avatar-upload-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}
.avatar-guidelines-wrap {
  position: relative;
}
.avatar-guidelines-button {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  font-weight: 700;
  font-family: Georgia, serif;
}
.avatar-guidelines-popover {
  position: absolute;
  right: 0;
  top: 40px;
  z-index: 30;
  width: min(280px, 80vw);
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 0;
  border-radius: 7px;
  background: #1f2933;
  box-shadow: 0 14px 32px rgba(17, 24, 39, 0.22);
  color: white;
  font-size: 13px;
}
.avatar-guidelines-popover[hidden] {
  display: none;
}
.avatar-guidelines-popover::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 9px;
  width: 14px;
  height: 14px;
  background: #1f2933;
  transform: rotate(45deg);
}
.avatar-guidelines-popover a {
  color: white;
  text-decoration: underline;
}
.profile-avatar-button {
  width: 64px;
  height: 64px;
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--panel);
}
.profile-avatar-button img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
button:disabled { opacity: .45; cursor: default; }
main { width: min(980px, calc(100% - 28px)); margin: 26px auto 56px; }
.site-footer {
  width: min(980px, calc(100% - 28px));
  margin: -28px auto 28px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.feed-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.feed-title-row h1 {
  margin: 0;
}
.feed-search-tools,
.search-page-form {
  display: flex;
  align-items: start;
  justify-content: end;
  gap: 8px;
  margin-left: auto;
}
.feed-search-tools {
  flex: 0 1 auto;
  max-width: 500px;
}
.feed-search-tools.search-open {
  flex: 1 1 300px;
}
.feed-search-form {
  position: relative;
  flex: 1 1 220px;
  max-width: 400px;
}
.feed-search-form input,
[data-feed-search-toggle] {
  height: 42px;
}
.feed-search-form[hidden] {
  display: none;
}
.feed-search-hints {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 8;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  box-shadow: var(--shadow);
}
.feed-search-hints[hidden] {
  display: none;
}
.feed-search-hints a {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 7px 8px;
  border-radius: 5px;
  color: var(--ink);
}
.feed-search-hints a:hover {
  background: #f0f8f6;
  text-decoration: none;
}
.search-page-form {
  flex: 1 1 300px;
  max-width: 500px;
}
.search-page-form input {
  max-width: 400px;
}
.narrow { width: min(520px, calc(100% - 28px)); }
.settings-main {
  width: min(1660px, calc(100% - 28px));
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 400px));
  gap: 18px;
  align-items: start;
  justify-content: center;
  margin-bottom: 18px;
}
.settings-tile {
  width: min(400px, 100%);
}
.settings-grid .panel {
  margin-bottom: 0;
}
.settings-sessions {
  width: min(1236px, 100%);
  margin-left: auto;
  margin-right: auto;
}
.settings-data,
.settings-main .status {
  margin-left: auto;
  margin-right: auto;
}
.settings-data {
  display: grid;
  gap: 10px;
}
.settings-notifications {
  display: grid;
  gap: 12px;
}
.settings-data h2,
.settings-data h4,
.settings-data p,
.settings-notifications h2,
.settings-notifications p {
  margin: 0;
}
.settings-data h4 {
  margin-top: 8px;
}
.settings-data button {
  justify-self: start;
}
.settings-main h2,
.settings-main .muted {
  margin: 0;
}
.hero {
  min-height: calc(100vh - 58px);
  display: grid;
  align-content: center;
  gap: 28px;
}
.hero h1 { font-size: clamp(48px, 8vw, 92px); line-height: .95; margin: 0; letter-spacing: 0; }
.hero p { color: var(--muted); font-size: 20px; max-width: 640px; }
.panel, .feed-entry, .modal-body {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.panel { padding: 20px; margin-bottom: 18px; }
.compact-panel { padding: 14px; }
form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.checkbox-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 9px;
  color: var(--ink);
}
.checkbox-row input {
  width: auto;
  margin-top: 3px;
}
.toggle-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  color: var(--ink);
}
.toggle-row input {
  appearance: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #d1d5db;
  box-shadow: none;
  position: relative;
}
.toggle-row input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform 0.15s ease;
}
.toggle-row input:checked {
  background: var(--accent);
}
.toggle-row input:checked::before {
  transform: translateX(18px);
}
.notification-error {
  margin: -6px 0 6px;
  font-size: 12px;
}
.login-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: white;
}
.password-field {
  position: relative;
  display: block;
}
.password-field input {
  padding-right: 44px;
}
.password-reveal-button {
  position: absolute;
  right: 6px;
  top: 50%;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
}
.password-reveal-button:hover,
.password-reveal-button[aria-pressed="true"] {
  color: var(--accent);
  background: transparent;
}
.password-reveal-button svg {
  width: 20px;
  height: 20px;
  display: block;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
textarea { min-height: 90px; resize: vertical; }
td textarea {
  min-width: 260px;
  min-height: 32px;
  padding: 6px 12px;
}
.feed { display: grid; gap: 16px; }
.feed-entry { padding: 16px; display: grid; gap: 14px; }
.feed-loading {
  min-height: 24px;
  color: var(--muted);
  text-align: center;
}
.feed-loading.busy::after {
  content: "";
  display: inline-block;
  width: 1.5em;
  text-align: left;
  animation: status-dots 1.2s steps(4, end) infinite;
}
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.byline { color: var(--muted); font-size: 13px; }
.message { white-space: pre-wrap; line-height: 1.5; }
.feed-entry.selected-answer {
  animation: selected-answer-highlight 3500ms ease-in-out;
}
@keyframes selected-answer-highlight {
  0% { background: transparent; }
  15% { background: #fff6b8; }
  75% { background: #fff6b8; }
  100% { background: transparent; }
}
.question-message-link { display: block; color: var(--ink); text-decoration: none; white-space: pre-wrap; line-height: 1.5; }
.question-message-link:hover { color: var(--accent); text-decoration: underline; }
.see-answers-link { font-size: 12px; }
.question { border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.question-entry { border-bottom: 1px solid var(--line); padding: 12px 0; }
.question-entry:first-child { padding-top: 0; }
.question-entry:last-child { border-bottom: 0; padding-bottom: 0; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.action-spacer {
  width: 8px;
  height: 1px;
}
.quick-answer-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}
.question-hints {
  display: grid;
  gap: 4px;
  margin-top: -6px;
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  box-shadow: var(--shadow);
}
.question-hints[hidden] {
  display: none;
}
.question-hints a {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border-radius: 5px;
  color: var(--ink);
}
.question-hints a:hover {
  background: #f0f8f6;
  text-decoration: none;
}
.question-hints small {
  color: var(--muted);
  font-size: 12px;
}
.quick-answer-form .question-hints {
  grid-column: 1 / -1;
  margin-top: 0;
}
.quick-answer-form[hidden] {
  display: none;
}
.icon-button { width: 36px; height: 34px; padding: 0; display: grid; place-items: center; }
.menu-wrap { position: relative; }
.dropdown {
  position: absolute;
  right: 0;
  top: 38px;
  width: 132px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
}
.dropdown.open { display: grid; }
.muted { color: var(--muted); }
tr.current-session {
  background: #edf8ed;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
table { width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--line); }
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 720px; }
.admin-filter { padding: 12px; }
.admin-filter form { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.admin-filter label { width: min(220px, 100%); }
.admin-filter button { width: auto; }
.admin-filter-legend {
  flex-basis: 100%;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.admin-create-panel { padding: 12px; }
.admin-row-form { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.admin-row-form label { width: min(220px, 100%); }
.admin-row-form button { width: auto; }
.admin-row-form .status { margin: 0; min-height: 0; align-self: center; }
.admin-clear-link {
  align-self: end;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 4px;
  font-size: 14px;
}
.admin-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }
.disabled-link { opacity: .45; pointer-events: none; }
.actions-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions-cell button,
td[data-admin-resource] button {
  border: 1px solid var(--line);
}
.metadata-cell { max-width: 280px; overflow-wrap: anywhere; word-break: break-word; }
.admin-avatar-preview { width: 128px; height: 128px; display: block; border-radius: 50%; object-fit: cover; background: var(--line); }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; }
tr.suspended,
tr.hidden-record { background: #fff8e5; }
tr.pending-review { background: #f3f7ff; }
tr.deleted, tr.terminated, .feed-entry.deleted, .panel.deleted { color: var(--muted); background: #eeeeea; }
.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0,0,0,.35);
  padding: 18px;
  z-index: 40;
}
.modal.open { display: grid; }
.modal-body { width: min(460px, 100%); padding: 18px; }
.chat-list {
  display: grid;
  gap: 8px;
}
.chat-list-row {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfbf8;
}
.chat-list-row:hover {
  text-decoration: none;
  border-color: #b8d8d3;
  background: #f0f8f6;
}
.chat-list-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.chat-list-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}
.chat-list-time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.chat-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  height: calc(var(--chat-viewport-height, 100dvh) - var(--chat-topbar-height, 58px) - 52px);
  min-height: 0;
  margin-bottom: 16px;
}
.chat-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-title-row h1 {
  margin: 0;
}
.chat-back-link {
  width: 32px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  color: var(--accent);
  background: transparent;
  font-size: 42px;
  line-height: 1;
  transform: translateY(-6px);
}
.chat-back-link:hover {
  text-decoration: none;
  color: var(--accent-strong);
}
.chat-box { min-height: 0; overflow: auto; display: grid; align-content: start; gap: 0; padding: 12px; border: 1px solid var(--line); background: white; }
.chat-message { padding: 4px 6px; display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: start; border-radius: 7px; }
.chat-message.own-message { margin-left: 10px; }
.chat-message:hover { background: #f3f3f0; }
.chat-message-head { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: baseline; margin-bottom: 2px; }
.chat-message-name { color: var(--muted); font-size: 13px; }
.chat-message-time { color: #8a8a8a; font-size: 11px; white-space: nowrap; }
.chat-message-text {
  white-space: pre-wrap;
  width: fit-content;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  background: #dff1ec;
}
.chat-message.own-message .chat-message-text { background: #edf8f5; }
.chat-message-quote {
  margin: 6px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfbf8;
  white-space: pre-wrap;
  font: inherit;
}
.chat-form { gap: 8px; }
.chat-input-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: stretch; }
.chat-input-row button { min-width: 86px; }
.chat-status { margin: 0; color: #808080; font-size: 12px; }
.chat-status:empty { display: none; }
.status { min-height: 22px; color: var(--muted); }
.status:empty { display: none; }
.legal-page {
  max-width: 820px;
}
.legal-page h1,
.legal-page h2 {
  margin-top: 0;
}
.legal-page section {
  margin-top: 22px;
}
.legal-page p,
.legal-page li {
  line-height: 1.55;
}
.status.busy::after {
  content: "";
  display: inline-block;
  width: 1.5em;
  text-align: left;
  animation: status-dots 1.2s steps(4, end) infinite;
}

@keyframes status-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75%, 100% { content: "..."; }
}

@media (max-width: 680px) {
  .topbar { height: auto; padding: 12px 14px; align-items: flex-start; }
  .nav { justify-content: flex-end; }
  .nav a { padding: 7px 9px; }
  main { margin-top: 18px; }
  .chat-main {
    width: calc(100% - 16px);
    height: calc(var(--chat-viewport-height, 100dvh) - var(--chat-topbar-height, 58px) - 16px);
    min-height: 0;
    margin-top: 8px;
    margin-bottom: 8px;
    gap: 8px;
  }
  .chat-title-row h1 {
    font-size: 22px;
  }
  .chat-form {
    padding: 10px;
    margin-bottom: 0;
  }
  .admin-filter label { width: 100%; }
  .admin-row-form label { width: 100%; }
}
