: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 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;
}

.sidebar-language {
  margin-top: 16px;
}

.language-switcher {
  display: inline-flex;
  width: fit-content;
  padding: 3px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.language-switcher__option {
  min-width: 38px;
  min-height: 30px;
  padding: 0 9px;
  color: var(--subtle);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.language-switcher__option:hover {
  color: var(--accent);
}

.language-switcher__option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.language-switcher__option:active {
  transform: scale(0.95);
}

.language-switcher__option.is-active {
  color: #ffffff;
  background: var(--text);
}

.topbar-language {
  display: none;
}

.workspace {
  display: grid;
  height: 100vh;
  min-width: 0;
  min-height: 0;
  padding: 32px;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.read-only-notice {
  margin: -12px 0 20px;
  padding: 12px 14px;
  color: var(--warning);
  background: #fff8e8;
  border: 1px solid #ead7aa;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.55;
}

.topbar {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.mobile-brand {
  display: none;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
}

.create-post-link {
  display: inline-flex;
  gap: 6px;
  min-height: 42px;
  align-items: center;
  text-decoration: none;
}

.back-link {
  display: none;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  text-decoration: none;
  font-size: 1.15rem;
}

.create-panel {
  width: min(100%, 720px);
  min-height: 0;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.create-intro {
  display: grid;
  gap: 8px;
  padding: 22px 22px 0;
}

.create-intro h3 {
  font-size: 1.15rem;
}

.create-intro p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.post-form--page {
  padding: 22px;
}

.workspace--form {
  justify-items: start;
}

.topbar--form {
  justify-content: flex-start;
}

.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);
}

.feedback-layout--list {
  grid-template-columns: minmax(0, 1fr);
}

.feedback-layout--list .list-panel {
  width: 100%;
}

.list-panel {
  min-width: 0;
  min-height: 0;
}

.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;
}

.filters select {
  min-width: 132px;
}

.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;
  cursor: pointer;
}

.post-row:hover {
  background: rgba(91, 69, 240, 0.07);
}

.post-row:active {
  background: rgba(91, 69, 240, 0.1);
  transform: scale(0.995);
}

.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-meta {
  flex-wrap: wrap;
}

.post-row-meta .vote-button {
  margin-left: auto;
}

.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;
}

.official-badge {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 7px;
  color: var(--accent-strong);
  background: var(--panel-soft);
  border: 1px solid rgba(91, 69, 240, 0.28);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 850;
  white-space: nowrap;
}

.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;
}

.language-badge {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 7px;
  color: var(--accent-strong);
  background: rgba(91, 69, 240, 0.08);
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.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 {
  position: relative;
  width: min(100%, 440px);
  padding: 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-language {
  position: absolute;
  top: 24px;
  right: 24px;
}

.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;
}

.post-image--error {
  display: grid;
  min-height: 120px;
  place-items: center;
  color: var(--muted);
  background: #0d0f11;
}

.post-timestamps {
  display: flex;
  gap: 8px 24px;
  flex-wrap: wrap;
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.post-timestamps div {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.post-timestamps dt,
.post-timestamps dd {
  margin: 0;
  font-size: 0.8rem;
}

.post-timestamps dt {
  color: var(--subtle);
  font-weight: 800;
}

.post-timestamps dd {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.comment-timestamps {
  display: flex;
  gap: 8px 24px;
  flex-wrap: wrap;
  margin: 0;
}

.comment-timestamps div {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.comment-timestamps dt,
.comment-timestamps dd {
  margin: 0;
  font-size: 0.76rem;
}

.comment-timestamps dt {
  color: var(--subtle);
  font-weight: 800;
}

.comment-timestamps dd {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.detail-actions,
.comment-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status-form,
.comment-form,
.comment-edit-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcff;
}

.comment-edit-form {
  padding: 0;
  border: 0;
  background: transparent;
}

.comment-edit-form textarea {
  min-height: 160px;
}

.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;
  }

  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) {
  body {
    background: var(--panel);
  }

  .shell {
    display: block;
    height: 100svh;
    min-height: 100vh;
    overflow: hidden;
  }

  .workspace {
    height: 100svh;
    padding: 0;
    grid-template-rows: auto auto minmax(0, 1fr);
    overflow: hidden;
  }

  .sidebar {
    display: none;
  }

  .topbar-language {
    display: inline-flex;
    margin-left: auto;
  }

  .topbar-language .language-switcher__option {
    min-width: 34px;
    min-height: 28px;
    padding: 0 7px;
  }

  .topbar {
    z-index: 4;
    min-height: 68px;
    margin: 0;
    padding: max(10px, env(safe-area-inset-top)) 16px 10px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
  }

  .topbar h2 {
    font-size: 1.35rem;
  }

  .mobile-brand {
    display: block;
  }

  .actions {
    gap: 8px;
  }

  .icon-button {
    width: 40px;
    min-height: 40px;
  }

  .create-post-link {
    min-height: 40px;
    padding: 0 13px;
    font-size: 0.88rem;
  }

  .read-only-notice {
    margin: 0;
    padding: 10px 16px;
    border-width: 0 0 1px;
    border-radius: 0;
    font-size: 0.79rem;
  }

  .feedback-layout {
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .list-panel {
    min-height: 0;
  }

  .section-heading--stack {
    display: block;
    min-height: auto;
    padding: 10px 0 9px;
    overflow: hidden;
    background: #ffffff;
  }

  .section-heading--stack > div:first-child {
    display: flex;
    padding: 0 16px 8px;
    align-items: baseline;
    justify-content: space-between;
  }

  .section-heading--stack h3 {
    font-size: 0.88rem;
  }

  .filters {
    display: flex;
    gap: 8px;
    padding: 0 16px 2px;
    overflow-x: auto;
    align-items: end;
    scrollbar-width: none;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .filters label {
    flex: 0 0 auto;
  }

  .filters label span {
    display: none;
  }

  .filters select {
    width: auto;
    min-width: 138px;
    height: 38px;
    padding-right: 30px;
    background: var(--panel-soft);
    border-color: transparent;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 750;
  }

  .post-rows {
    overflow-y: auto;
    background: #ffffff;
  }

  .post-row {
    gap: 8px;
    padding: 15px 16px;
  }

  .post-row-header {
    gap: 10px;
    align-items: flex-start;
  }

  .post-title {
    padding-top: 2px;
    font-size: 0.98rem;
    white-space: normal;
  }

  .post-body {
    font-size: 0.88rem;
    line-height: 1.5;
  }

  .post-row-meta {
    gap: 7px 9px;
  }

  .post-row-meta .vote-button {
    min-height: 34px;
  }

  .post-row-meta .meta-text:last-of-type {
    display: none;
  }

  .load-more {
    min-height: 54px;
    padding: 7px 16px;
    background: #ffffff;
  }

  .workspace--form {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .topbar--form {
    gap: 12px;
  }

  .topbar--detail {
    justify-content: flex-start;
  }

  .back-link {
    display: grid;
  }

  .desktop-label {
    display: none;
  }

  .create-panel {
    width: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .create-intro {
    padding: 20px 16px 0;
  }

  .post-form--page {
    padding: 18px 16px max(28px, env(safe-area-inset-bottom));
  }

  .post-form--page textarea {
    min-height: 180px;
  }

  .detail-panel {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .post-detail {
    padding: 18px 16px;
  }
}

@media (max-width: 680px) {
  .post-detail-header,
  .status-form {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-form {
    grid-template-columns: 1fr;
  }
}
