.theme-page {
  display: grid;
  gap: 20px;
}

.theme-page-header {
  display: grid;
  gap: 16px;
}

.theme-subnav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.theme-subnav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  background: transparent;
  text-align: center;
}

@media (max-width: 480px) {
  .theme-subnav {
    grid-template-columns: 1fr;
  }
}

.theme-subnav-link-active {
  background: var(--surface);
  border-color: var(--border-strong);
}

.theme-progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px;
}

.theme-progress-text {
  margin: 0;
  color: var(--muted);
}

.theme-section {
  display: grid;
  gap: 14px;
}

.theme-section-header h2 {
  margin: 0;
}

.theme-stack {
  display: grid;
  gap: 14px;
}

.theme-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: grid;
  gap: 14px;
}

.theme-card-muted {
  background: var(--surface-muted);
  box-shadow: none;
}

.theme-card-empty {
  padding: 20px 22px;
}

.theme-card-form {
  width: 100%;
  max-width: none;
}

.theme-title {
  margin: 0;
  font-size: clamp(1.08rem, 1rem + 0.3vw, 1.2rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.theme-meta {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

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

.theme-reaction-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 10px;
}

.theme-reaction-fieldset legend {
  padding: 0;
  font-weight: 600;
}

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

.theme-reaction-option {
  position: relative;
}

.theme-reaction-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-reaction-option label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #cfd6dc;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.2;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.theme-reaction-option input:checked + label {
  box-shadow: inset 0 0 0 1px currentColor;
}

.theme-reaction-option:nth-child(1) label {
  color: #446556;
  border-color: #bfd3c6;
}

.theme-reaction-option:nth-child(2) label {
  color: #49627b;
  border-color: #c5d3e2;
}

.theme-reaction-option:nth-child(3) label {
  color: #8a6531;
  border-color: #dcc8ae;
}

.theme-reaction-option:nth-child(4) label {
  color: #8a5056;
  border-color: #dfc3c6;
}

.theme-reaction-option input:focus-visible + label {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.theme-reaction-option label:hover {
  background: #fbfcfd;
}

.theme-reaction-option:nth-child(1) input:checked + label {
  background: #f6faf7;
  border-color: #9dbca8;
}

.theme-reaction-option:nth-child(2) input:checked + label {
  background: #f7f9fc;
  border-color: #a8bdd3;
}

.theme-reaction-option:nth-child(3) input:checked + label {
  background: #fcfaf7;
  border-color: #c9ab84;
}

.theme-reaction-option:nth-child(4) input:checked + label {
  background: #fcf8f8;
  border-color: #caa2a7;
}

.theme-field-hint {
  margin: 1px 0 6px;
  color: var(--muted);
  font-size: var(--text-sm);
}

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

.theme-vote-actions .button {
  min-height: 40px;
  padding: 0.55rem 1rem;
}

.theme-dashboard-list {
  display: grid;
  gap: 14px;
}

.theme-dashboard-row {
  display: grid;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.theme-dashboard-title {
  margin: 0;
  font-size: var(--text-md);
  line-height: 1.35;
}

.theme-dashboard-metrics {
  display: grid;
  gap: 12px;
  align-items: start;
}

.theme-dashboard-metric {
  display: grid;
  gap: 4px;
}

.theme-dashboard-comments-metric {
  justify-items: center;
  text-align: center;
}

.theme-dashboard-label {
  color: var(--muted);
  font-size: var(--text-sm);
}

.theme-dashboard-value {
  font-size: var(--text-lg);
  line-height: 1.1;
}

.theme-dashboard-reactions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  align-content: start;
}

.theme-reaction-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 36px;
  min-width: 0;
  padding: 7px 12px;
  border: 1px solid #cfd6dc;
  border-radius: 14px;
  background: #fbfcfd;
}

.theme-reaction-stat-label {
  font-size: var(--text-sm);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.theme-reaction-stat-value {
  font-size: var(--text-sm);
  line-height: 1;
  flex: 0 0 auto;
  min-width: 1.5rem;
  text-align: right;
}

.theme-reaction-pill-excellent {
  border-color: #bfd3c6;
}

.theme-reaction-pill-excellent .theme-reaction-stat-label,
.theme-reaction-pill-excellent .theme-reaction-stat-value {
  color: #446556;
}

.theme-reaction-pill-good_idea {
  border-color: #c5d3e2;
}

.theme-reaction-pill-good_idea .theme-reaction-stat-label,
.theme-reaction-pill-good_idea .theme-reaction-stat-value {
  color: #49627b;
}

.theme-reaction-pill-needs_work {
  border-color: #dcc8ae;
}

.theme-reaction-pill-needs_work .theme-reaction-stat-label,
.theme-reaction-pill-needs_work .theme-reaction-stat-value {
  color: #8a6531;
}

.theme-reaction-pill-not_convinced {
  border-color: #dfc3c6;
}

.theme-reaction-pill-not_convinced .theme-reaction-stat-label,
.theme-reaction-pill-not_convinced .theme-reaction-stat-value {
  color: #8a5056;
}

@media (min-width: 720px) {
  .theme-page-header {
    grid-template-columns: 1fr auto;
    align-items: start;
  }

  .theme-dashboard-row {
    grid-template-columns: minmax(0, 1fr) minmax(440px, 560px);
    align-items: start;
  }

  .theme-dashboard-metrics {
    grid-template-columns: 64px minmax(380px, 1fr) 112px;
    min-width: 0;
  }
}

@media (max-width: 719px) {
  .theme-card,
  .theme-dashboard-row {
    padding: 18px;
  }

  .theme-dashboard-metrics {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "votes comments"
      "reactions reactions";
    align-items: start;
  }

  .theme-dashboard-metric:first-child {
    grid-area: votes;
  }

  .theme-dashboard-reactions {
    grid-area: reactions;
  }

  .theme-dashboard-comments-metric {
    grid-area: comments;
  }

  .theme-vote-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .theme-vote-actions .button {
    width: 100%;
  }

  .theme-dashboard-metrics {
    grid-template-columns: 72px minmax(0, 1fr) 92px;
  }
}

@media (max-width: 420px) {
  .theme-reaction-grid {
    grid-template-columns: 1fr;
  }

  .theme-card,
  .theme-dashboard-row {
    padding: 16px;
  }

  .theme-dashboard-reactions {
    grid-template-columns: minmax(0, 1fr);
  }
}

.theme-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.theme-modal-backdrop[hidden] {
  display: none;
}

.theme-modal-backdrop:not([hidden]) {
  display: flex;
}

.theme-modal {
  width: min(720px, 100%);
  max-height: 80vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 16px;
}

.theme-modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.theme-modal-title {
  margin: 0;
}

.theme-modal-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.theme-modal-close {
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}

.theme-modal-body {
  display: grid;
  gap: 12px;
}

.theme-comments-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

body.modal-open {
  overflow: hidden;
}

textarea {
  width: 100%;
  resize: vertical;
}

.theme-comment-textarea {
  line-height: 1.4;
  min-height: 0;
  padding: 8px 12px;
}

.theme-comments-button {
  width: fit-content;
  min-width: 2.25rem;
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease;
}

.theme-dashboard-metric .theme-comments-button {
  justify-self: center;
}

.theme-comments-button:hover:not(:disabled),
.theme-comments-button:focus-visible:not(:disabled) {
  border-color: var(--border-strong);
}

.theme-comments-icon {
  width: 1.1rem;
  height: 1.1rem;
}

.theme-comments-button:disabled {
  color: var(--muted);
  border-color: var(--border);
  background: var(--surface-muted);
  cursor: not-allowed;
  opacity: 0.65;
}
