/* ── Reset & Variables ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f1eb;
  --card: #ffffff;
  --text: #2c2c2c;
  --muted: #6b6560;
  --accent: #1a3a68;
  --accent-hover: #142d52;
  --accent-light: #3c8bf2;
  --border: #d4cfc4;
  --border-light: #e5e0d8;
  --radius: 0.5rem;
  --font: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;
  --font-script: "Caveat", cursive;
  --max-w: 1040px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── Header ──────────────────────────────────────────────────── */
#site-header {
  padding: 1.25rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

#site-header.home {
  opacity: 1;
  pointer-events: auto;
  position: absolute;
}

.logo {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}

.logo-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.logo-tag {
  font-family: var(--font-script);
  font-size: 1.15rem;
  color: var(--accent-light);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s;
}

.header-link.active,
.header-link:hover {
  color: var(--accent);
}

/* Before login: only "Contribute" button is visible.
   After login: "Contribute" hides, contributor-only items appear. */
.contributor-only {
  display: none !important;
}

body.contributor .contributor-only {
  display: inline-flex !important;
}

body.contributor #nav-contributions {
  display: none !important;
}

/* ── Main ────────────────────────────────────────────────────── */
#app {
  flex: 1;
}

.loading {
  text-align: center;
  padding: 6rem 2rem;
  color: var(--muted);
  font-size: 1.1rem;
}

/* ── Home / Hero ─────────────────────────────────────────────── */
.home-view .hero {
  text-align: center;
  padding: 4rem 2rem 3rem;
}

.hero-title {
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1;
}

.hero-tagline {
  font-family: var(--font-script);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: var(--accent-light);
  margin-top: -0.75rem;
}

.hero-mission {
  max-width: 40rem;
  margin: 1.1rem auto 0;
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.5;
  color: var(--text);
}

#btn-contribute {
  position: relative;
  font-weight: 700;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    linear-gradient(90deg, #1a3f6b 0%, #316cb5 46%, #72abdc 74%, #abcde9 100%) border-box;
  box-shadow: 0 8px 18px rgba(26, 58, 104, 0.08);
  color: #255ea8;
  transition: none;
  appearance: none;
  -webkit-appearance: none;
}

#btn-contribute span {
  display: inline-block;
  line-height: 1;
  transition: none;
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  #btn-contribute span {
    background: linear-gradient(90deg, #1a3f6b 0%, #316cb5 46%, #72abdc 74%, #abcde9 100%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}

#btn-contribute:hover,
#btn-contribute:focus-visible,
#btn-contribute:active {
  border-color: transparent;
  color: #255ea8;
  transform: none;
  box-shadow: 0 8px 18px rgba(26, 58, 104, 0.08);
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    linear-gradient(90deg, #1a3f6b 0%, #316cb5 46%, #72abdc 74%, #abcde9 100%) border-box;
  outline: none;
}

#btn-contribute:hover span,
#btn-contribute:focus-visible span,
#btn-contribute:active span {
  color: inherit;
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  #btn-contribute:hover span,
  #btn-contribute:focus-visible span,
  #btn-contribute:active span {
    background: linear-gradient(90deg, #1a3f6b 0%, #316cb5 46%, #72abdc 74%, #abcde9 100%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}

/* ── Inline search ───────────────────────────────────────────── */
.inline-search {
  width: 100%;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  outline: none;
  color: var(--text);
  margin-bottom: 1rem;
  transition: border-color 0.15s;
}

.inline-search:focus {
  border-color: var(--accent);
}

.inline-search::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.sr-empty {
  padding: 1rem 1.25rem;
  color: var(--muted);
  text-align: center;
}

/* ── Deep search suggestions ─────────────────────────────────── */
.search-suggestions {
  margin-top: 1.5rem;
}

.no-tiles-msg {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 1rem;
}

.no-tiles-msg a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}

.no-tiles-msg a:hover {
  text-decoration-color: var(--accent);
}

.suggestions-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.875rem;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: rgba(255, 255, 255, 0.6);
}

.suggestion-name {
  font-weight: 600;
  font-size: 0.92rem;
  flex-shrink: 0;
}

.suggestion-name mark {
  background: rgba(60, 139, 242, 0.18);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 2px;
}

.suggestion-path {
  flex: 1;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-kind {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ── Browse / Tasks tabs ─────────────────────────────────────── */
.browse-tasks-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border-light);
}

.tab-btn {
  padding: 0.5rem 1.5rem;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.panel-hidden {
  display: none;
}

/* ── Stats ───────────────────────────────────────────────────── */
.stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.stat {
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.stat-sep {
  color: var(--border);
  font-size: 1.05rem;
  margin-top: -0.35rem;
}

/* ── Card Grids ──────────────────────────────────────────────── */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.875rem;
}

.domains-grid {
  grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 700px) {
  .domains-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.browse-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.browse-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(26, 58, 104, 0.1);
}

.browse-card.hidden {
  display: none;
}

.browse-card h3,
.field-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.browse-card p,
.field-card p {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Page View ───────────────────────────────────────────────── */
.page-view {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0.5rem 2rem 4rem;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}

.breadcrumb a:hover {
  text-decoration-color: var(--accent);
}

.breadcrumb .sep {
  color: var(--muted);
}

.breadcrumb > span:last-child {
  color: var(--muted);
}

.page-view > h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 0.2rem;
}

.subtitle {
  color: var(--muted);
  font-size: 1rem;
  margin-bottom: 2rem;
}

/* ── Subfields Grid ──────────────────────────────────────────── */
.subfields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.875rem;
}

/* ── Topics List ─────────────────────────────────────────────── */
.topics-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 0.625rem;
}

.topic-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  transition: border-color 0.2s;
}

.topic-card:hover {
  border-color: var(--accent);
}

.topic-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--bg);
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  margin-left: 1rem;
  white-space: nowrap;
}

/* ── Topic Detail ────────────────────────────────────────────── */
.topic-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.topic-profile-save {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  margin: 0.75rem 0 1rem;
}

.topic-profile-save-btn {
  margin-top: 0;
}

.topic-profile-save-msg {
  min-height: 1.1em;
  margin: 0;
  font-size: 0.78rem;
  color: #b91c1c;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-family: var(--font);
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

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


.btn svg {
  width: 15px;
  height: 15px;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task-card {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  transition: border-color 0.15s;
}

.task-card:hover {
  border-color: var(--accent);
}

.task-num {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 0.1rem;
}

.task-text {
  font-size: 0.95rem;
  line-height: 1.55;
}


.task-level-label {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--muted);
  margin-left: 0.5rem;
  align-self: center;
}

/* ── Category filter bar ────────────────────────────────────── */
.category-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.category-filter-btn {
  flex: 1 1 100px;
  min-width: 80px;
  max-width: 140px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.category-filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.category-filter-btn.active {
  border-color: var(--accent);
  background: rgba(26, 58, 104, 0.08);
  color: var(--accent);
}

/* ── Tasks by category (flat groups) ─────────────────────────── */
.tasks-by-category {
  margin-bottom: 2rem;
}

.category-group {
  margin-bottom: 1.5rem;
}

.category-group:last-child {
  margin-bottom: 0;
}

.category-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.category-group .task-list {
  margin-bottom: 0;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
}

/* ── Task body wrapper ────────────────────────────────────────── */
.task-body {
  flex: 1;
  min-width: 0;
}

/* ── Rating row (hidden unless contributor) ───────────────────── */
.rating-row {
  display: none;
}

body.contributor .rating-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.rating-scale {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.rating-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  width: 7rem;
  flex-shrink: 0;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.rating-anchor {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}

.rating-anchor.lo {
  text-align: right;
  min-width: 3rem;
}

.rating-anchor.hi {
  text-align: left;
  min-width: 3rem;
}

.rating-pills {
  display: flex;
  gap: 0.25rem;
}

.rating-pill {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--card);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.rating-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rating-pill.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.rating-pill-wide {
  width: auto;
  min-width: 1.75rem;
  height: auto;
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  font-size: 0.68rem;
  white-space: nowrap;
}

.rating-scale-wide .rating-pills {
  flex-wrap: wrap;
}

.rating-scale-minutes {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.rating-scale-minutes .rating-label {
  width: auto;
}

.rating-minutes-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.rating-minutes-input {
  width: 6.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
  font-family: var(--font);
}

.rating-minutes-input:focus {
  outline: none;
  border-color: var(--accent);
}

.rating-minutes-unit {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.autosave-status {
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.2em;
}

.autosave-status[data-state="saved"] {
  color: var(--accent);
}

.autosave-status[data-state="error"] {
  color: #b91c1c;
}

/* ── Page-level comment ───────────────────────────────────────── */
.page-comment-box {
  display: none;
  margin-bottom: 1.25rem;
}

body.contributor .page-comment-box {
  display: block;
}

.page-comment-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.page-comment-rating {
  margin-bottom: 0.8rem;
}

.page-comment-rating-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.page-comment-rating-scale {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
}

.page-comment-rating-btn {
  width: 100%;
  height: 38px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s;
}

.page-comment-rating-btn:hover {
  border-color: var(--accent);
  background: rgba(26, 58, 104, 0.04);
}

.page-comment-rating-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-comment-rating-anchors {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.page-comment-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--font);
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  outline: none;
  resize: vertical;
}

.page-comment-input:focus {
  border-color: var(--accent);
}

/* ── Add task slot & form ─────────────────────────────────────── */
.add-task-slot {
  display: none;
}

body.contributor .add-task-slot {
  display: block;
  margin-top: 0.5rem;
}

.add-task-btn {
  font-size: 0.8rem;
  color: var(--muted);
  border-style: dashed;
}

.add-task-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.add-task-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.add-task-text {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: var(--font);
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  outline: none;
  color: var(--text);
}

.add-task-text:focus {
  border-color: var(--accent);
}

.add-task-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.add-task-meta select,
.add-task-meta input {
  padding: 0.4rem 0.6rem;
  font-family: var(--font);
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  outline: none;
  flex: 1;
  min-width: 120px;
}

.add-task-meta select:focus,
.add-task-meta input:focus {
  border-color: var(--accent);
}

.add-task-ratings {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.add-task-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.add-task-actions .btn {
  margin-top: 0;
}

.add-task-success {
  color: #22863a;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ── Modal overlay ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: var(--card);
  border-radius: 0.75rem;
  padding: 2rem 2.5rem;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

/* ── Rating instructions floating panel ───────────────────────── */
.rating-intro-panel {
  position: fixed;
  top: 5.5rem;
  right: 1.25rem;
  width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  z-index: 90;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text);
  overflow: hidden;
}

.rating-intro-panel.hidden {
  display: none;
}

.rating-intro-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--accent);
  border: none;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  text-align: left;
}

.rating-intro-toggle h3 {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.4rem;
}

.rating-intro-chevron {
  font-size: 0.6rem;
  opacity: 0.8;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.rating-intro-panel.collapsed .rating-intro-chevron {
  transform: rotate(180deg);
}

.rating-intro-body {
  padding: 0.85rem 1rem;
  transition: none;
}

.rating-intro-panel.collapsed .rating-intro-body {
  display: none;
}

.rating-intro-panel p {
  margin: 0 0 0.5rem;
}

.rating-intro-panel ul {
  padding-left: 1.1rem;
  margin: 0 0 0.5rem;
}

.rating-intro-panel li {
  margin-bottom: 0.3rem;
}

.rating-intro-defs {
  margin: 0.4rem 0 0.6rem;
}

.rating-intro-defs dt {
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.45rem;
}

.rating-intro-defs dt:first-child {
  margin-top: 0;
}

.rating-intro-defs dd {
  margin: 0.1rem 0 0;
}

.rating-intro-panel p:last-child {
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .rating-intro-panel {
    position: static;
    width: auto;
    margin: 0 auto 1rem;
    max-width: 600px;
  }
}

.modal-note {
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 0.5rem;
  min-height: 1.2em;
}

/* ── Google Sign-In container ─────────────────────────────────── */
#google-signin-container {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0;
}

/* ── Profile card & header ───────────────────────────────────── */
.profile-shell {
  display: flex;
  justify-content: center;
}

.profile-card {
  background: #faf7ef;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 2rem 2.5rem;
  max-width: 540px;
  width: 100%;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 1.25rem;
}

.profile-header-text h1 {
  margin: 0 0 0.15rem;
}

.profile-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
}

.profile-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  margin-top: 0.5rem;
}

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.profile-actions .btn {
  margin-top: 0;
}

.profile-topics-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.profile-topic-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.profile-topic-row.is-unavailable {
  background: #fbfbfb;
}

.profile-topic-main {
  min-width: 0;
  flex: 1 1 auto;
}

.profile-topic-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.profile-topic-link:hover .profile-topic-name {
  color: var(--accent);
}

.profile-topic-link:hover .profile-topic-path {
  color: var(--text);
}

.profile-topic-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.profile-topic-path {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.profile-topic-status {
  margin-top: 0.28rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.profile-topic-remove {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.profile-topic-remove:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(26, 58, 104, 0.04);
}

.profile-topic-remove:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Profile form ─────────────────────────────────────────────── */
.profile-form {
  max-width: 100%;
}

.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.form-field input,
.form-field select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: var(--font);
  font-size: 0.92rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  outline: none;
  color: var(--text);
}

.form-field input:focus,
.form-field select:focus {
  border-color: var(--accent);
}

.form-field input:disabled {
  background: var(--bg);
  color: var(--muted);
}

.form-field-checkbox {
  margin-top: 0.25rem;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem !important;
  font-weight: 400 !important;
  color: var(--text) !important;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  flex-shrink: 0;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-field select,
#prof-country {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.field-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 0.25rem;
}

.field-tooltip-text {
  display: none;
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.4;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  white-space: normal;
  width: 240px;
  z-index: 50;
  pointer-events: none;
}

.field-tooltip:hover .field-tooltip-text,
.field-tooltip:focus .field-tooltip-text {
  display: block;
}

/* ── Contributions table ──────────────────────────────────────── */
.contributions-table {
  overflow-x: auto;
  margin-bottom: 2rem;
}

.contributions-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.contributions-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  border-bottom: 2px solid var(--border);
}

.contributions-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}

.contributions-table tr:hover td {
  background: rgba(26, 58, 104, 0.04);
}

tr.contrib-row-link {
  cursor: pointer;
}

tr.contrib-row-link:hover td {
  background: rgba(26, 58, 104, 0.07);
}

.contrib-task-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.contrib-task-link:hover {
  color: var(--accent-light);
}

.contributions-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.contribution-branch-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
}

.contribution-branch-link {
  display: block;
  width: fit-content;
  max-width: 100%;
  font-size: 0.84rem;
  color: var(--accent);
  text-decoration: none;
  line-height: 1.45;
}

.contribution-branch-link:hover {
  color: var(--accent-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.contribution-branch-link.is-static {
  color: var(--text);
  cursor: default;
}

.general-feedback-form {
  width: 100%;
  margin-bottom: 0.5rem;
}

.general-feedback-form .page-comment-input {
  width: 100%;
}

.past-comments-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1.5rem;
  max-width: 100%;
}

.past-comments-list li {
  font-size: 0.85rem;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--accent-light);
  margin-bottom: 0.5rem;
  background: rgba(60, 139, 242, 0.04);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.past-comment-date {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  margin-right: 0.3rem;
}

@keyframes task-highlight-pulse {
  0%   { box-shadow: 0 0 0 3px rgba(60, 139, 242, 0.5); }
  50%  { box-shadow: 0 0 0 6px rgba(60, 139, 242, 0.15); }
  100% { box-shadow: 0 0 0 3px rgba(60, 139, 242, 0); }
}

.task-card-highlight {
  animation: task-highlight-pulse 2s ease-out;
}

/* ── About page ──────────────────────────────────────────────── */
.about-body {
  max-width: 680px;
  margin-top: 2rem;
}

.about-body h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.about-body p {
  font-size: 0.97rem;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.about-body p a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.about-body p a:hover {
  color: var(--accent-light);
}

.about-team {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.about-person {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.about-name {
  font-weight: 600;
  font-size: 0.97rem;
  color: var(--accent);
  text-decoration: none;
}

a.about-name:hover {
  color: var(--accent-light);
  text-decoration: underline;
}

.about-role {
  font-size: 0.85rem;
  color: var(--accent-light);
}

.about-affil {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Aggregate data panel (field / domain Data tabs) ─────────── */
.agg-data-note {
  font-size: 0.87rem;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 1.25rem;
}

.agg-loading {
  padding: 2rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Footer ──────────────────────────────────────────────────── */
#site-footer {
  text-align: center;
  padding: 2rem;
  font-size: 0.88rem;
  color: var(--muted);
}

#site-footer .footer-link {
  color: var(--muted);
  text-decoration: none;
}

#site-footer .footer-link:hover {
  color: var(--accent);
}

/* ── Error ───────────────────────────────────────────────────── */
.error-view {
  text-align: center;
  padding: 6rem 2rem;
}

.error-view h2 {
  margin-bottom: 0.5rem;
}

.error-view a {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  #site-header {
    padding: 0.85rem 1rem;
    align-items: flex-start;
  }

  .logo {
    align-items: center;
  }

  .logo-tag {
    display: none;
  }

  .logo-name {
    font-size: 1.35rem;
  }

  .home-view .hero {
    padding: 2.5rem 1.25rem 2rem;
  }

  .hero-mission {
    margin-top: 0.9rem;
    font-size: 0.98rem;
  }

  .stats {
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  .stat-num {
    font-size: 1.25rem;
  }

  .stat-sep {
    font-size: 0.85rem;
  }

  .browse-grid,
  .subfields-grid,
  .topics-list {
    grid-template-columns: 1fr;
  }

  .page-view {
    padding: 0.5rem 1.25rem 3rem;
  }

  .page-view > h1 {
    font-size: 1.5rem;
  }

  .task-card {
    gap: 0.625rem;
    padding: 0.75rem 1rem;
  }


  .category-filter-btn {
    min-width: 70px;
    max-width: 120px;
    font-size: 0.72rem;
  }

  .header-nav {
    gap: 0.35rem 0.6rem;
  }

  .header-link {
    font-size: 0.78rem;
  }

  .header-nav .btn {
    padding: 0.45rem 0.8rem;
    font-size: 0.78rem;
  }

  .rating-label {
    width: 5.5rem;
    font-size: 0.65rem;
  }

  .rating-anchor {
    display: none;
  }

  .modal-card {
    padding: 1.5rem 1.5rem;
  }

  .add-task-meta {
    flex-direction: column;
  }

  .profile-actions {
    flex-direction: column;
  }

  .profile-topic-row {
    padding: 0.8rem 0.85rem;
  }

  .validate-shortcut-card {
    padding: 0.85rem 0.9rem;
  }
}

/* ── Section divider ─────────────────────────────────────────── */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0 1.5rem;
}

/* ── Survey hub ──────────────────────────────────────────────── */
.survey-hub-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1.5rem 0 2rem;
}

.survey-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.survey-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(26, 58, 104, 0.07);
}

.survey-card-done {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.survey-card-done:hover {
  border-color: #22c55e;
}

.survey-card-check {
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.survey-card-body {
  flex: 1;
  min-width: 0;
}

.survey-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.survey-card-desc {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0.25rem;
}

.survey-card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-outline:hover {
  background: rgba(26, 58, 104, 0.06);
}

.survey-card-count-badge {
  flex-shrink: 0;
  width: 80px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(26, 58, 104, 0.07);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  line-height: 1.3;
}

.survey-card-tasks {
  border-style: solid;
}

.survey-profile-banner {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.survey-profile-banner a {
  color: var(--accent);
  font-weight: 600;
}

/* ── Additional surveys link card ────────────────────────────── */
.survey-card-more {
  background: linear-gradient(135deg, rgba(26, 58, 104, 0.04) 0%, rgba(59, 130, 246, 0.06) 100%);
  border-color: rgba(26, 58, 104, 0.15);
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}

.survey-card-more:hover {
  background: linear-gradient(135deg, rgba(26, 58, 104, 0.06) 0%, rgba(59, 130, 246, 0.1) 100%);
  border-color: var(--accent);
}

.survey-card-more .survey-card-title {
  color: var(--accent);
  font-size: 1rem;
}

.survey-card-more-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(26, 58, 104, 0.07);
  color: var(--accent);
}

.survey-card-more-arrow {
  flex-shrink: 0;
  font-size: 1.3rem;
  color: var(--accent);
  opacity: 0.5;
  margin-left: auto;
  transition: opacity 0.2s, transform 0.2s;
}

.survey-card-more:hover .survey-card-more-arrow {
  opacity: 1;
  transform: translateX(3px);
}

/* ── Survey catalog (additional surveys page) ───────────────── */
.survey-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}

.survey-catalog-card {
  display: block;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 1.4rem 1.6rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.survey-catalog-card:hover {
  border-color: var(--accent);
  box-shadow: 0 3px 16px rgba(26, 58, 104, 0.1);
}

.survey-catalog-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  color: var(--text);
}

.survey-catalog-card p {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0.6rem;
}

.survey-catalog-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.survey-catalog-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.survey-catalog-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.badge-model { background: rgba(26, 58, 104, 0.08); color: var(--accent); }
.badge-forecast { background: rgba(234, 88, 12, 0.1); color: #ea580c; }
.badge-behavioral { background: rgba(22, 163, 74, 0.1); color: #16a34a; }
.badge-novel { background: rgba(147, 51, 234, 0.1); color: #7c3aed; }
.badge-simp { background: rgba(16, 185, 129, 0.1); color: #059669; }
.badge-aug { background: rgba(59, 130, 246, 0.1); color: #2563eb; }

.survey-catalog-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.1rem;
}

.survey-catalog-check {
  flex-shrink: 0;
  line-height: 0;
}

.survey-catalog-card-done {
  border-color: #bbf7d0;
  background: #f0fdf4;
  opacity: 0.85;
}

.survey-catalog-card-done:hover {
  border-color: #22c55e;
  opacity: 1;
}

@media (max-width: 600px) {
  .survey-catalog-grid {
    grid-template-columns: 1fr;
  }
}

/* ── New survey question types ────────────────────────────────── */
.survey-info { border: none; padding: 0.5rem 0; }
.survey-info-text { font-size: 0.9rem; color: var(--muted); line-height: 1.6; }
.survey-info-text strong { color: var(--text); }
.survey-info-text em { font-style: italic; }

.survey-slider-wrap { width: 100%; max-width: none; }
.survey-slider { width: 100%; accent-color: var(--accent); }
.survey-slider-wrap.is-pristine .survey-slider { accent-color: #cbd5e1; }
.survey-slider-wrap.is-pristine .survey-slider::-webkit-slider-thumb { opacity: 0; }
.survey-slider-wrap.is-pristine .survey-slider::-moz-range-thumb { opacity: 0; }
.survey-slider-labels { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.survey-slider-labels span:last-child { text-align: right; }
.survey-slider-val { font-weight: 600; color: var(--accent); text-align: center; }
.survey-slider-val.is-empty { color: var(--muted); font-weight: 500; }
.survey-slider-marks { margin-top: 0.3rem; display: grid; grid-template-columns: repeat(var(--mark-count), minmax(0, 1fr)); gap: 0.2rem; align-items: start; }
.survey-slider-mark-item { display: flex; flex-direction: column; align-items: center; gap: 0.18rem; min-width: 0; text-align: center; }
.survey-slider-mark-item.is-active .survey-slider-mark-value,
.survey-slider-mark-item.is-active .survey-slider-mark-title { color: var(--accent); }
.survey-slider-mark-value { font-size: 0.78rem; font-weight: 700; color: var(--muted); line-height: 1.1; }
.survey-slider-mark-title { font-size: 0.72rem; font-weight: 600; color: var(--text); line-height: 1.22; max-width: 100%; overflow-wrap: anywhere; }
.survey-slider-mark-help {
  width: 1.22rem;
  height: 1.22rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.survey-slider-mark-help:hover,
.survey-slider-mark-help:focus-visible,
.survey-slider-mark-help.is-open {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(26, 58, 104, 0.08);
  outline: none;
}
.survey-slider-detail { margin-top: 0.75rem; padding: 0.8rem 0.9rem; border: 1px solid var(--border); border-radius: 8px; background: rgba(26, 58, 104, 0.04); }
.survey-slider-detail-heading { font-size: 0.84rem; font-weight: 600; color: var(--text); margin-bottom: 0.22rem; }
.survey-slider-detail-desc { font-size: 0.84rem; color: var(--text); line-height: 1.5; }
.survey-slider-detail-example { margin-top: 0.28rem; font-size: 0.8rem; color: var(--muted); line-height: 1.45; font-style: italic; }

@media (max-width: 640px) {
  .survey-slider-marks { gap: 0.1rem; }
  .survey-slider-mark-title { font-size: 0.64rem; }
}

.survey-number-wrap { display: flex; align-items: center; gap: 0.35rem; max-width: 200px; }
.survey-number-inp { width: 100px; padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }
.survey-number-unit { font-size: 0.85rem; color: var(--muted); }

.survey-radio-group { display: flex; flex-direction: column; gap: 0.4rem; }
.survey-radio-item { display: flex; align-items: flex-start; gap: 0.4rem; font-size: 0.9rem; cursor: pointer; line-height: 1.5; }
.survey-radio-item input { margin-top: 0.25rem; accent-color: var(--accent); }

.survey-grid-table { overflow-x: auto; margin-top: 0.25rem; }
.survey-grid-table table { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
.survey-grid-table th { text-align: center; padding: 0.35rem 0.4rem; font-weight: 600; color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.survey-grid-table td { text-align: center; padding: 0.3rem 0.4rem; border-top: 1px solid var(--border); }
.survey-grid-row-label { text-align: left !important; font-weight: 500; white-space: nowrap; padding-right: 1rem !important; }
.survey-grid-table input[type="radio"] { accent-color: var(--accent); }

.survey-scenario { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.25rem; }
.survey-scenario-field { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.survey-scenario-field label { font-size: 0.85rem; min-width: 200px; color: var(--muted); }
.survey-scenario-field .survey-number-inp { width: 90px; }

.survey-percentile { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.25rem; }
.survey-pctile-row { display: flex; align-items: center; gap: 0.4rem; }
.survey-pctile-row label { font-size: 0.85rem; min-width: 170px; color: var(--muted); }
.survey-pctile-row .survey-pct-inp { width: 80px; }

.survey-paired { margin-top: 0.25rem; }
.survey-paired-header { display: grid; grid-template-columns: 1fr 100px 100px; gap: 0.4rem; font-size: 0.78rem; font-weight: 600; color: var(--muted); margin-bottom: 0.3rem; text-align: center; }
.survey-paired-header span:first-child { text-align: left; }
.survey-paired-row { display: grid; grid-template-columns: 1fr 100px 100px; gap: 0.4rem; align-items: center; padding: 0.3rem 0; border-top: 1px solid var(--border); }
.survey-paired-task { font-size: 0.85rem; }
.survey-paired-row .survey-number-inp { width: 100%; text-align: center; }

.survey-q-hint { font-size: 0.82rem; color: var(--muted); margin: 0.2rem 0 0.5rem; line-height: 1.5; font-style: italic; }
.survey-q-resolution { font-size: 0.78rem; color: var(--muted); margin: 0.15rem 0; line-height: 1.4; }
.survey-q-baseline { font-size: 0.78rem; color: var(--muted); margin: 0.15rem 0 0.4rem; line-height: 1.4; }
.survey-cs-sum { font-size: 0.82rem; font-weight: 600; color: var(--accent); margin-top: 0.3rem; }

/* ── Validate landing ────────────────────────────────────────── */
.validate-landing {
  max-width: 580px;
  margin-top: 1rem;
}

.validate-landing h1 {
  margin-bottom: 0.5rem;
}

.validate-landing > p {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.validate-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.validate-step {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--text);
}

.validate-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

.validate-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.validate-go-btn {
  display: inline-block;
  padding: 0.65rem 1.5rem;
}

.validate-shortcuts {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.validate-shortcuts-heading {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.validate-shortcuts-note {
  font-size: 0.84rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.validate-shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.validate-shortcut-card {
  display: block;
  padding: 0.9rem 1rem;
  border-radius: 0.8rem;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(26, 58, 104, 0.03), rgba(26, 58, 104, 0.01));
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.12s, transform 0.12s, background 0.12s;
}

.validate-shortcut-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  background: linear-gradient(180deg, rgba(26, 58, 104, 0.06), rgba(26, 58, 104, 0.015));
}

.validate-shortcut-kicker {
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.validate-shortcut-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.validate-shortcut-path {
  display: block;
  margin-top: 0.18rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ── Survey form ─────────────────────────────────────────────── */
.survey-view {
  max-width: 720px;
}

.survey-form {
  margin-top: 1.75rem;
}

.survey-question {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.survey-q-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.85rem;
  line-height: 1.5;
}

.survey-q-num {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.survey-required {
  color: #ef4444;
  margin-left: 0.2rem;
}

.survey-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s;
}

.survey-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.survey-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 2rem 0.6rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
  appearance: none;
}

.survey-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Tag input */
.survey-tag-input {
  position: relative;
}

.survey-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.survey-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(26, 58, 104, 0.08);
  color: var(--text);
  font-size: 0.85rem;
  padding: 0.3rem 0.55rem;
  border-radius: 5px;
  line-height: 1.3;
}

.survey-tag-x {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.1rem;
}

.survey-tag-x:hover {
  color: #ef4444;
}

.survey-tag-field {
  position: relative;
}

.survey-tag-text {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
}

.survey-tag-text:focus {
  outline: none;
  border-color: var(--accent);
}

.survey-tag-suggestions {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 2px;
}

.survey-tag-sug-item {
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.1s;
}

.survey-tag-sug-item:hover {
  background: rgba(26, 58, 104, 0.06);
}

/* Scale buttons */
.survey-scale {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.survey-scale-btns {
  display: grid;
  grid-template-columns: repeat(var(--scale-count, 5), minmax(0, 1fr));
  gap: 0.4rem;
}

.survey-scale-btn {
  width: 100%;
  height: 38px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s;
}

.survey-scale-btn:hover {
  border-color: var(--accent);
  background: rgba(26, 58, 104, 0.04);
}

.survey-scale-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.survey-scale-anchors {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Checklist */
.survey-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.survey-check-option {
  display: flex;
  flex-direction: column;
}

.survey-check-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: 5px;
  transition: background 0.1s;
}

.survey-check-item:hover {
  background: rgba(26, 58, 104, 0.04);
}

.survey-check-item input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

.survey-check-detail {
  display: none;
  margin: 0 0 0.2rem 1.9rem;
}

.survey-check-detail-visible {
  display: block;
}

.survey-check-detail-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  line-height: 1.45;
}

.survey-check-detail-textarea {
  min-height: 4.75rem;
}

/* Time split */
.survey-time-split {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.survey-ts-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.survey-ts-cat {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text);
}

.survey-ts-sel {
  width: 140px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 1.8rem 0.4rem 0.6rem;
  font-size: 0.85rem;
  font-family: inherit;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 0.5rem center;
  appearance: none;
}

.survey-ts-sel:focus {
  outline: none;
  border-color: var(--accent);
}

.survey-hours-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.survey-hours-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.survey-hours-row:last-of-type {
  border-bottom: none;
}

.survey-hours-name {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text);
}

.survey-hours-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.survey-hours-inp,
.survey-hours-other-inp,
.survey-hours-other-label {
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.88rem;
  font-family: inherit;
}

.survey-hours-inp,
.survey-hours-other-inp {
  width: 86px;
  padding: 0.4rem 0.5rem;
  text-align: right;
  -moz-appearance: textfield;
}

.survey-hours-inp::-webkit-inner-spin-button,
.survey-hours-inp::-webkit-outer-spin-button,
.survey-hours-other-inp::-webkit-inner-spin-button,
.survey-hours-other-inp::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.survey-hours-other-label {
  flex: 1.3;
  min-width: 0;
  padding: 0.42rem 0.65rem;
}

.survey-hours-inp:focus,
.survey-hours-other-inp:focus,
.survey-hours-other-label:focus {
  outline: none;
  border-color: var(--accent);
}

.survey-hours-unit {
  font-size: 0.85rem;
  color: var(--muted);
}

.survey-hours-total {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.35rem;
}

.survey-q-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  line-height: 1.45;
}

/* Percentage input */
.survey-pct-wrap {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.survey-pct-inp {
  width: 70px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.88rem;
  font-family: inherit;
  text-align: right;
  -moz-appearance: textfield;
}

.survey-pct-inp::-webkit-inner-spin-button,
.survey-pct-inp::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.survey-pct-inp:focus {
  outline: none;
  border-color: var(--accent);
}

.survey-pct-sign {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Category grid */
.survey-cat-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.survey-cg-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.survey-cg-row:last-child {
  border-bottom: none;
}

.survey-cg-cat {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text);
}

.survey-cg-sel {
  width: 160px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 1.8rem 0.4rem 0.6rem;
  font-size: 0.82rem;
  font-family: inherit;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 0.5rem center;
  appearance: none;
}

.survey-cg-sel:focus {
  outline: none;
  border-color: var(--accent);
}

/* Form footer */
.survey-form-footer {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-top: 0.5rem;
  margin-bottom: 1rem;
}

.survey-submit-btn {
  padding: 0.6rem 1.75rem;
  margin-top: 0;
}

.survey-cancel-link {
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

/* Mobile */
@media (max-width: 700px) {
  .page-comment-rating-btn {
    height: 36px;
    font-size: 0.85rem;
  }

  .survey-ts-row {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .survey-ts-sel {
    width: 100%;
  }

  .survey-hours-row {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .survey-hours-other-label,
  .survey-hours-input-wrap {
    width: 100%;
  }

  .survey-hours-inp,
  .survey-hours-other-inp {
    width: 100%;
    text-align: left;
  }

  .survey-cg-row {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .survey-cg-sel {
    width: 100%;
  }

  .survey-scale-btns {
    gap: 0.3rem;
  }

  .survey-scale-btn {
    height: 36px;
    font-size: 0.85rem;
  }
}

/* ── Keyword tags ──────────────────────────────────────────── */
.keyword-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
}

.kw-tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  background: var(--bg-alt, #f0f0f0);
  border-radius: 999px;
  color: var(--text-secondary, #555);
  letter-spacing: 0.01em;
}

/* ── Topic summary (detail page) ─────────────────────────── */
.topic-summary {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-secondary, #555);
  margin: 0.5rem 0 1rem;
  max-width: 52rem;
}

/* ── Card summaries ──────────────────────────────────────── */
.card-summary {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-secondary, #666);
  margin-top: 0.35rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Label groups (custom topic labels) ──────────────────── */
.label-groups {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 0.5rem;
}

.label-group {
  overflow: hidden;
}

.label-header-static {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border, #e0e0e0);
}

.label-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary, #1a1a2e);
}

.label-count {
  font-size: 0.8rem;
  color: var(--text-secondary, #555);
  white-space: nowrap;
}

.label-topics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.5rem;
}

.label-topic-hidden {
  display: none;
}

.label-topics .browse-card {
  margin: 0;
}

.label-show-more,
.label-show-less {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.3rem 0.75rem;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--text-secondary, #666);
  background: none;
  border: 1px solid var(--border, #ccc);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.label-show-more:hover,
.label-show-less:hover {
  background: var(--bg-alt, #f0f0f0);
  color: var(--text-primary, #333);
}

@media (max-width: 600px) {
  .label-topics {
    grid-template-columns: 1fr;
  }
}

/* ── Single-task rating view (#/rate/...) ──────────────────── */

.rate-header {
  margin-bottom: 1.25rem;
}

.rate-header h1 {
  margin-bottom: 0.25rem;
}

.rate-topic-path {
  font-size: 0.85rem;
  color: var(--muted);
}

.rate-info-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-bottom: 1.25rem;
  overflow: hidden;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
}

.rate-info-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--accent);
  border: none;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  text-align: left;
}

.rate-info-toggle h3 {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.4rem;
}

.rate-info-chevron {
  font-size: 0.6rem;
  opacity: 0.8;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.rate-info-panel.collapsed .rate-info-chevron {
  transform: rotate(180deg);
}

.rate-info-body {
  padding: 0.85rem 1rem;
}

.rate-info-panel.collapsed .rate-info-body {
  display: none;
}

.rate-info-body p {
  margin: 0 0 0.5rem;
}

.rate-info-body p:last-child {
  margin-bottom: 0;
}

.rate-info-defs {
  margin: 0.4rem 0 0.6rem;
}

.rate-info-defs dt {
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.45rem;
}

.rate-info-defs dt:first-child {
  margin-top: 0;
}

.rate-info-defs dd {
  margin: 0.1rem 0 0;
}

.rate-progress {
  margin-bottom: 1.25rem;
}

.rate-progress-bar {
  background: var(--border-light);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}

.rate-progress-fill {
  background: var(--accent);
  height: 100%;
  transition: width 0.3s ease;
  border-radius: 4px;
}

.rate-progress-text {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
  margin-top: 0.35rem;
}

.rate-card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  margin-bottom: 1.25rem;
}

.rate-card-meta {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.rate-category-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rate-level-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary, #888);
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}

.rate-task-text {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.rate-dimension {
  margin-bottom: 1.5rem;
}

.rate-dimension:last-of-type {
  margin-bottom: 0.5rem;
}

.rate-dim-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.65rem;
}

.rate-dim-buttons {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.rate-dim-time {
  flex-wrap: wrap;
}

.rate-time-input-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.rate-time-input {
  width: 8rem;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  padding: 0 0.8rem;
}

.rate-time-input:focus {
  outline: none;
  border-color: var(--accent);
}

.rate-time-unit {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.rate-time-hint {
  margin-top: 0.45rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.rate-dimension-minutes {
  text-align: center;
}

.rate-dim-anchors {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--muted);
  max-width: 340px;
  margin: 0 auto;
}

.rate-btn {
  min-width: 44px;
  height: 44px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  padding: 0 0.5rem;
}

.rate-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rate-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.rate-btn-wide {
  min-width: auto;
  height: 38px;
  font-size: 0.82rem;
  padding: 0 0.75rem;
}

.rate-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.rate-nav-btn {
  flex: 0 0 auto;
}

.rate-nav-skip {
  font-size: 0.82rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border-light);
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-family: var(--font);
}

.rate-nav-skip:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.rate-shortcuts {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.5rem 0 1rem;
}

.rate-shortcuts strong {
  font-weight: 600;
}

.topic-rate-link {
  margin: 0.75rem 0 0.5rem;
}

@media (max-width: 600px) {
  .rate-card {
    padding: 1.25rem 1rem;
  }

  .rate-dim-buttons {
    gap: 0.35rem;
  }

  .rate-btn {
    min-width: 38px;
    height: 38px;
    font-size: 0.9rem;
  }

  .rate-btn-wide {
    font-size: 0.72rem;
    padding: 0 0.5rem;
    height: 34px;
  }

  .rate-time-input {
    width: 100%;
    max-width: 10rem;
    height: 40px;
  }

  .rate-nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .rate-shortcuts {
    display: none;
  }
}

/* ── Subfield picker in profile ────────────────────────────── */
.sf-picker-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.sf-picker-row select {
  flex: 1;
  min-width: 140px;
}

.sf-add-btn {
  white-space: nowrap;
}

.sf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.sf-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.82rem;
  background: var(--bg-alt, #f0f0f0);
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  color: var(--text-primary, #333);
}

.sf-chip-x {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted, #999);
  padding: 0;
  line-height: 1;
}

.sf-chip-x:hover {
  color: #ef4444;
}

/* ── Subfield stats row ───────────────────────────────────── */
.sf-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 0.65rem 1rem;
  background: rgba(26, 58, 104, 0.04);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text);
}

.sf-stat-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.sf-stat-item strong {
  color: var(--accent);
}

.subfield-title-row {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

.subfield-title-main {
  min-width: 0;
  flex-shrink: 0;
}

.subfield-title-sparkline {
  margin-left: auto;
  flex-shrink: 0;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 0.3rem;
}

.sf-sparkline-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.sparkline {
  display: block;
  width: 100%;
  height: auto;
}

.sparkline-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-dot {
  fill: var(--accent);
}

.sparkline-val {
  font-size: 13px;
  font-weight: 700;
  fill: var(--accent);
}

.sparkline-axis-label {
  font-size: 11px;
  fill: var(--muted);
}

/* ── Data panel & expanded trend chart ─────────────────────── */
.data-panel {
  margin-bottom: 1.5rem;
}

.trend-chart-wrap {
  margin-top: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem 1rem;
}

.oa-subfield-wrap {
  margin-top: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem 1rem;
}

.oa-subfield-note {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.oa-subfield-median {
  margin-bottom: 0.85rem;
  font-size: 0.82rem;
  color: var(--text);
}

.oa-subfield-median strong {
  color: var(--accent);
}

.oa-subfield-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.oa-subfield-col h4 {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-transform: uppercase;
}

.oa-subfield-list {
  margin: 0;
  padding-left: 1.1rem;
}

.oa-subfield-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.78rem;
}

.oa-subfield-item-name {
  color: var(--text);
  overflow-wrap: anywhere;
}

.oa-subfield-item-metric {
  color: var(--muted);
  white-space: nowrap;
}

.oa-cite-secondary {
  color: var(--muted);
  opacity: 0.65;
  font-size: 0.85em;
  margin-left: 0.3em;
}

.oa-tooltip-wrap {
  position: relative;
  cursor: help;
  font-size: 0.8em;
  color: var(--muted);
  margin-left: 0.3em;
}
.oa-tooltip-wrap .oa-tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #f0f0f0;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.4;
  width: max-content;
  max-width: 240px;
  white-space: normal;
  text-transform: none;
  letter-spacing: normal;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.oa-tooltip-wrap:hover .oa-tooltip-text {
  visibility: visible;
  opacity: 1;
}

.oa-subfield-empty {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.trend-chart-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
  margin-bottom: 0.75rem;
}

.trend-chart-row {
  display: flex;
  align-items: flex-start;
  gap: 2.25rem;
}

.trend-chart-col {
  flex: 1;
  min-width: 0;
  max-width: 540px;
}

.trend-chart-note {
  flex: 0 0 220px;
  margin-left: auto;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted);
}

.trend-chart-note p {
  margin: 0 0 0.6rem;
}

.trend-chart-note p:last-child {
  margin-bottom: 0;
}

.trend-chart-note em {
  color: var(--text);
  font-style: italic;
}

@media (max-width: 700px) {
  .oa-subfield-grid {
    grid-template-columns: 1fr;
  }

  .trend-chart-row {
    flex-direction: column;
  }

  .trend-chart-note {
    flex: none;
    width: 100%;
  }
}

.trend-chart {
  display: block;
  width: 100%;
  max-width: 540px;
  height: auto;
  overflow: visible;
}

.trend-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-line-parent {
  fill: none;
  stroke: #9b8e80;
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  stroke-linecap: round;
}

.trend-area {
  fill: rgba(26, 58, 104, 0.08);
}

.trend-dot {
  fill: var(--accent);
}

.trend-val {
  font-size: 13px;
  font-weight: 700;
  fill: var(--accent);
}

.trend-axis-label {
  font-size: 11px;
  fill: var(--muted);
}

/* ── Verifiability breakdown panel ────────────────────────── */

.verif-breakdown-wrap {
  margin-top: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem 1rem;
}

.verif-breakdown-row {
  display: flex;
  align-items: flex-start;
  gap: 2.25rem;
}

.verif-breakdown-col {
  flex: 1;
  min-width: 0;
  max-width: 540px;
}

.verif-breakdown-note {
  flex: 0 0 220px;
  margin-left: auto;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted);
}

.verif-breakdown-note p {
  margin: 0 0 0.6rem;
}

.verif-breakdown-note p:last-child {
  margin-bottom: 0;
}

@media (max-width: 700px) {
  .verif-breakdown-row {
    flex-direction: column;
  }

  .verif-breakdown-note {
    flex: none;
    width: 100%;
  }
}

.verif-comp-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label value"
    "bar bar";
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.35rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-light);
}

.verif-comp-row:last-child {
  border-bottom: none;
}

.verif-comp-label {
  grid-area: label;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}

.verif-comp-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--muted);
  cursor: help;
  position: relative;
  flex-shrink: 0;
}

.verif-comp-tip-text {
  display: none;
  position: absolute;
  bottom: calc(100% + 0.45rem);
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  background: #2c2c2c;
  color: #fff;
  font-size: 0.72rem;
  line-height: 1.35;
  font-weight: 400;
  white-space: normal;
  z-index: 40;
}

.verif-comp-tip:hover .verif-comp-tip-text,
.verif-comp-tip:focus .verif-comp-tip-text {
  display: block;
}

.verif-comp-bar-wrap {
  grid-area: bar;
  min-width: 0;
}

.verif-comp-track {
  height: 8px;
  background: #eae6df;
  border-radius: 4px;
  position: relative;
}

.verif-comp-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: #a09078;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.verif-comp-marker-overall {
  background: var(--accent);
}

.verif-comp-track-overall {
  background: rgba(26, 58, 104, 0.08);
}

.verif-comp-row-overall {
  padding-bottom: 0.65rem;
}

.verif-comp-label-overall {
  font-weight: 700;
}

.verif-comp-val-overall {
  font-weight: 700;
}


.verif-comp-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.6rem;
  color: var(--muted);
  margin-top: 2px;
  padding: 0 2px;
}

.verif-comp-val {
  grid-area: value;
  font-size: 0.8rem;
  font-weight: 700;
  color: #7a6b5c;
  text-align: right;
  min-width: 0;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .verif-comp-row {
    column-gap: 0.5rem;
  }
}

.verif-comp-unit {
  font-weight: 400;
  font-size: 0.65rem;
  color: var(--muted);
}

.sf-verif-badge {
  position: relative;
}

.sf-info-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  margin-left: 0.3rem;
  cursor: help;
  position: relative;
}

.sf-info-tooltip-text {
  display: none;
  position: absolute;
  bottom: calc(100% + 0.45rem);
  left: 50%;
  transform: translateX(-50%);
  width: 290px;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  background: #2c2c2c;
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.35;
  font-weight: 400;
  white-space: normal;
  text-transform: none;
  letter-spacing: normal;
  z-index: 40;
}

.sf-info-tooltip:hover .sf-info-tooltip-text,
.sf-info-tooltip:focus .sf-info-tooltip-text {
  display: block;
}

/* ── Rated tasks view ──────────────────────────────────────── */
.rated-sf-group {
  margin-bottom: 1.5rem;
}

.rated-sf-heading {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary, #1a1a2e);
}

.rated-sf-field {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--text-secondary, #666);
}

.rated-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.rated-table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary, #666);
  border-bottom: 2px solid var(--border, #ddd);
  padding: 0.4rem 0.5rem;
}

.rated-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border, #eee);
  vertical-align: top;
}

.rated-cell-center {
  text-align: center;
}

/* ── Stat links ──────────────────────────────────────────────── */
.sf-stat-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
  transition: border-color 0.15s, color 0.15s;
}

.sf-stat-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.sf-stat-link strong {
  color: var(--accent);
}

/* ── Rankings page ───────────────────────────────────────────── */
.rankings-view {
  max-width: var(--max-w);
}

.rankings-desc {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  max-width: 42rem;
}

.rankings-tabs {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-light);
}

.rankings-tab {
  padding: 0.5rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

.rankings-tab:hover {
  color: var(--text);
}

.rankings-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.rankings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.rankings-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  padding: 0.55rem 0.75rem;
}

.rankings-th-rank {
  width: 60px;
}

.rankings-th-rate {
  width: 80px;
}

.rankings-th-adjusted {
  width: 130px;
}

.rankings-th-count {
  width: 120px;
}

.rankings-table tbody tr {
  transition: background 0.1s;
}

.rankings-table tbody tr:hover {
  background: rgba(26, 58, 104, 0.04);
}

.rankings-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.rankings-cell-rank {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.rankings-cell-name a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.rankings-cell-name a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rankings-cell-field {
  color: var(--muted);
  font-size: 0.82rem;
}

.rankings-cell-rate {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.rankings-cell-adjusted {
  font-weight: 600;
  white-space: nowrap;
}

.rankings-cell-count {
  color: var(--muted);
  white-space: nowrap;
}

.rankings-code-badge {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.08rem 0.38rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

@media (max-width: 600px) {
  .subfield-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }

  .subfield-title-sparkline {
    width: 100%;
    margin-left: 0;
  }

  .sf-picker-row {
    flex-direction: column;
  }
  .sf-picker-row select {
    width: 100%;
  }
  .rated-table {
    font-size: 0.78rem;
  }
  .rankings-table {
    font-size: 0.82rem;
  }
  .rankings-table td,
  .rankings-table thead th {
    padding: 0.4rem 0.5rem;
  }
  .rankings-cell-field {
    display: none;
  }
  .rankings-th-count,
  .rankings-cell-count {
    display: none;
  }
}
