:root {
  color-scheme: light;
  --bg: #f7f7fc;
  --panel: #ffffff;
  --panel-soft: #f0efff;
  --line: #dcdaeb;
  --text: #1f2130;
  --muted: #5f6174;
  --subtle: #818398;
  --accent: #5b45f0;
  --accent-strong: #4935d7;
  --danger: #c8405d;
  --warning: #94620e;
  --shadow: 0 22px 70px rgba(36, 34, 64, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(135deg, #fcfcff 0%, var(--bg) 54%, #efedff 100%);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

.protected-pending .shell {
  visibility: hidden;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

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

h1 {
  font-size: 1.05rem;
}

h2 {
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  line-height: 1.08;
}

h3 {
  font-size: 0.98rem;
}

.shell {
  display: grid;
  height: 100vh;
  min-height: 0;
  grid-template-columns: 280px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  display: grid;
  height: 100vh;
  min-height: 0;
  padding: 28px;
  grid-template-rows: auto 1fr auto;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

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

.brand--login {
  margin-bottom: 42px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #ffffff;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 900;
}

.label {
  margin: 0 0 6px;
  color: var(--subtle);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav {
  padding-top: 42px;
}

.nav-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  color: var(--muted);
  border-radius: 8px;
  text-decoration: none;
}

.nav-item--active {
  color: var(--text);
  background: rgba(91, 69, 240, 0.1);
}

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

.account-email {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.9rem;
}

.workspace {
  display: grid;
  height: 100vh;
  min-width: 0;
  min-height: 0;
  padding: 32px;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.feedback-layout {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(320px, 0.78fr) minmax(0, 1.22fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.composer,
.list-panel {
  min-width: 0;
  min-height: 0;
}

.composer {
  border-right: 1px solid var(--line);
}

.list-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.section-heading {
  display: flex;
  min-height: 62px;
  padding: 0 18px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.section-heading--stack {
  min-height: 82px;
  gap: 16px;
}

.section-heading span {
  color: var(--subtle);
  font-size: 0.82rem;
}

.filters {
  display: flex;
  gap: 10px;
  align-items: end;
}

.post-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--subtle);
  font-size: 0.78rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: #fcfcff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 160px;
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 69, 240, 0.16);
}

.primary-button,
.quiet-button,
.icon-button {
  min-height: 42px;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 8px;
}

.primary-button {
  padding: 0 18px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 850;
}

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

.primary-button--wide {
  width: 100%;
}

.quiet-button,
.icon-button {
  color: var(--muted);
  background: #f8f7ff;
  border-color: var(--line);
}

.quiet-button {
  padding: 0 14px;
}

.icon-button {
  width: 42px;
  font-size: 1.1rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.post-rows {
  min-height: 0;
  overflow: auto;
}

.post-row {
  display: grid;
  gap: 10px;
  padding: 18px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: background 160ms ease, transform 160ms ease;
}

.post-row:hover {
  background: rgba(91, 69, 240, 0.07);
}

.post-row:focus-visible {
  outline: 3px solid rgba(91, 69, 240, 0.22);
  outline-offset: -3px;
}

.post-row-header,
.post-row-meta,
.profile-chip {
  display: flex;
  gap: 10px;
  align-items: center;
}

.post-row-header {
  justify-content: space-between;
}

.post-title {
  overflow: hidden;
  font-size: 1rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-body {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.profile-avatar {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 50%;
  background: var(--panel-soft);
}

.profile-fallback {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: #ffffff;
  background: var(--accent);
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 900;
}

.profile-name,
.meta-text {
  color: var(--subtle);
  font-size: 0.8rem;
}

.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  color: var(--text);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.badge--open {
  color: var(--warning);
}

.badge--done {
  color: var(--accent);
}

.load-more {
  min-height: 58px;
  padding: 8px 18px;
  border-top: 1px solid var(--line);
}

.empty-state,
.error-state,
.loading-state {
  padding: 38px 18px;
  color: var(--subtle);
  text-align: center;
}

.error-state,
.auth-error,
.form-message--error {
  color: var(--danger) !important;
}

.form-message--success {
  color: var(--accent);
}

.login-page {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.login-panel {
  width: min(100%, 440px);
  padding: 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-copy {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.7;
}

.login-panel .primary-button {
  margin-top: 28px;
}

.login-divider {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 22px 0;
  color: var(--subtle);
  font-size: 0.78rem;
  font-weight: 800;
}

.login-divider::before,
.login-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

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

.quiet-button--wide {
  width: 100%;
}

.vote-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--accent);
  background: #ffffff;
  border: 1px solid rgba(91, 69, 240, 0.32);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 850;
}

.vote-button--active {
  color: #ffffff;
  background: var(--accent);
}

.danger-button {
  color: var(--danger);
}

.detail-panel {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.detail-grid {
  display: grid;
  min-height: 100%;
  grid-template-columns: minmax(0, 1fr) 320px;
}

.post-detail {
  display: grid;
  gap: 18px;
  padding: 22px;
  min-width: 0;
  border-right: 1px solid var(--line);
}

.post-detail-header {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
}

.post-detail-header h3 {
  margin-top: 12px;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.2;
}

.post-detail-body,
.comment-row p {
  color: var(--text);
  line-height: 1.75;
  white-space: pre-wrap;
}

.post-image {
  width: min(100%, 760px);
  max-height: 440px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.status-form,
.comment-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcff;
}

.status-form {
  grid-template-columns: minmax(180px, 320px) auto;
  align-items: end;
}

.comments-panel {
  display: grid;
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

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

.comment-row {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.edit-post-form {
  max-width: 760px;
}

.voters-panel {
  display: grid;
  min-width: 0;
  min-height: 0;
  align-self: start;
  grid-template-rows: auto minmax(0, 1fr);
}

.voters-list {
  display: grid;
  align-content: start;
  min-height: 0;
  max-height: calc(100vh - 190px);
  overflow: auto;
}

.voter-row {
  display: grid;
  gap: 7px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

[hidden] {
  display: none !important;
}

@media (max-width: 1040px) {
  .feedback-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .composer {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  textarea {
    min-height: 120px;
  }

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

  .post-detail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .voters-list {
    max-height: none;
  }
}

@media (max-width: 860px) {
  .shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .sidebar,
  .workspace {
    height: auto;
    overflow: visible;
  }

  .sidebar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 18px;
  }

  .nav {
    display: none;
  }
}

@media (max-width: 680px) {
  .workspace,
  .sidebar {
    padding: 20px;
  }

  .topbar,
  .section-heading--stack,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .post-row-header,
  .post-row-meta,
  .post-detail-header,
  .status-form {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-form {
    grid-template-columns: 1fr;
  }
}
