:root {
  --page: #eef5ff;
  --surface: #ffffff;
  --surface-soft: #f6f8fc;
  --ink: #172033;
  --muted: #586477;
  --line: #cfd8e6;
  --blue: #225bd6;
  --blue-dark: #17439f;
  --pink: #d92b75;
  --green: #17834f;
  --red: #bd2838;
  --yellow: #f2c94c;
  --focus: #111827;
  --shadow: 0 8px 24px rgba(31, 48, 78, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: var(--blue-dark);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea,
summary {
  outline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--focus);
}

.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px max(24px, calc((100vw - 1180px) / 2));
  color: #ffffff;
  background: #1d3f88;
  border-bottom: 5px solid var(--pink);
}

.site-title {
  flex: 0 1 auto;
  color: #ffffff;
  font-size: 1.65rem;
  font-weight: 850;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.main-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.main-nav > a,
.nav-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 11px;
  color: #ffffff;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.main-nav > a:hover,
.nav-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.main-nav .nav-primary {
  color: var(--ink);
  background: var(--yellow);
}

.unread-badge {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  place-items: center;
  color: #ffffff;
  background: var(--red);
  border: 2px solid #ffffff;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 850;
  line-height: 1;
}

.is-hidden {
  display: none !important;
}

.inline-form {
  display: inline;
  margin: 0;
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 60px;
}

.narrow-page {
  width: min(720px, calc(100% - 40px));
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 26px;
}

.page-heading h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
}

.page-heading p {
  margin: 7px 0 0;
  color: var(--muted);
}

.identity-heading,
.user-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.avatar {
  display: inline-grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #ffffff;
  font-size: 1.45rem;
}

.avatar-small {
  flex-basis: 30px;
  width: 30px;
  height: 30px;
  font-size: 1rem;
}

.avatar-large {
  flex-basis: 66px;
  width: 66px;
  height: 66px;
  font-size: 2.3rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 15px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #9baac0;
  border-radius: 6px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: #e9eef6;
}

.button-primary {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.button-primary:hover {
  background: var(--blue-dark);
}

.button-success {
  color: #ffffff;
  background: var(--green);
  border-color: var(--green);
}

.button-danger {
  color: #ffffff;
  background: var(--red);
  border-color: var(--red);
}

.button-quiet {
  background: transparent;
  border-color: transparent;
}

.flash-list {
  position: relative;
  z-index: 1;
  width: min(900px, calc(100% - 40px));
  margin: 20px auto 0;
}

.flash {
  width: 100%;
  margin: 0 0 10px;
  padding: 13px 16px;
  border: 1px solid;
  border-radius: 6px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
}

.flash-success {
  color: #0a5832;
  background: #e4f5eb;
  border-color: #69b98d;
}

.flash-error {
  color: #79202c;
  background: #fde8eb;
  border-color: #dc7f8b;
}

.flash-info {
  color: #254374;
  background: #e6efff;
  border-color: #82a9e9;
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.tag-filter-item,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 11px;
  color: #254374;
  background: #ffffff;
  border: 1px solid #aebbd0;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.tag-filter-item.selected {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr));
  gap: 20px;
}

.news-card,
.form-panel,
.section-block,
.feedback-item,
.user-row,
.work-row,
.filter-bar,
.action-panel,
.empty-state,
.notice,
.review-note {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.news-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 22px;
}

.news-card h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.story-body {
  flex: 1;
  color: #273247;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.byline > div {
  display: grid;
  min-width: 0;
}

.byline strong,
.byline time,
.byline span {
  overflow-wrap: anywhere;
}

.byline time,
.byline > div > span,
.compact-byline + p {
  color: var(--muted);
  font-size: 0.88rem;
}

.compact-byline {
  margin-bottom: 9px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 0.8rem;
}

.form-panel,
.section-block {
  padding: 24px;
}

.section-block {
  margin-bottom: 22px;
}

.section-block h2 {
  margin: 0 0 18px;
  font-size: 1.25rem;
}

.form-panel label,
.filter-bar label,
.role-form label,
.reset-panel label {
  display: grid;
  gap: 7px;
  color: #344158;
  font-weight: 700;
}

.form-panel label + label {
  margin-top: 18px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #9eacc0;
  border-radius: 5px;
}

textarea {
  resize: vertical;
}

.form-panel > .button {
  margin-top: 22px;
}

.field-help,
.optional,
.muted,
.form-footer {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.form-footer {
  text-align: center;
}

fieldset {
  min-width: 0;
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  color: #344158;
  font-weight: 700;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  gap: 9px;
  margin-bottom: 18px;
}

.avatar-choice {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 58px;
  place-items: center;
  cursor: pointer;
}

.avatar-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.avatar-choice span {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  background: var(--surface-soft);
  border: 2px solid transparent;
  border-radius: 50%;
  font-size: 1.8rem;
}

.avatar-choice input:checked + span {
  background: #e4ecff;
  border-color: var(--blue);
}

.avatar-choice input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.work-list,
.user-list,
.feedback-list {
  display: grid;
  gap: 13px;
}

.work-row,
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px;
}

.work-main {
  min-width: 0;
}

.work-main h2,
.user-row h2 {
  margin: 6px 0 3px;
  font-size: 1.08rem;
  overflow-wrap: anywhere;
}

.work-main p,
.user-row p {
  margin: 0;
  color: var(--muted);
}

.status-line,
.row-actions,
.secondary-actions,
.action-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.status {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 4px;
  color: #344158;
  background: #e9edf4;
  font-size: 0.78rem;
  font-weight: 800;
}

.status-published {
  color: #0d6339;
  background: #dff3e8;
}

.status-pending_review {
  color: #674d00;
  background: #fff1bd;
}

.status-rejected,
.status-trashed {
  color: #852532;
  background: #fbe3e7;
}

.status-locked {
  color: #ffffff;
  background: #273247;
}

.review-note,
.notice {
  margin: 0 0 20px;
  padding: 14px 16px;
  box-shadow: none;
}

.review-note {
  border-left: 5px solid var(--yellow);
}

.notice {
  border-left: 5px solid var(--blue);
}

.secondary-actions {
  margin-top: 16px;
}

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

.filter-bar {
  display: grid;
  grid-template-columns: minmax(190px, 2fr) repeat(3, minmax(130px, 1fr)) auto auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 20px;
  padding: 15px;
  box-shadow: none;
}

.user-filter {
  grid-template-columns: minmax(200px, 2fr) minmax(150px, 1fr) auto auto;
}

.action-panel {
  margin-top: 18px;
  padding: 16px;
  box-shadow: none;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 22px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  display: grid;
  gap: 4px;
  padding: 18px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
}

.stat strong {
  font-size: 1.8rem;
}

.stat span {
  color: var(--muted);
}

.activity-list {
  display: grid;
  gap: 2px;
}

.activity-list > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid #e5eaf1;
}

.activity-list span {
  color: var(--muted);
}

.user-row {
  align-items: flex-start;
}

.user-identity {
  flex: 1 1 260px;
}

.user-controls {
  display: grid;
  gap: 10px;
  flex: 1 1 520px;
}

.role-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.reset-panel {
  padding: 10px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.reset-panel summary {
  font-weight: 750;
  cursor: pointer;
}

.reset-panel form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 10px;
  margin-top: 12px;
}

.deleted-row {
  opacity: 0.72;
}

.feedback-item {
  display: grid;
  gap: 15px;
  padding: 20px;
}

.feedback-item p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.feedback-item form {
  justify-self: start;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 36px 24px;
  text-align: center;
}

.empty-state h1,
.empty-state h2 {
  margin-top: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.messaging-layout {
  display: grid;
  grid-template-columns: minmax(250px, 330px) minmax(0, 1fr);
  min-height: 560px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.message-sidebar {
  min-width: 0;
  background: var(--surface-soft);
  border-right: 1px solid var(--line);
}

.conversation-list {
  display: grid;
}

.conversation-link {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 14px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.conversation-link:hover,
.conversation-link.selected {
  background: #e7eefc;
}

.conversation-link.unread {
  border-left: 4px solid var(--pink);
  padding-left: 10px;
}

.conversation-summary {
  display: grid;
  min-width: 0;
}

.conversation-name {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.conversation-preview {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-empty {
  padding: 18px;
}

.message-welcome {
  display: grid;
  place-content: center;
  padding: 30px;
  text-align: center;
}

.message-welcome h2,
.message-welcome p {
  margin: 4px;
}

.message-welcome p {
  color: var(--muted);
}

.conversation-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 560px;
}

.conversation-panel > .notice {
  grid-row: 1;
  align-self: start;
  margin: 16px 16px 0;
  z-index: 1;
}

.message-thread {
  grid-row: 1;
  min-width: 0;
  max-height: 62vh;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.conversation-panel > .notice + .message-thread {
  padding-top: 80px;
}

.message-items {
  display: grid;
  gap: 14px;
}

.chat-message {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  max-width: min(720px, 92%);
}

.chat-message.own-message {
  justify-self: end;
  width: min(720px, 92%);
}

.message-content {
  min-width: 0;
  padding: 12px 14px;
  background: #f1f4f9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.own-message .message-content {
  background: #e5edff;
  border-color: #a8bce8;
}

.message-content p {
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.message-meta strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.message-deleted {
  color: var(--muted);
  font-style: italic;
}

.message-actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.message-actions details {
  min-width: min(360px, 100%);
}

.message-actions summary,
.text-button {
  color: var(--blue-dark);
  background: transparent;
  border: 0;
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
}

.message-actions form {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.message-actions textarea {
  font-size: 0.9rem;
}

.danger-text {
  color: var(--red);
  padding: 0;
}

.load-older {
  display: flex;
  margin: 0 auto 18px;
}

.empty-chat {
  padding: 50px 20px;
  color: var(--muted);
  text-align: center;
}

.message-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 14px;
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
}

.message-composer textarea {
  max-height: 180px;
}

.mobile-back-link {
  display: none;
}

.message-search {
  grid-template-columns: minmax(220px, 1fr) auto auto;
}

.contact-list {
  display: grid;
  gap: 12px;
}

.contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.contact-row h2 {
  margin: 0;
  font-size: 1.05rem;
}

.contact-row p {
  margin: 2px 0 0;
  color: var(--muted);
}

.feedback-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.9fr);
  align-items: start;
  gap: 22px;
}

.feedback-history > h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}

.feedback-link {
  position: relative;
  color: var(--ink);
  text-decoration: none;
}

.feedback-link:hover {
  border-color: #91a8d0;
}

.feedback-item.unread,
.admin-feedback-row.unread {
  border-left: 5px solid var(--pink);
}

.feedback-preview {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.feedback-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.unread-label {
  color: #8b1749;
  font-weight: 800;
}

.feedback-thread {
  display: grid;
  gap: 14px;
  margin-bottom: 22px;
}

.feedback-message {
  max-width: min(780px, 94%);
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.feedback-message.admin-reply {
  justify-self: end;
  width: min(780px, 94%);
  background: #eaf0ff;
}

.feedback-message p {
  margin: 14px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.feedback-reply-form {
  max-width: 780px;
  margin-left: auto;
}

.admin-feedback-row .row-actions {
  justify-self: start;
}

@media (max-width: 900px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px 20px;
  }

  .main-nav {
    justify-content: flex-start;
    width: 100%;
  }

  .filter-bar,
  .user-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar .button {
    width: 100%;
  }

  .user-row {
    flex-direction: column;
  }

  .user-identity,
  .user-controls {
    width: 100%;
    flex-basis: auto;
  }

  .feedback-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .messaging-layout {
    display: block;
    min-height: 0;
  }

  .messaging-layout:not(.inbox-layout) .message-sidebar {
    display: none;
  }

  .message-sidebar {
    border-right: 0;
  }

  .inbox-layout .message-welcome {
    display: none;
  }

  .conversation-panel {
    min-height: 0;
  }

  .message-thread {
    min-height: 380px;
    max-height: 58vh;
    padding: 14px;
  }

  .mobile-back-link {
    display: inline-block;
    margin-bottom: 6px;
    font-weight: 700;
  }
}

@media (max-width: 620px) {
  .site-header {
    padding: 12px 14px;
  }

  .site-title {
    font-size: 1.45rem;
  }

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

  .main-nav > a,
  .main-nav .inline-form,
  .nav-button {
    width: 100%;
  }

  .main-nav > a,
  .nav-button {
    justify-content: center;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .account-link {
    grid-column: 1 / -1;
  }

  .page-shell,
  .narrow-page {
    width: calc(100% - 28px);
    padding: 24px 0 40px;
  }

  .flash-list {
    width: calc(100% - 28px);
    margin-top: 14px;
  }

  .page-heading,
  .work-row {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading h1 {
    font-size: 1.65rem;
  }

  .page-heading > .button,
  .row-actions,
  .row-actions form,
  .row-actions .button,
  .secondary-actions form,
  .secondary-actions .button {
    width: 100%;
  }

  .form-panel,
  .section-block,
  .news-card,
  .user-row,
  .feedback-item {
    padding: 18px;
  }

  .form-grid,
  .filter-bar,
  .user-filter,
  .role-form,
  .reset-panel form {
    grid-template-columns: minmax(0, 1fr);
  }

  .action-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .action-panel form,
  .action-panel .button {
    width: 100%;
  }

  .activity-list > div {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .avatar-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .message-page-heading > .button {
    display: none;
  }

  .chat-message,
  .chat-message.own-message,
  .feedback-message,
  .feedback-message.admin-reply {
    width: 100%;
    max-width: 100%;
  }

  .message-composer {
    grid-template-columns: minmax(0, 1fr);
  }

  .message-composer .button,
  .contact-row .button {
    width: 100%;
  }

  .message-search {
    grid-template-columns: minmax(0, 1fr);
  }

  .contact-row {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }
}
