:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef3f1;
  --ink: #202624;
  --muted: #65716d;
  --line: #d9e0dd;
  --line-strong: #bec9c4;
  --accent: #24524b;
  --accent-dark: #173d37;
  --blue: #315a8a;
  --orange: #9a5b2c;
  --red: #9b3434;
  --shadow: 0 18px 46px rgba(20, 32, 28, 0.09);
  --radius: 8px;
  --max-width: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

body.modal-open {
  overflow: hidden;
}

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

button {
  border: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 38px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 24px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 8px;
  font-size: 20px;
  line-height: 1.25;
}

a {
  color: var(--accent);
}

.page-shell {
  width: min(var(--max-width), calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 56px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 30px rgba(20, 32, 28, 0.07);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.nav,
.auth-actions,
.actions-row,
.tabs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav {
  justify-content: center;
}

.nav-link {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: var(--surface-soft);
  color: var(--accent);
}

.auth-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--accent);
  font-weight: 800;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

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

.btn.primary:hover {
  background: var(--accent-dark);
}

.btn.ghost {
  border-color: var(--line);
  background: var(--surface);
}

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

.btn.danger {
  border-color: rgba(155, 52, 52, 0.28);
  background: rgba(155, 52, 52, 0.08);
  color: var(--red);
}

.btn.small {
  min-height: 36px;
}

.btn.full {
  width: 100%;
}

.main-shell {
  padding-top: 32px;
}

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

.lead {
  max-width: 700px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
}

.kicker {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.feed-list {
  display: grid;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
}

.panel,
.feed-card,
.modal-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

#create-card {
  max-width: 760px;
  margin: 0 auto;
}

.page[data-page="new"] .page-head {
  max-width: 760px;
  margin-right: auto;
  margin-left: auto;
}

.page-card {
  max-width: 720px;
}

#history-page {
  max-width: none;
  width: 100%;
}

#profile-card.page-card {
  max-width: none;
}

.feed-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  padding: 18px;
}

.feed-card[data-event-card] {
  cursor: pointer;
}

.feed-card.expanded {
  cursor: default;
}

.feed-card.admin-post {
  grid-template-columns: 1fr;
}

.cover {
  position: relative;
  height: 150px;
  min-height: 150px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-soft);
}

.cover img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
}

.cover.placeholder {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 42px;
  font-weight: 800;
}

.card-body {
  min-width: 0;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.muted,
.card-meta,
.feed-card p {
  color: var(--muted);
}

.card-meta {
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
}

.status.voting {
  background: rgba(154, 91, 44, 0.13);
  color: var(--orange);
}

.status.discussion {
  background: rgba(49, 90, 138, 0.12);
  color: var(--blue);
}

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

.status.rejected {
  background: rgba(155, 52, 52, 0.10);
  color: var(--red);
}

.actions-row {
  flex-wrap: wrap;
  margin-top: 16px;
}

.expand-hint {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--muted);
  font-size: 14px;
}

.vote-count,
.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--surface-soft);
}

.detail-image {
  width: 100%;
  max-height: 260px;
  margin-bottom: 14px;
  border-radius: 6px;
  object-fit: cover;
}

.divider {
  margin: 18px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.form {
  display: grid;
  gap: 14px;
}

.form label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.file-input {
  padding: 8px;
}

.file-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.form-label {
  display: block;
  margin-bottom: 7px;
  font-weight: 700;
}

.image-picker {
  display: grid;
  gap: 7px;
}

.image-picker-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}

.image-picker-preview-col {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.image-preview {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
}

.image-preview:hover {
  border-color: var(--accent);
}

.image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-placeholder {
  font-size: 13px;
  font-weight: 800;
}

.image-picker-fields {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.image-help {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.image-url-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.image-clear {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.image-clear:hover {
  color: var(--red);
}

.text-button {
  width: fit-content;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.text-button:hover {
  color: var(--red);
}

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

input:focus,
textarea:focus,
select:focus {
  outline: 3px solid rgba(36, 82, 75, 0.16);
  border-color: var(--accent);
}

.form-note,
.detail-status {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
}

.form-note.error,
.detail-status.error,
.alert {
  color: var(--red);
}

.profile-card {
  display: grid;
  gap: 12px;
}

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

.profile-form,
.profile-activity {
  min-width: 0;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 22px;
}

.avatar-editor {
  display: grid;
  justify-items: center;
  width: 150px;
  flex: 0 0 150px;
  gap: 8px;
}

.profile-avatar-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--accent);
  cursor: pointer;
}

.profile-avatar-button:hover .avatar-camera-mark {
  background: rgba(20, 32, 28, 0.66);
  color: #fff;
}

.profile-avatar-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-button .image-placeholder {
  font-size: 28px;
  font-weight: 900;
}

.avatar-camera-mark {
  position: absolute;
  inset: auto auto 50%;
  transform: translateY(50%);
  display: grid;
  place-items: center;
  min-width: 54px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.avatar-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 150px;
  white-space: nowrap;
}

.avatar-link {
  padding: 0;
  background: transparent;
  color: #2f95db;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.avatar-link.muted-link {
  color: var(--muted);
}

.avatar-link:hover {
  color: var(--accent);
}

.profile-name {
  margin-bottom: 0;
  font-size: 24px;
  font-weight: 800;
}

.settings-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  list-style: none;
}

.profile-activity {
  display: grid;
  gap: 16px;
}

.activity-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafbfb;
}

.activity-panel summary {
  cursor: pointer;
  font-size: 19px;
  font-weight: 800;
}

.activity-scroll {
  max-height: 240px;
  overflow: auto;
  margin-top: 12px;
  padding-right: 4px;
}

.compact-event-list {
  display: grid;
  gap: 10px;
}

.compact-event {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfb;
}

.compact-event span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.event-expanded {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.event-fulltext {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.event-fulltext p {
  margin-bottom: 0;
  color: var(--ink);
  white-space: pre-wrap;
}

.text-link {
  width: fit-content;
  font-weight: 800;
}

.comment-form {
  margin-top: 16px;
}

.guest-notice {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
}

.comments-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.comment {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfb;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-post-box {
  margin-bottom: 0;
}

.create-stack {
  display: grid;
  gap: 22px;
}

.form-block {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.voted-list {
  margin: 0;
  padding-left: 18px;
}

.error-log-list {
  display: grid;
  gap: 14px;
}

.audit-log-list {
  display: grid;
  gap: 14px;
}

.error-log-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.audit-log-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.error-log-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 16px;
  align-items: start;
}

.error-detail {
  max-height: 220px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfb;
  color: var(--ink);
  font-size: 13px;
  white-space: pre-wrap;
}

.audit-detail {
  max-height: 260px;
  max-width: 100%;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfb;
  color: var(--ink);
  font-size: 13px;
  white-space: pre;
}

.history-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.empty-state,
.loading-state,
.error-state,
.alert {
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-state.compact {
  padding: 14px;
}

.error-state,
.alert {
  border-color: rgba(155, 52, 52, 0.32);
  background: rgba(155, 52, 52, 0.06);
}

.alert {
  margin-bottom: 18px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 18px;
  margin-top: 46px;
  padding: 22px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.site-footer strong,
.site-footer span {
  display: block;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 32, 28, 0.44);
}

.modal-card {
  width: min(440px, 100%);
  padding: 24px;
}

.tabs {
  margin-bottom: 20px;
  padding: 4px;
  border-radius: 6px;
  background: var(--surface-soft);
}

.tab {
  flex: 1;
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(20, 32, 28, 0.08);
}

.hidden {
  display: none !important;
}

@media (max-width: 1000px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .nav,
  .auth-actions {
    justify-content: flex-start;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .profile-head {
    align-items: flex-start;
  }

  .error-log-head {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .page-shell {
    width: min(100% - 24px, var(--max-width));
    padding-top: 12px;
  }

  .topbar {
    top: 8px;
  }

  .nav {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
  }

  h1 {
    font-size: 32px;
  }

  .page-head {
    display: grid;
  }

  .feed-card {
    grid-template-columns: 1fr;
  }

  .profile-head {
    display: grid;
  }

  .cover,
  .cover img {
    height: 190px;
    min-height: 190px;
  }

  .image-picker-row {
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 10px;
  }

  .image-preview {
    width: 78px;
    height: 78px;
  }
}
