:root {
  --bg: #f4f6f9;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #111111;
  --muted: #5f6368;
  --line: rgba(0, 0, 0, 0.12);
  --line-strong: rgba(0, 0, 0, 0.22);
  --label: #303134;
  --input-bg: #ffffff;
  --placeholder: #8a8d91;
  --divider-bg: #f4f6f9;
  --meta-surface: #ffffff;
  --meta-text: #1f1f1f;
  --accent: #2997ff;
  --accent-strong: #46a6ff;
  --danger: #d93025;
  --success: #1e8e3e;
  --warning: #b26a00;
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-dark: 0 14px 40px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 10% 8%, rgba(41, 151, 255, 0.1), transparent 25%),
    radial-gradient(circle at 90% 6%, rgba(68, 170, 255, 0.06), transparent 22%),
    linear-gradient(180deg, #ffffff 0%, #f4f6f9 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: pan-y;
}

body.theme-dark {
  --bg: #000000;
  --bg-soft: #0a0a0a;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.08);
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.18);
  --label: #d5d5da;
  --input-bg: rgba(0, 0, 0, 0.35);
  --placeholder: #8f9299;
  --divider-bg: rgba(4, 4, 4, 0.85);
  --meta-surface: rgba(255, 255, 255, 0.04);
  --meta-text: #d7d8dd;
  --danger: #ff6b6b;
  --success: #32d74b;
  --warning: #ffb020;
  --shadow-dark: 0 28px 70px rgba(0, 0, 0, 0.46);
  background: radial-gradient(circle at 10% 8%, rgba(41, 151, 255, 0.18), transparent 25%),
    radial-gradient(circle at 90% 6%, rgba(68, 170, 255, 0.1), transparent 22%),
    linear-gradient(180deg, #050505 0%, #000000 100%);
}

.page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 90%);
}

body.theme-dark .page-bg {
  background-image: linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

.shell {
  width: min(100% - 32px, 560px);
  margin: 34px auto;
  position: relative;
  z-index: 1;
}

.shell-wide {
  width: min(100% - 32px, 1240px);
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-dark);
  padding: 22px;
  backdrop-filter: blur(10px) saturate(130%);
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(1.55rem, 2vw, 2rem);
}

h2 {
  font-size: clamp(1.2rem, 1.7vw, 1.5rem);
}

h3 {
  font-size: 1.03rem;
}

.lead {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.section-head-split {
  align-items: center;
}

.dashboard {
  display: grid;
  gap: 18px;
}

form,
.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--label);
  font-size: 0.93rem;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 0.97rem;
  color: var(--text);
  background: var(--input-bg);
}

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(41, 151, 255, 0.8);
  box-shadow: 0 0 0 4px rgba(41, 151, 255, 0.22);
}

textarea {
  min-height: 94px;
  resize: vertical;
}

button,
.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .17s ease, background .17s ease, border-color .17s ease;
}

button:hover,
.btn:hover {
  transform: translateY(-1px);
}

button:disabled,
.btn:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

button,
.btn-primary {
  background: var(--accent);
  color: #fff;
}

button:hover,
.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-secondary {
  background: var(--input-bg);
  color: var(--text);
  border-color: var(--line);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.btn-google {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--line);
  color: var(--text);
}

.auth-divider {
  position: relative;
  text-align: center;
  margin: 14px 0 10px;
}

.auth-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 1px solid var(--line);
  transform: translateY(-50%);
}

.auth-divider span {
  position: relative;
  display: inline-block;
  padding: 0 10px;
  background: var(--divider-bg);
  color: var(--muted);
  font-size: 0.86rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status {
  margin-top: 10px;
  font-size: 0.92rem;
  line-height: 1.35;
}

.status-info {
  color: var(--muted);
}

.status-error {
  color: var(--danger);
}

.status-success {
  color: var(--success);
}

.hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.meta {
  background: var(--meta-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  display: grid;
  gap: 4px;
  color: var(--meta-text);
  line-height: 1.45;
}

.row {
  display: grid;
  grid-template-columns: minmax(132px, auto) 1fr;
  gap: 8px;
  font-size: 0.9rem;
}

.row span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

.linkline {
  margin-top: 14px;
  color: var(--muted);
}

.linkline a {
  color: #7ec1ff;
  font-weight: 600;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.profile-grid > * {
  min-width: 0;
}

.avatar-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}

.avatar-panel label,
.avatar-panel .meta {
  min-width: 0;
}

.avatar-panel input {
  min-width: 0;
  max-width: 100%;
}

.avatar-wrap {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
  position: relative;
}

.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 1.2rem;
  color: #d6ebff;
  background: radial-gradient(circle at 30% 20%, rgba(41, 151, 255, 0.35), rgba(41, 151, 255, 0.12));
}

.forum-layout {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.forum-side,
.forum-main {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px;
  min-width: 0;
}

.thread-list {
  margin-top: 10px;
  max-height: 460px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.thread-item {
  width: 100%;
  text-align: left;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
  color: var(--text);
  display: grid;
  gap: 4px;
  min-width: 0;
}

.thread-item.active {
  border-color: rgba(41, 151, 255, 0.55);
  box-shadow: inset 0 0 0 1px rgba(41, 151, 255, 0.4);
  background: rgba(41, 151, 255, 0.1);
}

.thread-title {
  font-weight: 600;
}

.thread-meta,
.subtle {
  color: var(--muted);
  font-size: 0.84rem;
}

.thread-details {
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.22);
  padding: 12px;
  display: grid;
  gap: 10px;
  min-width: 0;
  overflow-x: hidden;
}

.forum-article-body {
  min-width: 0;
}

.article-rating-section {
  min-width: 0;
  width: 100%;
}

.thread-details .article-rating-section {
  margin-top: 10px;
}

.thread-details.empty {
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.messages {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

.message-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.03);
  min-width: 0;
}

.message-author {
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.thread-title,
.thread-meta,
.thread-details > div,
.message-item > div {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.calendar-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.calendar-month {
  min-width: 164px;
  text-align: center;
  font-weight: 600;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekdays {
  margin-top: 4px;
  margin-bottom: 8px;
}

.calendar-weekday {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.calendar-cell {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 8px;
  text-align: left;
  position: relative;
}

.calendar-cell.muted {
  opacity: 0.45;
}

.calendar-cell.today {
  border-color: rgba(41, 151, 255, 0.5);
}

.calendar-cell.selected {
  box-shadow: inset 0 0 0 1px rgba(41, 151, 255, 0.7);
  background: rgba(41, 151, 255, 0.12);
}

.day-number {
  font-size: 0.88rem;
  font-weight: 600;
}

.day-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  position: absolute;
  bottom: 8px;
  left: 8px;
}

.day-count {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.event-list {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.event-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 6px;
}

.event-item h3 {
  font-size: 1rem;
}

.event-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  width: fit-content;
  color: #d6ecff;
  background: rgba(41, 151, 255, 0.12);
}

.event-create-wrap {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.cols-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.suggestions-layout {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.suggestion-list {
  margin-top: 8px;
  display: grid;
  gap: 10px;
}

.suggestion-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 6px;
}

.suggestion-status {
  font-size: 0.82rem;
  width: fit-content;
  border-radius: 999px;
  padding: 2px 9px;
  border: 1px solid var(--line);
}

.suggestion-status.new {
  color: #fce68f;
  border-color: rgba(252, 230, 143, 0.45);
}

.suggestion-status.in_review {
  color: #9ad3ff;
  border-color: rgba(154, 211, 255, 0.45);
}

.suggestion-status.accepted {
  color: #8ef0a2;
  border-color: rgba(142, 240, 162, 0.4);
}

.suggestion-status.rejected {
  color: #ffb4b4;
  border-color: rgba(255, 180, 180, 0.45);
}

.ceo-review {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

@media (max-width: 1080px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .forum-layout,
  .suggestions-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell,
  .shell-wide {
    width: min(100% - 22px, 100%);
    margin-top: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    flex: 1;
  }

  .card {
    border-radius: var(--radius-lg);
    padding: 16px;
  }

  .cols-2 {
    grid-template-columns: 1fr;
  }

  .calendar-cell {
    min-height: 72px;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* Cabinet home */
.dashboard-hub {
  gap: 20px;
}

.hub-hero {
  display: grid;
  gap: 16px;
}

.avatar-editor {
  display: block;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.avatar-editor-menu {
  width: min(100%, 760px);
}

.avatar-editor-toggle {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: transform .17s ease, background .17s ease, border-color .17s ease;
}

.avatar-editor-toggle:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--line-strong);
}

.avatar-editor-toggle::-webkit-details-marker {
  display: none;
}

.avatar-editor-toggle::marker {
  content: "";
}

.avatar-editor-toggle::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-top: -3px;
  transition: transform .18s ease;
}

.avatar-editor-menu[open] .avatar-editor-toggle::after {
  transform: rotate(225deg);
  margin-top: 3px;
}

.avatar-editor-toggle:focus-visible {
  outline: none;
  border-color: rgba(41, 151, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(41, 151, 255, 0.2);
}

.avatar-editor-panel {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.avatar-editor-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.avatar-editor-head .lead {
  margin: 6px 0 0;
}

.avatar-editor-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.avatar-editor-canvas-wrap {
  width: 152px;
  height: 152px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(10, 20, 38, 0.45);
}

.avatar-editor-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.avatar-editor-controls {
  display: grid;
  gap: 10px;
}

.avatar-editor-controls label {
  display: grid;
  gap: 6px;
}

.avatar-editor-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.avatar-editor-buttons .btn {
  flex: 1 1 150px;
  min-width: 0;
  white-space: normal;
  line-height: 1.15;
}

.avatar-editor-controls input[type="file"],
.avatar-editor-controls input[type="range"] {
  width: 100%;
  max-width: 100%;
}

.hub-profile-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.hub-entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.hub-entry {
  display: grid;
  gap: 10px;
  border-radius: var(--radius-xl);
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}

.hub-entry:hover {
  transform: translateY(-2px);
  border-color: rgba(41, 151, 255, 0.45);
  background: linear-gradient(180deg, rgba(41, 151, 255, 0.12), rgba(255, 255, 255, 0.03));
}

.hub-entry-kicker {
  color: #9acfff;
  font-weight: 600;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hub-entry-note {
  color: #c9e6ff;
  font-size: 0.9rem;
}

.hub-updates-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.hub-updates-layout.viewer-mode {
  grid-template-columns: minmax(0, 1fr);
}

.hub-updates-layout.ceo-mode {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
}

.hub-updates-feed,
.hub-updates-admin {
  border-radius: var(--radius-xl);
}

.news-list {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.news-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  line-height: 1.6;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
}

.news-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  background: linear-gradient(180deg, rgba(41, 151, 255, 0.08), rgba(255, 255, 255, 0.03));
}

.news-item-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.news-item-title {
  font-size: 1rem;
  line-height: 1.35;
}

.news-item-date,
.news-item-meta {
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.news-item-body {
  color: #dde6f1;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hub-updates-admin {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
}

.news-form {
  display: grid;
  gap: 12px;
}

.news-form textarea {
  min-height: 180px;
}

.news-form .status {
  margin-top: 0;
}

/* Forum screen */
.forum-shell-page {
  width: min(100% - 32px, 1380px);
}

.forum-screen {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(450px, 1fr) minmax(340px, 430px);
  gap: 16px;
  align-items: start;
}

.forum-sidebar,
.forum-board,
.forum-thread-panel {
  border-radius: var(--radius-lg);
  min-width: 0;
}

.forum-sidebar {
  display: grid;
  gap: 14px;
}

.forum-sidebar-head {
  display: grid;
  gap: 6px;
}

.forum-user-chip {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.forum-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 25% 25%, rgba(41, 151, 255, 0.5), rgba(41, 151, 255, 0.1));
  font-size: 0.8rem;
  font-weight: 700;
  color: #dff1ff;
}

.forum-user-name {
  font-weight: 600;
  line-height: 1.2;
}

.forum-filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.forum-filter-btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}

.forum-filter-btn.active {
  border-color: rgba(41, 151, 255, 0.55);
  background: rgba(41, 151, 255, 0.18);
  color: #d8edff;
}

.forum-board {
  display: grid;
  gap: 10px;
}

.forum-board-head {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: flex-start;
}

.forum-search-wrap {
  min-width: 260px;
}

.forum-search-wrap input {
  min-height: 40px;
}

.forum-thread-rows {
  display: grid;
  gap: 8px;
  max-height: min(70vh, 760px);
  overflow-y: auto;
}

.forum-thread-row {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  text-align: left;
}

.forum-thread-row:hover {
  border-color: rgba(41, 151, 255, 0.45);
  background: rgba(41, 151, 255, 0.08);
}

.forum-thread-row.active {
  border-color: rgba(41, 151, 255, 0.62);
  box-shadow: inset 0 0 0 1px rgba(41, 151, 255, 0.46);
  background: rgba(41, 151, 255, 0.13);
}

.forum-thread-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.forum-thread-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.forum-thread-topline {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.forum-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  border: 1px solid var(--line);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #d6eaff;
}

.forum-pill.clinical {
  border-color: rgba(102, 195, 117, 0.5);
  color: #baf8c1;
}

.forum-pill.education {
  border-color: rgba(114, 187, 255, 0.55);
  color: #b9e0ff;
}

.forum-pill.practice {
  border-color: rgba(250, 183, 95, 0.52);
  color: #ffd7a1;
}

.forum-pill.community {
  border-color: rgba(193, 161, 255, 0.56);
  color: #dbc8ff;
}

.forum-thread-panel {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 18px;
}

.forum-thread-panel .thread-details {
  min-height: 340px;
}

.forum-thread-panel .messages {
  max-height: min(38vh, 440px);
}

/* Events screen */
.events-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(310px, 360px);
  gap: 16px;
  align-items: start;
}

.events-calendar-card,
.events-feed-card,
.events-create-card {
  border-radius: var(--radius-lg);
}

.events-feed-card {
  display: grid;
  gap: 8px;
}

.events-feed-card .event-list {
  margin-top: 0;
  max-height: min(75vh, 860px);
  overflow-y: auto;
  padding-right: 2px;
}

.events-create-card {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 10px;
}

.event-reactions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

 .thread-details .forum-article-reactions {
   display: flex;
   flex-wrap: wrap;
   align-items: center;
   gap: 10px;
   width: 100%;
   box-sizing: border-box;
   position: static;
   clear: both;
   margin: 0;
   padding: 14px;
   border: 1px solid var(--line);
   border-radius: 16px;
   background: rgba(255, 255, 255, 0.02);
 }

 .thread-details .forum-article-reactions .article-rating-title {
   flex: 0 0 100%;
   margin: 0;
   color: var(--muted);
   font-size: 0.72rem;
   font-weight: 700;
   letter-spacing: 0.12em;
   text-transform: uppercase;
 }

.reaction-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 34px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
}

.reaction-btn.active {
  border-color: rgba(41, 151, 255, 0.6);
  background: rgba(41, 151, 255, 0.2);
  color: #d9eeff;
}

@media (max-width: 1340px) {
  .forum-screen {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  }

  .forum-thread-panel {
    position: static;
    grid-column: 1 / -1;
  }
}

@media (max-width: 1180px) {
  .events-screen {
    grid-template-columns: minmax(0, 1fr);
  }

  .events-create-card {
    position: static;
  }
}

@media (max-width: 960px) {
  .hub-entry-grid,
  .forum-screen {
    grid-template-columns: 1fr;
  }

  .hub-updates-layout,
  .hub-updates-layout.ceo-mode {
    grid-template-columns: 1fr;
  }

  .hub-updates-admin {
    position: static;
  }

  .forum-search-wrap {
    min-width: 0;
    width: 100%;
  }

  .forum-board-head {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 760px) {
  .hub-profile-wrap {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .news-item-topline {
    flex-direction: column;
    align-items: flex-start;
  }

  .news-item-date {
    white-space: normal;
  }

  .forum-thread-row {
    grid-template-columns: 1fr;
  }

  .forum-thread-avatar {
    display: none;
  }

  .forum-thread-topline {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .events-feed-card .event-list,
  .forum-thread-rows {
    max-height: none;
  }

  .event-reactions {
    flex-wrap: wrap;
  }
}

/* Responsive refinements for forum/events */
.topbar-actions .btn,
.topbar-actions button {
  white-space: nowrap;
}

.forum-screen {
  grid-template-areas: "sidebar board panel";
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr) minmax(320px, 380px);
}

.forum-sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 18px;
  align-self: start;
  max-height: calc(100vh - 52px);
  overflow: auto;
}

.forum-board {
  grid-area: board;
}

.forum-thread-panel {
  grid-area: panel;
  align-self: start;
  grid-column: auto;
}

.forum-thread-main .thread-meta {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.events-screen {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  align-items: start;
}

.events-calendar-card {
  grid-column: 1;
}

.events-feed-card {
  grid-column: 1;
}

.events-create-card {
  grid-column: 2;
  grid-row: 1 / span 2;
  max-height: calc(100vh - 52px);
  overflow: auto;
}

.events-screen.viewer-mode {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.events-screen.viewer-mode .events-calendar-card {
  grid-column: 1;
}

.events-screen.viewer-mode .events-feed-card {
  grid-column: 2;
}

@media (max-width: 1320px) {
  .forum-screen {
    grid-template-areas:
      "board panel"
      "sidebar sidebar";
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  }

  .forum-sidebar,
  .forum-thread-panel {
    position: static;
    max-height: none;
  }

  .forum-thread-panel {
    grid-column: auto;
  }
}

@media (max-width: 1180px) {
  .events-screen,
  .events-screen.viewer-mode {
    grid-template-columns: minmax(0, 1fr);
  }

  .events-calendar-card,
  .events-feed-card,
  .events-create-card {
    grid-column: 1;
    grid-row: auto;
  }

  .events-create-card {
    max-height: none;
  }
}

@media (max-width: 980px) {
  .forum-screen {
    grid-template-areas:
      "board"
      "panel"
      "sidebar";
    grid-template-columns: 1fr;
  }

  .forum-thread-panel {
    grid-column: auto;
  }

  .section-head,
  .section-head-split {
    flex-direction: column;
    align-items: flex-start;
  }

  .calendar-controls {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-month {
    min-width: 0;
    flex: 1;
  }
}

@media (max-width: 760px) {
  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
    width: 100%;
    gap: 8px;
  }

  .topbar-actions .btn,
  .topbar-actions button {
    width: 100%;
    min-width: 0;
    padding: 0 10px;
    font-size: 0.88rem;
  }

  .forum-sidebar,
  .forum-board,
  .forum-thread-panel {
    border-radius: var(--radius-md);
  }

  .forum-filter-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .forum-filter-btn {
    flex: 0 0 auto;
  }

  .forum-thread-panel .thread-details {
    min-height: 220px;
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 4px;
  }

  .calendar-weekday {
    font-size: 0.74rem;
  }

  .calendar-cell {
    min-height: 58px;
    padding: 6px;
  }

  .day-number {
    font-size: 0.8rem;
  }

  .day-dot {
    left: 6px;
    bottom: 6px;
  }

  .day-count {
    right: 6px;
    bottom: 4px;
    font-size: 0.7rem;
  }
}

/* UI hotfix pass */
.dashboard-hub .lead {
  max-width: 58ch;
}

.hub-hero {
  overflow: hidden;
}

.hub-profile-wrap {
  grid-template-columns: minmax(92px, 116px) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.dashboard-hub .avatar-wrap {
  width: 108px;
  height: 108px;
}

.hub-hero .meta {
  width: 100%;
  max-width: 560px;
  padding: 14px;
}

  .hub-hero .row {
    grid-template-columns: minmax(112px, auto) minmax(0, 1fr);
  }

.events-screen,
.events-screen > *,
.events-create-card,
.events-create-card > *,
.event-create-wrap,
.event-create-wrap > *,
.event-create-wrap form,
.event-create-wrap label {
  min-width: 0;
}

.events-create-card,
.event-create-wrap {
  overflow-x: hidden;
}

.event-create-wrap textarea,
.event-create-wrap input,
.event-create-wrap select {
  max-width: 100%;
}

.events-calendar-card .section-head-split {
  align-items: center;
}

.events-calendar-card .calendar-controls {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
}

.events-calendar-card .calendar-controls .btn {
  padding: 0;
}

@media (max-width: 920px) {
  .avatar-editor-menu {
    width: 100%;
  }

  .avatar-editor-panel {
    padding: 12px;
  }

  .avatar-editor-grid {
    grid-template-columns: 1fr;
  }

  .avatar-editor-canvas-wrap {
    width: 148px;
    height: 148px;
  }

  .avatar-editor-buttons .btn {
    flex-basis: 100%;
  }

  .hub-profile-wrap {
    grid-template-columns: 82px minmax(0, 1fr);
    align-items: center;
  }

  .dashboard-hub .avatar-wrap {
    width: 82px;
    height: 82px;
  }

  .hub-hero .meta {
    max-width: 100%;
  }
}

@media (max-width: 760px) {
  input,
  textarea,
  select {
    font-size: 16px;
  }

  .hub-hero .row {
    grid-template-columns: minmax(112px, auto) minmax(0, 1fr);
  }

  .events-calendar-card .calendar-controls {
    width: 100%;
  }

  .topbar-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 390px) {
  .topbar-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-hub .avatar-wrap {
    width: 84px;
    height: 84px;
  }

  .hub-profile-wrap {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .hub-hero .row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* Events form: keep datetime inputs readable in narrow tools column */
.event-create-wrap .cols-2-datetime {
  grid-template-columns: minmax(0, 1fr);
}

.event-create-wrap input[type="datetime-local"] {
  min-width: 0;
}

/* Native light palette refinements */
body:not(.theme-dark) .avatar-wrap,
body:not(.theme-dark) .forum-side,
body:not(.theme-dark) .forum-main,
body:not(.theme-dark) .thread-item,
body:not(.theme-dark) .message-item,
body:not(.theme-dark) .calendar-cell,
body:not(.theme-dark) .event-item,
body:not(.theme-dark) .event-create-wrap,
body:not(.theme-dark) .suggestion-item,
body:not(.theme-dark) .avatar-editor-toggle,
body:not(.theme-dark) .avatar-editor-panel,
body:not(.theme-dark) .forum-user-chip,
body:not(.theme-dark) .forum-thread-row,
body:not(.theme-dark) .reaction-btn {
  background: #ffffff;
}

body:not(.theme-dark) .thread-details {
  background: #f8fafc;
}

body:not(.theme-dark) .avatar-fallback {
  color: #184a7a;
  background: radial-gradient(circle at 30% 20%, rgba(41, 151, 255, 0.22), rgba(41, 151, 255, 0.08));
}

body:not(.theme-dark) .event-tag,
body:not(.theme-dark) .forum-pill {
  color: #184a7a;
}

body:not(.theme-dark) .hub-entry-kicker,
body:not(.theme-dark) .hub-entry-note,
body:not(.theme-dark) .news-item-body,
body:not(.theme-dark) .forum-user-avatar,
body:not(.theme-dark) .forum-thread-avatar,
body:not(.theme-dark) .forum-filter-btn.active,
body:not(.theme-dark) .reaction-btn.active {
  color: #163b60;
}

body:not(.theme-dark) .forum-thread-avatar {
  background: rgba(41, 151, 255, 0.2);
}

/* Public author links shared by Forum and Events */
.author-link {
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border-radius: 999px;
  outline: none;
}

.author-link:hover {
  text-decoration: underline;
}

.author-link:focus-visible {
  box-shadow: 0 0 0 3px rgba(41, 151, 255, 0.24);
}

.forum-v3-article .author-link,
.event-item .author-link {
  position: relative;
  z-index: 2;
}

body:not(.theme-dark) .author-link {
  color: #0969da;
}
