/* Global foundation */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --teal: #0aa6a6;
  --orange: #ff6f61;
  --coral: #ff7a6e;
  --navy: #0b3a4a;
  --navymid: #0f5867;
  --white: #f8fbfb;
  --sand: #f2f7f7;
  --yellow: #ffc24d;
  --bg: #e7f6f5;
  --bg-2: #cfeeed;
  --surface: #ffffff;
  --surface-2: #f2f7f7;
  --surface-3: #e0f3f3;
  --ink: #10313b;
  --ink-muted: rgba(16, 49, 59, 0.68);
  --accent: var(--coral);
  --accent-strong: var(--orange);
  --accent-soft: #fff6f2;
  --border: rgba(16, 49, 59, 0.12);
  --focus: var(--orange);
  --danger: var(--orange);
  --success: var(--teal);
  --shadow: 0 14px 30px rgba(9, 42, 52, 0.18);
  --radius: 0.75rem;
  --radius-lg: 1.1rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --header-height: 4.5rem;
  --sticky-top: var(--header-height);
  --header-fade-height: 1.75rem;
  --font-body: "Montserrat", "Alegreya Sans", "Open Sans", sans-serif;
  --heading-demarcation: var(--navy);
  --heading-election: var(--navy);
  --motion-fast: 120ms;
  --motion-base: 180ms;
  --motion-slow: 240ms;
  --motion-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --edit-icon-size: 1.8rem;
}

html {
  font-size: 18px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
}

/* Canonical ballot controls are rendered only as a convenience for trusted
   editors. Authorization is independently enforced by the server. */
.editor-page[data-can-edit-base="false"] .district-node .add-district-trigger,
.editor-page[data-can-edit-base="false"] .district-node .add-demarcation-trigger,
.editor-page[data-can-edit-base="false"] .district-node .add-election-trigger,
.editor-page[data-can-edit-base="false"] .district-node .add-candidate-trigger,
.editor-page[data-can-edit-base="false"] .district-node .map-trigger,
.editor-page[data-can-edit-base="false"] .district-node .delete-trigger,
.editor-page[data-can-edit-base="false"] .district-node .edit-trigger,
.editor-page[data-can-edit-base="false"] .district-node .tag-control {
  display: none;
}

.editor-page[data-can-edit-base="false"] .district-focus .resource-actions {
  display: none;
}

main {
  padding: var(--space-6);
}

body.viewer-page main {
  padding-top: var(--space-1);
}

body.viewer-page,
body.viewer-page main {
  background: #ffffff;
}

body.editor-page,
body.editor-page main {
  background: #ffffff;
}

a {
  color: var(--navymid);
  text-decoration: none;
}

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

p {
  color: var(--ink-muted);
  margin: 0 0 var(--space-3);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}

h1 {
  font-size: clamp(2.4rem, 2vw + 2rem, 3.5rem);
  color: var(--navy);
}

h2 {
  font-size: clamp(1.6rem, 1vw + 1.4rem, 2.4rem);
  color: var(--ink);
}

h3 {
  font-size: 1.3rem;
  color: var(--ink);
}

h4 {
  font-size: 1.1rem;
  color: var(--ink);
}

img {
  max-width: 100%;
  height: auto;
}

img.view {
  height: 10em;
  margin: auto;
}

input,
select,
textarea {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  min-height: 2.75rem;
  transition:
    border-color var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-fast) var(--motion-ease),
    background var(--motion-fast) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

input::placeholder,
textarea::placeholder {
  color: rgba(16, 49, 59, 0.45);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  color: var(--ink);
}

button {
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 0.55rem 0.9rem;
  font-size: 1rem;
  font-weight: 600;
  transition:
    transform var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    background var(--motion-base) var(--motion-ease);
}

button:hover {
  border-color: var(--accent-strong);
  background: var(--surface-3);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

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

.success {
  color: var(--success);
}

.orange {
  color: var(--accent);
}

.hide {
  display: none;
}

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

header.app-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  min-height: var(--header-height);
  padding: 0 var(--space-5);
  background: rgba(11, 58, 74, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 100;
}

header.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(-1 * var(--header-fade-height));
  height: var(--header-fade-height);
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.6) 38%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}

header.app-header.has-center {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: var(--space-4);
  border-bottom: 0;
}

header.app-header.has-center::after {
  display: none;
}

a.logo {
  font-size: 1.45rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--navy);
  background: #ffffff;
  border-radius: 0.8rem;
  padding: 0.36rem 0.6rem;
  box-shadow: 0 4px 12px rgba(9, 42, 52, 0.18);
}

.logo img {
  height: 3rem;
  width: auto;
}

a.logo [property="name"] {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  line-height: 1;
}

a.logo .logo-down {
  color: var(--navy);
}

a.logo .logo-ballot {
  color: var(--coral);
}

.header-center {
  display: flex;
  justify-content: center;
  min-width: 0;
  align-self: end;
}

.viewer-header-title-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 3.4rem;
  padding: 1rem 2.2rem 1.05rem 2.2rem;
  background: transparent;
  border: 0;
  color: #ffffff;
  font-weight: 700;
  font-size: clamp(1.35rem, 0.7vw + 1.15rem, 1.9rem);
  line-height: 1.15;
}

.editor-header-title-tab {
  gap: var(--space-2);
  max-width: min(42rem, calc(100vw - 16rem));
}

.editor-header-page-tabs {
  display: inline-flex;
  align-items: flex-end;
  gap: var(--space-2);
  max-width: 100%;
}

.editor-header-page-tabs #ballot-name-editor {
  min-width: 0;
}

.editor-share-trigger-wrap {
  position: relative;
  align-self: center;
}

.editor-share-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  min-height: 2.35rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-weight: 800;
}

.editor-share-trigger-icon {
  width: 0.9rem;
  height: 0.9rem;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: url("/icons/font-awesome/share-nodes.svg") center / contain no-repeat;
  mask: url("/icons/font-awesome/share-nodes.svg") center / contain no-repeat;
}

.editor-share-trigger:hover,
.editor-share-trigger:focus-visible,
.editor-share-trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.16);
}

.editor-share-trigger[aria-disabled="true"] {
  border-color: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.48);
  cursor: not-allowed;
}

.editor-share-disabled-tooltip {
  position: absolute;
  z-index: 1200;
  top: calc(100% + 0.45rem);
  right: 0;
  display: none;
  width: min(13rem, calc(100vw - 1rem));
  padding: 0.55rem 0.65rem;
  border-radius: 0.5rem;
  background: #102f38;
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
}

.editor-share-trigger-wrap:hover .editor-share-disabled-tooltip,
.editor-share-trigger:focus-visible + .editor-share-disabled-tooltip,
.editor-share-trigger-wrap.share-disabled-explanation-visible .editor-share-disabled-tooltip {
  display: block;
}

.editor-header-page-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.2rem;
  padding: 0.85rem 1.4rem 0.92rem 1.4rem;
  background: #ffffff;
  border: 1px solid rgba(16, 49, 59, 0.2);
  border-bottom: 0;
  color: var(--navy);
  font-weight: 700;
  line-height: 1;
}

.editor-header-page-tab-left {
  border-radius: 0.95rem 0.95rem 0 0;
}

.editor-header-page-tab-right {
  border-radius: 0.95rem 0.95rem 0 0;
}

.editor-header-page-tab:not(.selected-tab) {
  background: #e6ebed;
  color: var(--ink-muted);
}

.editor-header-page-tab.selected-tab {
  background: #ffffff;
  color: var(--navy);
}

.editor-header-title-tab .editor-header-title-text {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ffffff;
}

.editor-header-title-tab.ballot-name-edit-trigger {
  cursor: pointer;
  border-radius: 0.85rem 0.85rem 0 0;
  transition:
    background var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-fast) var(--motion-ease);
}

.editor-header-title-tab .ballot-name-edit-icon {
  width: 0.9rem;
  height: 0.9rem;
  flex: 0 0 auto;
  background-color: currentColor;
  mask: url("/icons/font-awesome/pen.svg") center / contain no-repeat;
  -webkit-mask: url("/icons/font-awesome/pen.svg") center / contain no-repeat;
  opacity: 0.82;
}

.editor-header-title-tab.ballot-name-edit-trigger:hover,
.editor-header-title-tab.ballot-name-edit-trigger:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34);
  outline: none;
}

.header-actions {
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

header.app-header .contact-us {
  min-height: 0;
  border: 0;
  font-weight: 600;
  color: #ffffff;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

header.app-header .contact-us:hover,
header.app-header .contact-us:focus-visible {
  background: rgba(255, 255, 255, 0.28);
}

/* Editor layout */
form.ballot {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr;
  row-gap: 0;
  margin: 0 auto var(--space-4);
  width: 100%;
  --editor-tabs-height: 0rem;
}

#save-status {
  min-height: 1.5rem;
  font-weight: 600;
  color: #ffffff;
  background: rgba(11, 58, 74, 0.86);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  animation: fade-slide-in var(--motion-base) var(--motion-ease);
}

#save-status:empty {
  display: none;
}

.editor-tabs {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: var(--space-2);
  align-items: flex-end;
  justify-content: center;
  width: auto;
  max-width: 100%;
  margin: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--space-2) 0 0 0;
}

.editor-tabs .editor-tab,
.editor-tabs button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
  text-align: left;
  text-decoration: none;
  padding: 0.6rem 1rem 0.66rem 1rem;
  background: #e5eaec;
  border: 1px solid rgba(16, 49, 59, 0.22);
  border-bottom: 0;
  border-radius: 0.85rem 0.85rem 0 0;
  transition:
    background var(--motion-fast) var(--motion-ease),
    border-color var(--motion-fast) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

.editor-tabs .editor-tab:hover,
.editor-tabs button:hover {
  background: #edf1f2;
}

.editor-tabs .editor-tab .tab-number,
.editor-tabs button .tab-number {
  display: inline-grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
  background: rgba(16, 49, 59, 0.1);
}

.editor-tabs .editor-tab .tab-label,
.editor-tabs button .tab-label {
  font-family: var(--font-body);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.editor-tabs .editor-tab.selected-tab,
.editor-tabs button.selected-tab {
  background: #ffffff;
  border-color: rgba(16, 49, 59, 0.2);
  border-bottom: 0;
  z-index: 1;
  transform: none;
}

.editor-tabs .editor-tab.selected-tab .tab-number,
.editor-tabs button.selected-tab .tab-number {
  color: var(--navy);
  background: rgba(11, 58, 74, 0.12);
}

.editor-tabs .editor-tab.selected-tab .tab-label,
.editor-tabs button.selected-tab .tab-label {
  color: var(--navy);
}

.editor-tabs-content {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.editor-tabs-content > :not(.hide) {
  animation: panel-in var(--motion-slow) var(--motion-ease);
}

.editor-personalize,
.editor-area,
.share {
  background: var(--surface);
  border: 1px solid rgba(16, 49, 59, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-6);
}

.editor-personalize h3 {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.editor-personalize input[type="text"] {
  max-width: 28rem;
}

.editor-area {
  --sticky-top: calc(var(--header-height) + var(--editor-tabs-height) + var(--space-6));
  display: grid;
  grid-template-columns: minmax(18rem, 1fr) minmax(20rem, 44rem) minmax(18rem, 1fr);
  gap: var(--space-4);
  min-width: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

.editor-empty-state {
  max-width: 46rem;
  padding: clamp(2rem, 5vw, 4rem);
  border: 1px dashed rgba(16, 49, 59, 0.28);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, #ffffff 0%, #f3f8f9 100%);
  text-align: center;
}

.editor-empty-state h2 {
  margin: var(--space-3) 0 var(--space-2);
}

.editor-empty-state > p {
  max-width: 34rem;
  margin: 0 auto;
  color: var(--ink-muted);
}

.editor-empty-icon {
  display: inline-grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  border-radius: 999px;
  background: rgba(239, 114, 104, 0.14);
  color: var(--accent-strong);
  font-size: 1.45rem;
  font-weight: 800;
}

.editor-onboarding-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin: var(--space-6) 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.editor-onboarding-steps li {
  padding: var(--space-3);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 49, 59, 0.08);
}

.editor-onboarding-steps strong,
.editor-onboarding-steps span {
  display: block;
}

.editor-onboarding-steps span {
  margin-top: var(--space-1);
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.editor-area > .table-of-contents,
.editor-area > .editor-map-panel,
.viewer-shell > .table-of-contents,
.viewer-shell > .viewer-share-panel {
  position: sticky;
  top: var(--sticky-top);
  align-self: flex-start;
}

.table-of-contents {
  --toc-frame-bg: #eef4f5;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--toc-frame-bg);
  padding: var(--space-4);
  height: calc(100vh - var(--sticky-top) - var(--space-4));
  max-height: none;
  overflow: hidden;
  min-width: 18rem;
}

.toc-contents {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  max-height: none;
  background: var(--surface);
  border-radius: calc(var(--radius) - 0.2rem);
  padding: var(--space-2) var(--space-2) var(--space-2) 0;
  box-shadow: inset 0 0 0 1px rgba(16, 49, 59, 0.05);
}

.toc-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 2.35rem minmax(0, 1fr);
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  align-content: stretch;
  align-items: stretch;
}

.toc-mode > input[type="radio"] {
  display: none;
}

.toc-mode-tab {
  display: block;
  position: relative;
  text-align: center;
  padding: 0.45rem 0.65rem;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  font-weight: 600;
  align-self: end;
  margin-bottom: -1px;
  z-index: 0;
}

.toc-mode > input:nth-of-type(1) + .toc-mode-tab {
  margin-right: 0.35rem;
}

.toc-mode > input:nth-of-type(2) + .toc-mode-tab {
  margin-right: 0;
}

.toc-mode-tab::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(16, 49, 59, 0.2);
  border-bottom: 0;
  border-radius: 0.5rem 0.5rem 0 0;
  background: #dce5e9;
  z-index: -1;
}

.toc-mode > input:nth-of-type(1):checked + .toc-mode-tab,
.toc-mode > input:nth-of-type(2):checked + .toc-mode-tab {
  color: var(--ink);
  z-index: 1;
}

.toc-mode > input:nth-of-type(1):checked + .toc-mode-tab::before,
.toc-mode > input:nth-of-type(2):checked + .toc-mode-tab::before {
  background: var(--surface);
  border-color: rgba(16, 49, 59, 0.24);
}

.toc-mode > input:nth-of-type(2) + .toc-mode-tab::before {
  border-top-right-radius: 0.5rem;
}

.toc-mode-panels {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid rgba(16, 49, 59, 0.2);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  padding: var(--space-2);
}

.toc-mode-panel {
  display: none;
}

.toc-mode > input:nth-of-type(1):checked ~ .toc-mode-panels > .toc-mode-panel:nth-child(1),
.toc-mode > input:nth-of-type(2):checked ~ .toc-mode-panels > .toc-mode-panel:nth-child(2) {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.toc-search-input {
  margin-bottom: var(--space-2);
}

.toc-search-input label,
.toc-filter-group > label {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 750;
}

.toc-search-input input[type="search"] {
  width: 100%;
}

.toc-search-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.toc-search-options {
  margin-bottom: var(--space-2);
}

.toc-search-options label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

.toc-search-options label:has(select) {
  justify-content: space-between;
}

.toc-state-filter-group {
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid rgba(16, 49, 59, 0.12);
}

.toc-state-filter-group select {
  width: 100%;
}

.toc-starting-prompt {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-4);
  color: var(--ink-muted);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 0.9rem;
}

.toc-starting-prompt strong {
  color: var(--ink);
}

.toc-tag-filter {
  width: auto;
  min-width: 8rem;
  max-width: 12rem;
}

.toc-search-results {
  display: grid;
  gap: var(--space-1);
}

.toc-search-empty {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.toc-link {
  display: inline-block;
  padding: 0.1rem 0;
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}

.toc-link.toc-match {
  color: var(--ink);
  font-weight: 600;
}

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

.toc-mode-panel .toc-contents {
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: var(--space-2) 0 0 0;
}

.toc-combined {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid rgba(16, 49, 59, 0.2);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--space-2);
}

.toc-combined .toc-search-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.toc-combined .toc-contents {
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: var(--space-2) 0 0 0;
}

.toc-branch {
  margin: 0;
}

.toc-summary {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
  list-style: none;
  min-height: 1.45rem;
}

.toc-summary::-webkit-details-marker {
  display: none;
}

.toc-summary > .toc-link,
.toc-leaf-row > .toc-link {
  min-width: 0;
}

.toc-summary > .toc-link {
  flex: 0 1 auto;
}

.toc-leaf-row > .toc-link {
  flex: 0 1 auto;
}

.toc-row-menu-trigger {
  display: none;
  place-items: center;
  flex: 0 0 auto;
  width: 1.45rem;
  height: 1.45rem;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: none;
  opacity: 0.42;
}

.editor-page[data-can-edit-base="true"] .toc-row-menu-trigger {
  display: inline-grid;
}

.copy-recommendations-direct {
  display: none;
}

.editor-page[data-can-edit-base="false"] .copy-recommendations-direct {
  display: inline-grid;
}

.copy-recommendations-trigger {
  place-items: center;
  flex: 0 0 auto;
  width: 1.65rem;
  height: 1.65rem;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  box-shadow: none;
}

.copy-recommendations-trigger:hover,
.copy-recommendations-trigger:focus-visible {
  background: var(--surface-2);
  color: var(--navy);
}

.copy-recommendations-icon {
  width: 0.9rem;
  height: 0.9rem;
  background: currentColor;
  -webkit-mask: url("/icons/font-awesome/copy.svg") center / contain no-repeat;
  mask: url("/icons/font-awesome/copy.svg") center / contain no-repeat;
}

.resource-menu {
  position: relative;
  display: inline-flex;
}

.resource-menu-trigger {
  opacity: 0.72;
}

.copy-recommendations-dialog {
  width: min(32rem, calc(100vw - 1rem));
  max-width: calc(100vw - 1rem);
  max-height: calc(100vh - 1rem);
  padding: 0;
  border: 1px solid rgba(16, 49, 59, 0.22);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1.25rem 3rem rgba(16, 49, 59, 0.24);
}

.copy-recommendations-dialog::backdrop {
  background: rgba(8, 28, 35, 0.46);
}

.copy-recommendations-dialog form {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-5);
  font-size: 0.9rem;
  min-width: 0;
}

.copy-recommendations-dialog form > * {
  min-width: 0;
}

.copy-recommendations-header,
.copy-recommendations-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.copy-recommendations-header h2,
.copy-recommendations-dialog p {
  margin: 0;
}

.copy-recommendations-header h2 {
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: 0;
  min-width: 0;
}

.copy-recommendations-header button,
.copy-recommendations-actions button {
  margin: 0;
}

.copy-recommendations-search-label,
.copy-recommendations-tags legend {
  font-weight: 800;
}

.copy-recommendations-combobox {
  position: relative;
}

.copy-recommendations-combobox input {
  width: 100%;
  margin: 0;
}

.copy-recommendations-results {
  position: absolute;
  inset: calc(100% + 0.2rem) 0 auto;
  z-index: 5;
  max-height: 13rem;
  margin: 0;
  padding: 0.25rem;
  overflow-y: auto;
  list-style: none;
  border: 1px solid rgba(16, 49, 59, 0.22);
  border-radius: calc(var(--radius) - 0.2rem);
  background: #fff;
  box-shadow: 0 0.6rem 1.4rem rgba(16, 49, 59, 0.18);
}

.copy-recommendations-results [role="option"] {
  padding: 0.45rem 0.6rem;
  border-radius: calc(var(--radius) - 0.3rem);
  cursor: pointer;
}

.copy-recommendations-results [role="option"]:hover,
.copy-recommendations-results [role="option"].active {
  background: var(--surface-2);
  color: var(--navy);
}

.copy-recommendations-help {
  color: var(--ink-muted);
  font-size: 0.86rem;
}

.copy-recommendations-tags {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem var(--space-3);
  margin: 0;
  padding: var(--space-3);
  border: 1px solid rgba(16, 49, 59, 0.18);
  border-radius: calc(var(--radius) - 0.2rem);
}

.copy-recommendations-tags legend {
  padding: 0 0.25rem;
}

.copy-recommendations-tags label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.copy-recommendations-tags input {
  min-height: 1.1rem;
  padding: 0;
  margin: 0;
}

.copy-recommendations-actions [type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
}

.copy-recommendations-actions [type="submit"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#copy-recommendations-status {
  min-height: 1.5em;
}

@media (max-width: 28rem) {
  .copy-recommendations-dialog form {
    padding: var(--space-4);
  }

  .copy-recommendations-tags {
    grid-template-columns: 1fr;
  }

  .copy-recommendations-header {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .copy-recommendations-header h2 {
    font-size: 1.1rem;
  }

  .copy-recommendations-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}

.edit-hover-anchor:hover .resource-menu-trigger,
.resource-menu-trigger:hover,
.resource-menu-trigger:focus-visible,
.resource-menu-trigger[aria-expanded="true"] {
  background: var(--surface-2);
  color: var(--navy);
  opacity: 1;
}

.toc-summary:hover .toc-row-menu-trigger,
.toc-leaf-row:hover .toc-row-menu-trigger,
.toc-row-menu-trigger:focus-visible,
.toc-row-menu-trigger[aria-expanded="true"] {
  background: var(--surface-2);
  color: var(--navy);
  opacity: 1;
}

.toc-row-menu-popup {
  position: absolute;
  top: 1.55rem;
  right: 0;
  z-index: 40;
  display: grid;
  gap: 0.1rem;
  width: min(15rem, calc(100% - 1.35rem));
  margin: 0;
  padding: 0.42rem;
  border: 1px solid rgba(16, 49, 59, 0.14);
  border-radius: 0.72rem;
  background: #fff;
  box-shadow:
    0 14px 32px rgba(16, 49, 59, 0.18),
    0 4px 10px rgba(16, 49, 59, 0.09);
  transform-origin: top right;
  animation: toc-menu-enter 150ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.toc-row-menu-popup::after {
  position: absolute;
  top: -0.32rem;
  right: 1.05rem;
  width: 0.58rem;
  height: 0.58rem;
  border-top: 1px solid rgba(16, 49, 59, 0.14);
  border-left: 1px solid rgba(16, 49, 59, 0.14);
  background: #fff;
  content: "";
  transform: rotate(45deg);
}

@keyframes toc-menu-enter {
  from {
    opacity: 0;
    transform: translateY(-0.3rem) scale(0.975);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toc-root,
details.toc-branch,
.toc-leaf-wrap {
  position: relative;
}

.toc-row-menu-popup[hidden] {
  display: none;
}

.toc-row-menu-popup > button {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 2.35rem;
  padding: 0.42rem 0.62rem;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: var(--navy);
  font-size: 0.8rem;
  font-weight: 720;
  text-align: left;
  box-shadow: none;
}

.toc-row-menu-popup > button::before {
  display: inline-block;
  flex: 0 0 1rem;
  width: 1rem;
  height: 1rem;
  background: currentColor;
  content: "";
  opacity: 0.78;
}

.toc-row-menu-popup > button[data-toc-structure-action="rename-district"]::before,
.toc-row-menu-popup > button[data-toc-structure-action="rename-demarcation"]::before,
.resource-menu-popup > button.edit-trigger::before {
  -webkit-mask: url("/icons/font-awesome/pen.svg") center / contain no-repeat;
  mask: url("/icons/font-awesome/pen.svg") center / contain no-repeat;
}

.resource-menu-popup > .resource-menu-tag-control {
  display: grid;
  grid-template-columns: 1rem minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  min-height: 2.35rem;
  padding: 0.42rem 0.62rem;
  color: var(--navy);
  font-size: 0.8rem;
  font-weight: 720;
}

.resource-menu-popup > .resource-menu-tag-control::before {
  width: 1rem;
  height: 1rem;
  background: currentColor;
  content: "";
  opacity: 0.78;
  -webkit-mask: url("/icons/font-awesome/tag.svg") center / contain no-repeat;
  mask: url("/icons/font-awesome/tag.svg") center / contain no-repeat;
}

.resource-menu-tag-control select {
  min-width: 5.5rem;
  margin: 0;
  padding: 0.28rem 1.65rem 0.28rem 0.45rem;
  border: 1px solid rgba(16, 49, 59, 0.2);
  border-radius: 999px;
  background-color: var(--surface);
  color: var(--navy);
  font: inherit;
  cursor: pointer;
}

.toc-row-menu-popup > button[data-toc-structure-action="add-demarcation"]::before,
.toc-row-menu-popup > button[data-toc-structure-action="add-district"]::before {
  display: inline-grid;
  place-items: center;
  border-radius: 0.25rem;
  background: rgba(10, 166, 166, 0.12);
  color: var(--accent-strong);
  content: "+";
  font-size: 1.05rem;
  font-weight: 850;
  line-height: 1;
  opacity: 1;
}

.toc-row-menu-popup > button[data-toc-structure-action="map-demarcation"]::before {
  -webkit-mask: url("/icons/font-awesome/map.svg") center / contain no-repeat;
  mask: url("/icons/font-awesome/map.svg") center / contain no-repeat;
}

.toc-row-menu-popup > button[data-toc-structure-action="delete-district"]::before,
.toc-row-menu-popup > button[data-toc-structure-action="delete-demarcation"]::before,
.resource-menu-popup > button.delete-trigger::before {
  -webkit-mask: url("/icons/font-awesome/trash-can.svg") center / contain no-repeat;
  mask: url("/icons/font-awesome/trash-can.svg") center / contain no-repeat;
}

.toc-row-menu-popup > button:hover,
.toc-row-menu-popup > button:focus-visible {
  background: #eef4f5;
}

.toc-row-menu-popup > button.toc-menu-danger {
  margin-top: 0.24rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(16, 49, 59, 0.1);
  border-radius: 0 0 0.4rem 0.4rem;
  color: #9b332d;
}

.toc-row-menu-popup > button.toc-menu-danger:hover,
.toc-row-menu-popup > button.toc-menu-danger:focus-visible {
  background: rgba(155, 51, 45, 0.08);
  color: #842a25;
}

.toc-menu-editor:not(:empty) {
  padding: 0.2rem;
  border-top: 1px solid rgba(16, 49, 59, 0.1);
}

.toc-menu-editor [data-district-editor],
.toc-menu-editor [data-demarcation-editor] {
  margin-top: 0;
  padding: var(--space-2);
}

.toc-menu-editor .editor-inline-row input[type="text"] {
  min-width: 0;
}

.toc-progress {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  min-width: 2.7rem;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  white-space: nowrap;
}

.toc-progress-incomplete {
  background: #dce5e9;
  color: var(--ink);
}

.toc-progress-complete {
  background: var(--success);
  color: #ffffff;
}

.election-sequence-controls {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  margin: var(--space-2) 0;
}

.district-focus {
  position: sticky;
  top: var(--sticky-top);
  max-height: calc(100vh - var(--sticky-top) - var(--space-4));
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.district-focus-navigation {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(9rem, 1.15fr) minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
}

.district-focus-arrow {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 3.25rem;
  align-items: center;
  gap: var(--space-2);
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--navy);
  text-align: left;
}

.district-focus-next {
  justify-content: flex-end;
  text-align: right;
}

.district-focus-arrow-icon {
  flex: 0 0 auto;
  font-size: 1.25rem;
  line-height: 1;
}

.district-focus-destination {
  min-width: 0;
}

.district-focus-destination small,
.district-focus-destination strong {
  display: block;
}

.district-focus-destination small {
  color: var(--ink-muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.district-focus-destination strong {
  font-size: 0.78rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.district-focus-arrow:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.district-focus-title {
  min-width: 0;
  text-align: center;
}

.editor .district-focus-title-row.edit-hover-anchor {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding-right: 0;
}

.editor .district-focus-title-row.edit-hover-anchor > .resource-actions {
  right: auto;
  left: var(--hover-actions-left, calc(100% + 0.35rem));
}

.district-focus-title h2,
.district-focus-position {
  display: block;
  margin: 0;
}

.district-focus-title h2 {
  overflow-wrap: anywhere;
  font-size: clamp(1.05rem, 1vw + 0.8rem, 1.4rem);
}

.district-focus-position {
  margin-bottom: 0.15rem;
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.district-focus-body {
  padding: var(--space-4);
}

.district-focus-body > .district-node > .district-contents > .demarcation-group {
  display: none;
}

.district-focus-body > .district-node > .resource-header h2 {
  display: none;
}

.district-focus .district-structure-source {
  display: none;
}

.district-structure-panel-content > .district-structure-source {
  display: grid;
  gap: var(--space-3);
}

.district-structure-panel-content > .district-set-list {
  display: grid;
  gap: var(--space-2);
}

.district-structure-panel-content .district-structure-source > .resource-header {
  min-height: 2.4rem;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.district-structure-panel-content .district-structure-source > .resource-header h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1.05rem;
}

.district-set-list,
.district-structure-list {
  display: grid;
  gap: var(--space-2);
}

.district-structure-panel-content .demarcation-group {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: visible;
}

.district-structure-panel-content .demarcation-group.edit-hover-anchor {
  position: relative;
  display: block;
  padding: 0;
  margin: 0;
  gap: 0;
}

.district-set-heading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  min-height: 2.5rem;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  list-style: none;
  text-align: left;
}

.district-set-heading::-webkit-details-marker {
  display: none;
}

.district-set-heading::before {
  content: "▸";
  color: var(--ink-muted);
  transition: transform var(--motion-fast) var(--motion-ease);
}

.demarcation-group[open] > .district-set-heading::before {
  transform: rotate(90deg);
}

.district-set-heading h3 {
  flex: 0 1 auto;
  margin: 0;
  color: var(--heading-demarcation);
  font-size: 0.95rem;
  text-align: left;
}

.district-structure-panel-content .demarcation-group:hover > .resource-actions .hover-action,
.district-structure-panel-content .demarcation-group:focus-within > .resource-actions .hover-action {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.district-structure-panel-content .demarcation-group > .district-set-heading:hover + .resource-actions .hover-action,
.district-structure-panel-content .demarcation-group > .resource-actions:hover .hover-action,
.district-structure-panel-content .demarcation-group > .resource-actions:focus-within .hover-action {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.district-structure-list {
  padding: 0 0.65rem 0.65rem;
}

.district-structure-panel-content .district-node {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-top: 1px solid rgba(16, 49, 59, 0.1);
  border-radius: 0;
  background: transparent;
  animation: none;
}

.district-structure-panel-content .district-node > .district-contents,
.district-structure-panel-content .district-node > .district-structure-source > .district-set-list {
  display: none;
}

.district-structure-panel-content .district-node > .district-structure-source {
  display: block;
}

.district-structure-panel-content .district-node > .district-structure-source > .resource-header {
  min-height: 2.35rem;
  padding: 0.42rem 0;
  border-bottom: 0;
}

.district-structure-panel-content .district-node > .district-structure-source > .resource-header h2 {
  font-size: 0.9rem;
  font-weight: 650;
}

.contest-list-create,
.candidate-list-create,
.district-set-list-create,
.district-list-create {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
}

.contest-list-create {
  margin-bottom: var(--space-2);
}

.candidate-list-create {
  margin-bottom: 0.25rem;
}

.add-list-item {
  min-height: 2rem;
  padding: 0.3rem 0.65rem;
  border: 1px dashed rgba(16, 49, 59, 0.28);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 750;
  box-shadow: none;
}

.add-list-item:hover,
.add-list-item:focus-visible {
  border-color: var(--accent-strong);
  background: var(--surface-2);
}

.editor-page[data-can-edit-base="false"] .district-structure-panel-content .resource-actions,
.editor-page[data-can-edit-base="false"] .district-structure-panel-content .add-list-item {
  display: none;
}

.toc-link[aria-current="true"] {
  color: var(--accent-strong);
  font-weight: 850;
}

.toc-arrow,
.toc-arrow-placeholder {
  display: inline-block;
  width: 0.8rem;
  color: rgba(16, 49, 59, 0.58);
  line-height: 1;
  flex: 0 0 0.8rem;
}

.toc-arrow::before {
  content: "▸";
  display: inline-block;
  transition: transform var(--motion-fast) var(--motion-ease);
}

details[open] > .toc-summary .toc-arrow::before {
  transform: rotate(90deg);
}

.toc-leaf-row {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 1.45rem;
}

.toc-inner {
  position: relative;
  margin-left: 0.45rem;
  padding-left: 0.35rem;
  border-left: 1px dashed rgba(16, 49, 59, 0.2);
}

.toc-inner::before {
  content: "";
  position: absolute;
  left: -0.65rem;
  top: 0;
  bottom: 0;
  width: 0.9rem;
  cursor: pointer;
}

.toc-inner.toc-gutter-hover {
  border-left-color: rgba(16, 49, 59, 0.45);
}

.toc-search-subitem {
  margin-left: 0.4rem;
}

.editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
}

.editor-map-panel {
  --map-panel-padding: var(--space-4);
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #eef4f5;
  padding: var(--space-4);
  min-width: 0;
}

.editor-area > .editor-map-panel {
  box-sizing: border-box;
  height: calc(100dvh - var(--sticky-top) - var(--space-4));
  overflow: hidden;
}

.editor-map-panel-content {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  gap: var(--space-3);
}

.editor-area > .editor-map-panel > .editor-map-panel-content {
  height: 100%;
}

.editor-rail-disclosure {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.editor-rail-disclosure:not([open]) {
  flex: 0 0 auto;
}

.editor-rail-map-disclosure[open] {
  flex: 0 0 auto;
}

.editor-rail-notes-disclosure[open] {
  flex: 1 1 auto;
}

.editor-rail-disclosure-header {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 2.65rem;
  padding: 0.58rem 0.75rem;
  cursor: pointer;
  list-style: none;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 780;
  transition: background var(--motion-fast) var(--motion-ease);
}

.editor-rail-disclosure-header::-webkit-details-marker {
  display: none;
}

.editor-rail-disclosure-header:hover,
.editor-rail-disclosure-header:focus-visible {
  background: var(--surface-2);
}

.editor-rail-disclosure-header::after {
  width: 0.55rem;
  height: 0.55rem;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(45deg) translate(-0.12rem, 0.12rem);
  transition: transform var(--motion-fast) var(--motion-ease);
}

.editor-rail-disclosure[open] > .editor-rail-disclosure-header::after {
  transform: rotate(225deg) translate(-0.12rem, 0.12rem);
}

.editor-rail-disclosure-content {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  padding: 0 var(--space-3) var(--space-3);
}

.editor-rail-disclosure:not([open]) > .editor-rail-disclosure-content {
  display: none;
}

.editor-rail-view {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}

.editor-rail-view[data-editor-rail-view="map"] .editor-sticky-map-canvas {
  flex: 0 0 auto;
  width: 100%;
  min-height: 0;
  aspect-ratio: 1;
}

.editor-rail-view[data-editor-rail-view="notes"] {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.district-structure-panel-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.editor-map-disclosure {
  flex: 0 0 auto;
  margin-top: var(--space-3);
  border-top: 1px solid var(--border);
  padding-top: var(--space-2);
}

.editor-map-disclosure > summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  color: var(--navy);
  font-weight: 750;
  list-style: none;
}

.editor-map-disclosure > summary::-webkit-details-marker {
  display: none;
}

.editor-map-disclosure > summary::after {
  content: "+";
  margin-left: auto;
}

.editor-map-disclosure[open] > summary::after {
  content: "−";
}

.editor-map-disclosure > summary small {
  margin-left: auto;
  color: var(--ink-muted);
  font-size: 0.72rem;
}

.editor-map-disclosure[open] {
  display: flex;
  flex: 0 1 55%;
  min-height: 16rem;
  flex-direction: column;
}

.editor-map-disclosure-content {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: var(--space-2);
}

.editor-map-disclosure-content > [data-map-panel-view="map"] {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.editor-map-disclosure-content > .note-panel:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.editor-map-panel .map-status {
  color: var(--navy);
}

.editor-map-panel .map-status:empty {
  display: none;
}

.editor-share-panel {
  display: grid;
  gap: var(--space-2);
}

.editor-share-popup {
  position: fixed;
  z-index: 950;
  width: min(32rem, calc(100vw - 1rem));
  max-height: calc(100vh - 1rem);
  margin: 0;
  padding: var(--space-4);
  overflow: auto;
  border: 1px solid rgba(16, 49, 59, 0.18);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(9, 42, 52, 0.3), 0 4px 14px rgba(9, 42, 52, 0.18);
}

.editor-share-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.editor-share-popup-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.editor-share-popup-close {
  width: 2rem;
  height: 2rem;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0;
}

.editor-share-popup-close::before {
  content: "";
  display: block;
  width: 0.9rem;
  height: 0.9rem;
  margin: auto;
  background: currentColor;
  -webkit-mask: url("/icons/font-awesome/circle-xmark.svg") center / contain no-repeat;
  mask: url("/icons/font-awesome/circle-xmark.svg") center / contain no-repeat;
}

.editor-share-empty {
  display: grid;
  justify-items: start;
  gap: var(--space-2);
  max-width: 38rem;
}

.editor-share-empty h2,
.editor-share-empty p {
  margin: 0;
}

.primary-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: var(--space-2);
  padding: 0.72rem 1rem;
  border-radius: var(--radius);
  background: var(--coral);
  color: #ffffff;
  font-weight: 750;
  box-shadow: 0 5px 14px rgba(198, 70, 62, 0.2);
}

.editor-share-page {
  background: var(--surface);
  border: 1px solid rgba(16, 49, 59, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-6);
}

.editor-share-panel .viewer-share-url {
  grid-template-columns: minmax(0, 1fr) auto;
}

.editor-social-links {
  display: grid;
  gap: var(--space-2);
}

.editor-social-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: var(--space-2);
  align-items: center;
  min-height: 2rem;
}

.editor-social-row img {
  width: 1.45rem;
  height: 1.45rem;
}

.editor-social-row .edit-hover-anchor {
  min-width: 0;
}

.editor-social-row .editor-social-value {
  color: var(--ink);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.editor-social-row .editor-social-view-count {
  margin-left: var(--space-2);
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.editor-social-row .editor-panel {
  width: 100%;
}

.editor-social-row .editor-inline-row {
  width: 100%;
}

.editor-social-row .editor-inline-row input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
}

.note-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.note-panel[hidden] {
  display: none;
}

.note-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.note-panel-close {
  width: 1.8rem;
  height: 1.8rem;
  min-width: 1.8rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.note-panel-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: min(48vh, 420px);
  overflow: auto;
  padding-right: 0.2rem;
}

.note-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
}

.note-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.note-avatar {
  width: 1.65rem;
  height: 1.65rem;
  min-width: 1.65rem;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #fff;
}

.note-meta {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.note-author {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}

.note-time {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.note-body {
  margin: 0.3rem 0 0;
  white-space: pre-wrap;
}

.note-empty {
  margin: 0;
  color: var(--ink-muted);
}

.note-panel-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.note-panel-form textarea {
  width: 100%;
  resize: vertical;
}

.editor-sticky-map-canvas {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid rgba(16, 49, 59, 0.2);
  background: #f7fafc;
}

.resource-group {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  animation: fade-slide-in var(--motion-base) var(--motion-ease);
}

.resource-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.resource-header.resource-group {
  padding: 0;
  margin-bottom: var(--space-3);
  border: 0;
  box-shadow: none;
  background: transparent;
  animation: none;
}

.resource-header h2,
.resource-header h3,
.resource-header h4 {
  margin: 0;
}

.editor .demarcation-group > .resource-header h3,
.viewer-demarcation-header h3 {
  color: var(--heading-demarcation);
}

.editor .election .resource-header h3,
.editor .election .resource-header h4,
.viewer-election-header h3 {
  color: var(--heading-election);
}

.resource-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.resource-actions button {
  margin: 0;
}

.resource-actions .edit-trigger {
  order: -1;
}

.edit-hover-anchor {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
}

.edit-hover-anchor .resource-actions {
  position: absolute;
  left: var(--hover-actions-left, calc(100% + 0.35rem));
  top: var(--hover-actions-top, 50%);
  z-index: 2;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.hover-action {
  width: var(--edit-icon-size);
  height: var(--edit-icon-size);
  min-width: var(--edit-icon-size);
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(16, 49, 59, 0.28);
  background: rgba(255, 255, 255, 0.96);
  color: transparent;
  font-size: 0;
  line-height: 1;
  box-shadow: 0 5px 12px rgba(16, 49, 59, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
  transition:
    opacity var(--motion-fast) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease),
    border-color var(--motion-fast) var(--motion-ease),
    background var(--motion-fast) var(--motion-ease);
}

.hover-action::before {
  width: 0.9rem;
  height: 0.9rem;
  flex: 0 0 auto;
  display: inline-block;
  background-color: var(--navy);
  content: "";
  mask: var(--action-icon) center / contain no-repeat;
  -webkit-mask: var(--action-icon) center / contain no-repeat;
}

.edit-trigger::before {
  --action-icon: url("/icons/font-awesome/pen.svg");
}

.add-election-trigger::before,
.add-demarcation-trigger::before,
.add-district-trigger::before,
.add-candidate-trigger::before {
  content: none;
}

.delete-trigger::before {
  --action-icon: url("/icons/font-awesome/trash-can.svg");
}

.map-trigger::before {
  --action-icon: url("/icons/font-awesome/map.svg");
}

.note-trigger::before {
  --action-icon: url("/icons/font-awesome/note-sticky.svg");
  margin-right: 0.32rem;
}

.hover-action.add-election-trigger,
.hover-action.add-demarcation-trigger,
.hover-action.add-district-trigger,
.hover-action.add-candidate-trigger,
.hover-action.note-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 0.18rem;
  width: auto;
  min-width: 0;
  padding: 0 0.55rem;
  border-radius: 999px;
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.tag-control.hover-action {
  display: inline-flex;
  align-items: center;
  flex: 0 0 7.25rem;
  gap: 0.2rem;
  width: 7.25rem;
  min-width: 7.25rem;
  height: var(--edit-icon-size);
  min-height: var(--edit-icon-size);
  padding: 0;
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  overflow: visible;
  position: relative;
}

.tag-control::before {
  --action-icon: url("/icons/font-awesome/tag.svg");
  width: 0.78rem;
  height: 0.78rem;
  margin-left: 0.55rem;
}

.tag-control .tag-arrow {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.55rem;
  opacity: 0.82;
  pointer-events: none;
}

.tag-control .tag-select {
  display: block;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 100%;
  min-height: var(--edit-icon-size);
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  padding: 0 1.2rem 0 0.2rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.hover-action:hover {
  border-color: var(--accent-strong);
  background: var(--surface-3);
  transform: scale(1);
}

.hover-action:active {
  transform: scale(0.95);
}

.edit-hover-anchor:hover .hover-action,
.edit-hover-anchor:focus-within .hover-action {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.note-trigger-label {
  display: none;
}

.note-trigger-count {
  display: inline;
  white-space: nowrap;
}

.editor .edit-hover-anchor {
  width: 100%;
  padding-right: 5.75rem;
}

.editor .edit-hover-anchor > .resource-actions {
  right: 0;
  left: auto;
}

.editor .resource-header.edit-hover-anchor {
  width: fit-content;
  max-width: 100%;
  padding-right: 0;
}

.editor .resource-header.edit-hover-anchor > .resource-actions {
  right: auto;
  left: var(--hover-actions-left, calc(100% + 0.35rem));
}

.editor .district-node > .resource-header {
  min-height: 2.8rem;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid rgba(16, 49, 59, 0.1);
}

.editor .district-node > .resource-header h2 {
  font-size: clamp(1.3rem, 1vw + 1rem, 1.75rem);
  line-height: 1.2;
}

.editor .demarcation-group > .resource-header h3 {
  font-size: 1.05rem;
}

.nest {
  margin-left: var(--space-3);
  padding-left: var(--space-3);
  border-left: 2px solid rgba(16, 49, 59, 0.18);
}

/* Keep editor tree DOM nesting for behavior, but remove visual nesting chrome. */
.editor .nest {
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
}

.editor .district-node,
.editor .demarcation-group {
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.election {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  animation: fade-slide-in var(--motion-base) var(--motion-ease);
}

.district-focus .election {
  gap: 0;
  margin-bottom: var(--space-2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 0.15rem);
  background: var(--surface);
  overflow: visible;
}

.toc-root-summary {
  cursor: default;
}

.toc-root-children {
  position: relative;
}

.district-focus .election > .resource-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
  padding: 0.65rem 0.75rem;
}

.district-focus .election > .resource-header h3,
.district-focus .election > .resource-header h4 {
  grid-column: 1;
  grid-row: 1;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  font-size: 1rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.editor .district-focus .contest-title-anchor {
  grid-column: 1;
  grid-row: 1;
  width: fit-content;
  max-width: 100%;
  padding-right: 0;
}

.contest-picker-trigger {
  display: inline-flex;
  grid-column: 1;
  grid-row: 2;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.38rem 0.55rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--navy);
  text-align: left;
}

.editor .district-focus .contest-title-anchor > .resource-actions {
  position: absolute;
  top: 50%;
  right: auto;
  bottom: auto;
  left: calc(100% + 0.35rem);
  z-index: 10;
  width: max-content;
  max-width: min(22rem, calc(100vw - 2rem));
  transform: translateY(-50%);
  flex-wrap: wrap;
  justify-content: flex-start;
}

@media (hover: none), (pointer: coarse) {
  .editor .district-focus .contest-title-anchor {
    width: 100%;
    flex-wrap: wrap;
  }

  .editor .district-focus .contest-title-anchor > .resource-actions {
    position: static;
    width: 100%;
    max-width: 100%;
    margin-top: 0.25rem;
  }

  .editor .district-focus .contest-title-anchor > .resource-actions .hover-action {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
  }
}

.contest-pick-summary {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contest-picker-chevron::before {
  display: block;
  content: "▾";
  transition: transform var(--motion-fast) var(--motion-ease);
}

.contest-picker-open .contest-picker-chevron::before {
  transform: rotate(180deg);
}

.district-focus .election:not(.contest-picker-open) > .election-choices {
  display: none;
}

.district-focus .election > .election-choices {
  padding: 0.35rem 0.75rem 0.55rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.set-candidate-picker {
  display: grid;
  grid-template-columns: minmax(20rem, 26rem) minmax(12rem, 1fr);
  align-items: stretch;
  gap: clamp(var(--space-5), 4vw, 4rem);
  width: 100%;
}

.set-candidate-list {
  min-width: 0;
}

.candidate-selection-guidance {
  display: grid;
  min-width: 0;
  min-height: 100%;
  place-items: center;
  padding: var(--space-6);
  border-left: 1px solid rgba(16, 49, 59, 0.12);
  color: var(--ink-muted);
  font-size: clamp(1rem, 0.5vw + 0.9rem, 1.2rem);
  font-weight: 750;
  text-align: center;
}

.set-candidate-picker.candidate-limit-reached .candidate-selection-guidance {
  color: var(--navy);
}

.contest-picker-done {
  margin-left: auto;
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.election > h4 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.election-choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.election-choices label {
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.4rem 0.9rem;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}

.election-choices label:hover {
  border-color: var(--accent-strong);
}

.election-choices label.choice-undecided {
  border-style: dashed;
  background: var(--surface-2);
  color: var(--ink-muted);
}

.election-choices label.choice-undecided input {
  accent-color: #71838a;
}

.choice-state {
  padding: 0.1rem 0.36rem;
  border-radius: 999px;
  background: rgba(16, 49, 59, 0.1);
  color: var(--navy);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

[id^="election-header-"],
[id^="candidate-row-"] {
  scroll-margin-top: calc(var(--header-height) + var(--space-6));
}

[id^="election-header-"]:target,
[id^="candidate-row-"]:target {
  border-radius: var(--radius);
  background: rgba(10, 166, 166, 0.08);
  box-shadow: 0 0 0 4px rgba(10, 166, 166, 0.08);
}

.election-choices input {
  width: 1rem;
  height: 1rem;
}

div[id^="candidate-row-"] {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border-radius: var(--radius);
  animation: fade-slide-in var(--motion-base) var(--motion-ease);
  transition: background var(--motion-fast) var(--motion-ease), transform var(--motion-fast) var(--motion-ease);
}

.district-focus div[id^="candidate-row-"],
.district-focus li[id^="candidate-row-"] {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.65rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid rgba(16, 49, 59, 0.1);
  border-radius: 0;
  background: transparent;
}

.editor .district-focus .set-candidate-list div[id^="candidate-row-"] {
  flex-wrap: nowrap;
  width: 100%;
  padding-right: 0;
}

.editor .district-focus .set-candidate-list div[id^="candidate-row-"] > .resource-actions {
  position: static;
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  margin-left: auto;
  transform: none;
  flex-wrap: nowrap;
}

div[id^="candidate-row-"] .hover-action {
  transform: scale(0.92);
}

div[id^="candidate-row-"]:hover .hover-action,
div[id^="candidate-row-"]:focus-within .hover-action {
  transform: scale(1);
}

div[id^="candidate-row-"] .hover-action:hover {
  transform: scale(1);
}

div[id^="candidate-row-"] .hover-action:active {
  transform: scale(0.95);
}

div[id^="candidate-row-"]:hover {
  background: rgba(255, 255, 255, 0.62);
  transform: none;
}

div[id^="candidate-row-"] + div[id^="candidate-row-"] {
  margin-top: 0;
}

div[id^="candidate-row-"] label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.38rem 0.25rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
}

.district-focus div[id^="candidate-row-"]:has(input:checked) {
  margin-inline: -0.35rem;
  padding-inline: 0.35rem;
  border-radius: var(--radius-sm);
  background: rgba(10, 166, 166, 0.1);
}

div[id^="candidate-row-"] label input[type="checkbox"] {
  accent-color: var(--navy);
}

.set-candidate-list label:has(input[type="checkbox"]:disabled) {
  color: var(--ink-muted);
  cursor: not-allowed;
  opacity: 0.52;
}

.set-candidate-list input[type="checkbox"]:disabled {
  cursor: not-allowed;
}

.editor-navigation-pending .editor-tabs-content {
  opacity: 0.6;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.editor-help-button {
  align-self: center;
  cursor: pointer;
  background: var(--coral) !important;
}

.editor-help-button:hover,
.editor-help-button:focus-visible {
  background: var(--orange) !important;
}

.context-help {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  box-sizing: border-box;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  opacity: 0.5;
  z-index: 4;
}

.context-help:hover,
.context-help:focus-visible,
.context-help[aria-expanded="true"] {
  opacity: 0.85;
  transform: none;
}

.context-help:active {
  transform: none;
}

.context-help-icon {
  width: 0.8rem;
  height: 0.8rem;
  background: currentColor;
  -webkit-mask: url("/icons/font-awesome/circle-question.svg") center / contain no-repeat;
  mask: url("/icons/font-awesome/circle-question.svg") center / contain no-repeat;
}

.context-help-search,
.context-help-tag {
  width: 1.5rem;
  height: 2.75rem;
  opacity: 0.62;
}

.context-help-search .context-help-icon {
  width: 0.9rem;
  height: 0.9rem;
  -webkit-mask-image: url("/icons/font-awesome/magnifying-glass.svg");
  mask-image: url("/icons/font-awesome/magnifying-glass.svg");
}

.context-help-tag .context-help-icon {
  width: 0.9rem;
  height: 0.9rem;
  -webkit-mask-image: url("/icons/font-awesome/tag.svg");
  mask-image: url("/icons/font-awesome/tag.svg");
}

.toc-icon-filter-row {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem;
}

.toc-icon-filter-row > input,
.toc-icon-filter-row > select {
  min-width: 0;
  width: 100%;
}

.context-tooltip {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  display: none;
  width: min(18rem, 75vw);
  padding: 0.65rem 0.75rem;
  border-radius: 0.55rem;
  background: #102f38;
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  opacity: 1;
}

.context-tooltip.context-tooltip-positioned {
  position: fixed;
  right: auto;
  top: 0;
  left: 0;
  z-index: 1200;
}

.context-help:not(.context-help-tooltip-dismissed):hover .context-tooltip,
.context-help:not(.context-help-tooltip-dismissed):focus-visible .context-tooltip,
.context-help[aria-expanded="true"] .context-tooltip {
  display: block;
}

.toc-label-with-help {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.45rem;
  max-width: 100%;
  vertical-align: middle;
}

.toc-label-with-help > input[type="checkbox"] {
  flex: 0 0 auto;
  width: 1.1rem;
  height: 1.1rem;
  min-height: 0;
  margin: 0.18rem 0 0;
  padding: 0;
}

.toc-label-copy {
  display: block;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  line-height: 1.35;
}

.toc-label-copy > label {
  display: inline;
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.toc-search-options .toc-label-copy > label {
  font-size: 0.82rem;
}

.toc-label-copy > .context-help {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  margin: 0 0 0 0.08rem;
  padding: 0.22rem;
  border-radius: 50%;
  vertical-align: -0.28rem;
}

.toc-label-copy > .context-help .context-help-icon {
  width: 0.82rem;
  height: 0.82rem;
}

.toc-label-copy > .context-help:hover,
.toc-label-copy > .context-help:focus-visible,
.toc-label-copy > .context-help[aria-expanded="true"] {
  background: var(--surface-3);
}

.toc-label-copy > .context-help::after {
  content: "";
  position: absolute;
  inset: -0.12rem;
}

.toc-search-options > .toc-label-with-help {
  width: fit-content;
}

.toc-search-options > select {
  width: 100%;
  margin-top: var(--space-1);
}

.editor-tutorial[hidden],
.editor-tutorial [hidden] {
  display: none !important;
}

.editor-tutorial {
  position: fixed;
  z-index: 1000;
  overflow: visible;
}

.editor-tutorial-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  max-height: inherit;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
  box-shadow:
    0 18px 48px rgba(9, 42, 52, 0.28),
    0 4px 14px rgba(9, 42, 52, 0.18);
}

.editor-tutorial-header,
.editor-tutorial-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.editor-tutorial-picker {
  flex: 1 1 auto;
}

.editor-tutorial-picker select {
  width: 100%;
  min-height: 2.15rem;
  padding: 0.3rem 1.8rem 0.3rem 0.55rem;
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--navy);
  font-weight: 750;
}

.editor-tutorial-close,
.tutorial-arrow {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
}

.editor-tutorial-close:hover,
.editor-tutorial-close:focus-visible,
.tutorial-arrow:hover,
.tutorial-arrow:focus-visible {
  background: var(--surface-2);
  color: var(--navy);
}

.editor-tutorial-close span,
.tutorial-arrow span {
  display: block;
  width: 0.85rem;
  height: 0.85rem;
  background: currentColor;
}

.editor-tutorial-close span {
  -webkit-mask: url("/icons/font-awesome/circle-xmark.svg") center / contain no-repeat;
  mask: url("/icons/font-awesome/circle-xmark.svg") center / contain no-repeat;
}

.tutorial-arrow-previous span {
  -webkit-mask: url("/icons/font-awesome/caret-left.svg") center / contain no-repeat;
  mask: url("/icons/font-awesome/caret-left.svg") center / contain no-repeat;
}

.tutorial-arrow-next span {
  -webkit-mask: url("/icons/font-awesome/caret-right.svg") center / contain no-repeat;
  mask: url("/icons/font-awesome/caret-right.svg") center / contain no-repeat;
}

.tutorial-arrow:disabled {
  opacity: 0.25;
}

.editor-tutorial-progress,
.editor-tutorial-card h2,
.editor-tutorial-card p {
  margin: 0;
}

.editor-tutorial-card h2 {
  font-size: 1.08rem;
  line-height: 1.25;
}

.editor-tutorial-card h2:focus {
  outline: none;
}

.editor-tutorial-card [data-tutorial-copy] {
  color: var(--ink-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.editor-tutorial-progress {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tutorial-practice-banner {
  position: fixed;
  right: auto;
  bottom: var(--space-3);
  left: 50%;
  z-index: 975;
  width: max-content;
  max-width: calc(100vw - (2 * var(--space-3)));
  margin: 0;
  padding: 0.6rem 0.75rem;
  border-left: 4px solid var(--accent-strong);
  border-radius: var(--radius);
  background: #fff7dd;
  color: var(--navy);
  box-shadow: var(--shadow-sm);
  font-size: 0.86rem;
  font-weight: 800;
  pointer-events: none;
  transform: translateX(-50%);
}

@media (max-height: 600px) {
  .tutorial-practice-banner {
    top: var(--space-2);
    bottom: auto;
  }
}

.tutorial-highlight {
  outline: 3px solid var(--coral) !important;
  outline-offset: 3px;
  border-radius: var(--radius);
  box-shadow:
    0 0 0 4px rgba(255, 122, 110, 0.34),
    0 0 12px 7px rgba(255, 122, 110, 0.22),
    0 0 26px 13px rgba(255, 122, 110, 0.08) !important;
}

.hover-action.tutorial-highlight,
.tag-control.tutorial-highlight {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
}

.contest-editor-field {
  display: grid;
  gap: 0.25rem;
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.contest-editor-field input,
.contest-editor-field select {
  color: var(--ink);
}

.contest-editor-checkbox {
  display: inline-flex;
  align-items: center;
  align-self: end;
  min-height: 2.75rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.ranked-choice {
  display: grid;
  width: min(100%, 54rem);
  gap: var(--space-3);
}

.ranked-choice-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--ink);
}

.ranked-choice-heading span,
.ranked-choice-empty {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.ranked-choice-heading-available {
  margin-top: var(--space-2);
}

.ranked-candidate-list {
  display: grid;
  gap: var(--space-2);
  padding: 0;
  margin: 0;
  list-style: none;
}

.ranked-candidate-list .ranked-candidate {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 3.25rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.ranked-candidate-dragging {
  opacity: 0.64;
  box-shadow: 0 0 0 3px rgba(10, 166, 166, 0.18);
}

.ranked-recommendation-controls {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.ranked-recommendation-controls button {
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--surface-2);
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 700;
}

.ranked-recommendation-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ranked-drag-handle {
  cursor: grab;
  touch-action: none;
}

.ranked-candidate-dragging .ranked-drag-handle {
  cursor: grabbing;
}

.ranked-position {
  display: inline-grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
}

.ranked-candidate-name {
  flex: 1 1 auto;
  min-width: 8rem;
  color: var(--ink);
  font-weight: 700;
}

.ranked-candidate-list-available .ranked-drag-handle,
.ranked-candidate-list-available .ranked-position,
.ranked-candidate-list-available [data-ranked-action="up"],
.ranked-candidate-list-available [data-ranked-action="down"],
.ranked-candidate-list-available [data-ranked-action="remove"],
.ranked-candidate-list:not(.ranked-candidate-list-available) .ranked-add {
  display: none;
}

@media (max-width: 720px) {
  .ranked-choice-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-1);
  }

  .ranked-candidate-list .ranked-candidate {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .ranked-candidate-name {
    order: -1;
    flex-basis: 100%;
  }
}

[data-candidate-editor],
[data-district-editor],
[data-demarcation-editor],
[data-election-editor] {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  margin-top: var(--space-2);
  border-radius: var(--radius);
  border: 1px dashed rgba(16, 49, 59, 0.22);
  background: var(--surface-2);
  animation: fade-slide-in var(--motion-base) var(--motion-ease);
}

.editor-panel {
  animation: editor-open var(--motion-slow) var(--motion-ease);
  transform-origin: top center;
}

.editor-inline-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.editor-inline-row input[type="text"] {
  flex: 1 1 18rem;
  min-width: 12rem;
}

.editor-inline-row select {
  flex: 0 0 auto;
}

.candidate-party-fixed,
.contest-partisanship {
  color: var(--ink-muted);
  font-size: 0.875rem;
}

.candidate-party-fixed {
  flex: 0 0 auto;
}

.candidate-inline-row {
  flex-wrap: nowrap;
}

.candidate-inline-row input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
}

.candidate-inline-row .party-inline-select {
  flex: 0 0 auto;
  width: 3.5rem;
  min-width: 3.5rem;
  padding-inline: 0.35rem;
  font-size: 0.8rem;
}

.ballot-name-inline-row {
  flex-wrap: nowrap;
}

.ballot-name-inline-row input[type="text"] {
  flex: 0 1 28rem;
  min-width: 12rem;
}

.ballot-name-inline-row .editor-inline-actions {
  margin-left: 0;
}

.editor-inline-row input[name="seats"] {
  width: 5rem;
  flex: 0 0 auto;
}

.editor-inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}

.editor-action-trigger {
  width: var(--edit-icon-size);
  height: var(--edit-icon-size);
  min-width: var(--edit-icon-size);
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(16, 49, 59, 0.28);
  background: rgba(255, 255, 255, 0.96);
  color: transparent;
  font-size: 0;
  line-height: 1;
}

.editor-action-trigger::before {
  width: 0.95rem;
  height: 0.95rem;
  display: inline-block;
  background-color: var(--navy);
  content: "";
  mask: var(--action-icon) center / contain no-repeat;
  -webkit-mask: var(--action-icon) center / contain no-repeat;
}

.editor-action-trigger:hover {
  border-color: var(--accent-strong);
  background: var(--surface-3);
}

.save-trigger::before {
  --action-icon: url("/icons/font-awesome/circle-check.svg");
}

.cancel-trigger::before {
  --action-icon: url("/icons/font-awesome/circle-xmark.svg");
}

.share {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(12rem, 16rem);
  gap: var(--space-5);
  align-items: start;
}

.share-center input[type="text"] {
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  color: var(--navy);
  background: rgba(255, 122, 110, 0.16);
  border-color: rgba(255, 122, 110, 0.6);
}

.share-center a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: var(--space-3);
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  background: var(--accent);
  color: #2b1b16;
  font-weight: 700;
  transition: transform var(--motion-fast) var(--motion-ease), box-shadow var(--motion-base) var(--motion-ease);
}

.share-center a:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(255, 111, 97, 0.25);
}

.share-right {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
}

.share-right a {
  color: var(--navy);
}

.share-right img {
  border-radius: var(--radius);
  background: #fff;
  padding: var(--space-2);
  width: 2rem;
  height: 2rem;
}

/* Viewer */
.viewer {
  max-width: 44rem;
  margin: 0 auto var(--space-5);
  padding: var(--space-6);
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(16, 49, 59, 0.12);
  box-shadow: var(--shadow);
  animation: panel-in var(--motion-slow) var(--motion-ease);
}

.viewer.viewer-wide,
.viewer-shell {
  width: 100%;
}

.viewer.viewer-wide {
  max-width: 78rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

.viewer-shell {
  --sticky-top: calc(var(--header-height) + var(--space-6));
  display: grid;
  grid-template-columns: minmax(17rem, 21rem) minmax(22rem, 1fr) minmax(14rem, 18rem);
  gap: var(--space-4);
  align-items: start;
  min-width: 0;
}

.viewer-shell .view {
  min-width: 0;
  padding-top: var(--space-6);
}

.viewer-share-panel {
  display: grid;
  gap: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #eef4f5;
  padding: var(--space-4);
}

.viewer-share-url {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: center;
}

.viewer-share-url input[type="text"] {
  min-width: 0;
}

.viewer label {
  font-size: 1.1rem;
}

.viewer p {
  color: var(--ink-muted);
}

.viewer-landing {
  width: min(52rem, 100%);
  margin-left: auto;
  margin-right: auto;
}

.editor-lazy-node {
  min-height: 2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-muted);
}

.editor-loading-spinner {
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid rgba(16, 49, 59, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: editor-loading-spin 0.7s linear infinite;
}

@keyframes editor-loading-spin {
  to { transform: rotate(360deg); }
}

.district-contents-toggle {
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 0.86rem;
  margin: var(--space-2) 0;
}

#copy-status {
  min-height: 1.5rem;
  text-align: center;
  font-weight: 600;
  margin-bottom: var(--space-3);
}

#copy-status:not(:empty) {
  animation: fade-slide-in var(--motion-base) var(--motion-ease);
}

#copy-status:empty {
  display: none;
}

.viewer-node-header,
.viewer-demarcation-header,
.viewer-election-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.viewer-tree .election {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  background: var(--surface);
}

.viewer-nest {
  display: grid;
  gap: var(--space-3);
}

.copy-button {
  padding: 0.4rem 0.8rem;
  font-size: 0.95rem;
  background: rgba(16, 49, 59, 0.06);
  border-color: rgba(16, 49, 59, 0.2);
  transition: background var(--motion-fast) var(--motion-ease), border-color var(--motion-fast) var(--motion-ease);
}

.copy-button:hover {
  background: rgba(255, 122, 110, 0.18);
  border-color: rgba(255, 122, 110, 0.6);
}

.copy-button-primary {
  font-weight: 700;
}

.copy-button-inline {
  opacity: 0.2;
}

.viewer-node-header:focus-within .copy-button-inline,
.viewer-demarcation-header:focus-within .copy-button-inline,
.viewer-election-header:focus-within .copy-button-inline,
.viewer-node-header:hover .copy-button-inline,
.viewer-demarcation-header:hover .copy-button-inline,
.viewer-election-header:hover .copy-button-inline {
  opacity: 1;
}

.header-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  text-align: center;
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.header-buttons {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2);
  background: rgba(16, 49, 59, 0.06);
  border-radius: var(--radius);
  align-items: center;
}

.share-buttons button {
  padding: 0.45rem 0.8rem;
}

table,
td,
th {
  border: 1px solid var(--border);
  background: var(--surface);
}

td,
th {
  padding: var(--space-2);
}

table * {
  color: var(--ink);
  font-size: 1rem;
}

table {
  border-collapse: collapse;
  margin-left: auto;
  margin-right: auto;
  width: min(70rem, 100%);
}

table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
}

.print-only {
  display: none;
}

/* Misc */
.center-title {
  text-align: center;
}

.center-button {
  display: flex;
  justify-content: center;
}

.left,
.right,
.center {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.how-it-works {
  display: grid;
  grid-template-columns: 40% auto;
  gap: var(--space-5);
}

.how-it-works img {
  width: 100%;
  margin-top: var(--space-3);
}

.screen {
  height: 100vw;
  width: auto;
}

.outer {
  padding: 7em;
  max-width: 100em;
  margin: 0 auto;
}

.outer img {
  width: 100%;
}

.share-buttons {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
}

.share-buttons a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  color: var(--navy);
}

.share-buttons a img {
  width: 1.45rem;
  height: 1.45rem;
  min-width: 1.45rem;
}

.share-buttons .social-handle {
  min-width: 0;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

img.qr {
  height: 4rem;
  width: 4rem;
  padding: 0.2rem;
  background: #fff;
  border-radius: var(--radius);
}

img.big-qr {
  height: 10rem;
  width: 10rem;
  padding: 0.35rem;
  background: #fff;
  border-radius: var(--radius);
}

img.share-buttons {
  height: 2rem;
}

hr {
  border: none;
  border-top: 1px solid rgba(16, 49, 59, 0.1);
  margin: var(--space-4) 0;
}

.lookup-card {
  display: grid;
  max-width: 46rem;
  margin: var(--space-5) auto;
  gap: var(--space-3);
}

.lookup-panel {
  animation: fade-slide-in var(--motion-base) var(--motion-ease);
}

.lookup-lead {
  font-size: 1.1rem;
  color: var(--ink);
  font-weight: 600;
}

.lookup-help {
  font-size: 0.95rem;
  color: var(--ink-muted);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0;
  justify-content: flex-start;
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  box-shadow:
    0 -1px 1px rgba(16, 49, 59, 0.025),
    0 10px 20px rgba(16, 49, 59, 0.08),
    -4px 0 10px rgba(16, 49, 59, 0.045),
    4px 0 10px rgba(16, 49, 59, 0.045),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.tabs > [type=radio] {
  display: none;
}

.tabs > [type=radio] + label {
  order: 1;
  cursor: pointer;
  padding: 0.55rem 1rem;
  margin-right: 0.35rem;
  margin-bottom: -1px;
  border-radius: 0.7rem 0.7rem 0 0;
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--border);
  border-bottom-color: transparent;
  font-weight: 700;
  transition:
    background var(--motion-fast) var(--motion-ease),
    border-color var(--motion-fast) var(--motion-ease),
    color var(--motion-fast) var(--motion-ease);
}

.tabs > [type=radio] + label:hover {
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
}

.tabs > [type=radio]:checked + label {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
  border-bottom-color: var(--surface);
}

.tabs > [type=radio] + label + .content {
  width: 100%;
  flex-basis: 100%;
  order: 2;
  display: none;
  margin-top: 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  background: var(--surface);
}

.tabs > [type=radio]:checked + label + .content {
  display: block;
  animation: fade-slide-in var(--motion-base) var(--motion-ease);
}

form.address {
  display: grid;
  gap: var(--space-2);
  justify-items: stretch;
  width: 100%;
}

form.address input,
form.address select {
  width: 100%;
  max-width: none;
}

form.address input[type="submit"] {
  width: auto;
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: #2b1b16;
  font-weight: 700;
  transition: transform var(--motion-fast) var(--motion-ease), box-shadow var(--motion-base) var(--motion-ease);
}

form.address input[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(255, 111, 97, 0.25);
}

.lookup-tab-link {
  display: inline-block;
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: #2b1b16;
  font-weight: 700;
  transition: transform var(--motion-fast) var(--motion-ease), box-shadow var(--motion-base) var(--motion-ease);
}

.lookup-tab-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(255, 111, 97, 0.25);
}

.address-autocomplete-results {
  width: 100%;
}

.address-suggestion-list {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
  box-shadow: var(--shadow);
  max-height: 12rem;
  overflow-y: auto;
}

.address-suggestion {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  cursor: pointer;
}

.address-suggestion:last-child {
  border-bottom: 0;
}

.address-suggestion:hover {
  background: var(--surface-2);
}

/* Landing page */
body.landing-page main {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

body.landing-page .highlight {
  color: var(--accent-strong);
}

body.landing-page .hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

body.landing-page .hero-text {
  max-width: 54rem;
}

body.landing-page .hero-text p {
  font-size: 1.2rem;
}

body.landing-page .feature-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

body.landing-page .card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: var(--space-5);
  overflow: hidden;
}

body.landing-page .card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(10, 166, 166, 0.06), rgba(255, 122, 110, 0.1));
  pointer-events: none;
}

body.landing-page .card > * {
  position: relative;
  z-index: 1;
}

body.landing-page .card-title {
  margin-top: var(--space-2);
}

body.landing-page .card-icon {
  max-height: 2.8rem;
}

body.landing-page .mobile-only {
  display: none;
}

@keyframes fade-slide-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes editor-open {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (hover: none) {
  .copy-button-inline {
    opacity: 1;
  }

  .edit-trigger {
    opacity: 1;
    pointer-events: auto;
  }
}

#demarcation-map-modal {
  width: min(92vw, 960px);
  max-width: 960px;
  border: 1px solid rgba(16, 49, 59, 0.22);
  border-radius: var(--radius);
  padding: var(--space-3);
  background: #ffffff;
  color: #111827;
  opacity: 1;
}

#demarcation-map-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.demarcation-map-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

#demarcation-map-upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
}

#demarcation-map-canvas {
  width: 100%;
  height: min(70vh, 620px);
  border-radius: var(--radius);
  border: 1px solid rgba(16, 49, 59, 0.2);
  background: #f7fafc;
}

#demarcation-map-status {
  margin: 0 0 var(--space-2) 0;
  color: #111827;
}

.district-structure-panel-content .district-set-heading {
  justify-content: flex-start;
  padding-right: 6.75rem;
  text-align: left;
}

.district-structure-panel-content .district-set-heading h3 {
  margin-right: 0;
  text-align: left;
}

.district-structure-panel-content .demarcation-group > .resource-actions {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  left: auto;
  width: auto;
  max-width: none;
  flex-wrap: nowrap;
  transform: none;
  z-index: 2;
}

.district-structure-panel-content .demarcation-group > .resource-actions .hover-action {
  transition: none;
}

.district-structure-panel-content .demarcation-group:hover > .resource-actions .hover-action,
.district-structure-panel-content .demarcation-group:focus-within > .resource-actions .hover-action {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

@media (max-width: 1420px) {
  .viewer-shell {
    grid-template-columns: minmax(18rem, 23rem) minmax(0, 1fr);
  }

  .viewer-share-panel {
    grid-column: 1 / -1;
    position: static;
  }

  .editor .edit-hover-anchor {
    flex-wrap: wrap;
    padding-right: 0;
  }

  .editor .edit-hover-anchor > .resource-actions {
    position: static;
    width: 100%;
    max-width: 100%;
    transform: none;
    flex-wrap: wrap;
  }

  .editor .district-focus-title-row.edit-hover-anchor {
    flex-wrap: nowrap;
  }

  .editor .district-focus-title-row.edit-hover-anchor > .resource-actions {
    position: absolute;
    right: auto;
    left: calc(100% + 0.35rem);
    width: auto;
    max-width: none;
    transform: translateY(-50%);
    flex-wrap: nowrap;
  }

  .district-structure-panel-content .demarcation-group > .resource-actions {
    position: absolute;
    top: 0.35rem;
    right: 0.45rem;
    left: auto;
    width: auto;
    max-width: none;
    flex-wrap: nowrap;
  }
}

@media (max-width: 1100px) {
  header.app-header.has-center {
    grid-template-columns: auto auto;
    grid-template-areas:
      "logo actions"
      "tabs tabs";
    row-gap: var(--space-2);
    align-items: center;
    padding: var(--space-2) var(--space-4) 0 var(--space-4);
  }

  header.app-header.has-center .logo {
    grid-area: logo;
  }

  header.app-header.has-center .header-actions {
    grid-area: actions;
  }

  header.app-header.has-center .header-center {
    grid-area: tabs;
    justify-content: center;
  }

  .editor-header-title-tab {
    max-width: 100%;
  }

  .editor-header-page-tabs {
    width: 100%;
    justify-content: center;
  }

  .editor-header-page-tab {
    padding: 0.72rem 1rem 0.8rem 1rem;
    min-height: 2.8rem;
  }

  .editor-tabs {
    flex-direction: row;
    overflow-x: auto;
    gap: var(--space-2);
    width: 100%;
    justify-content: flex-start;
  }

  .editor-tabs .editor-tab,
  .editor-tabs button {
    min-width: auto;
  }

  .editor-area {
    grid-template-columns: 1fr;
  }

  .editor-onboarding-steps {
    grid-template-columns: 1fr;
  }

  .viewer-shell {
    grid-template-columns: 1fr;
  }

  .editor {
    grid-row: 1;
    width: 100%;
  }

  .district-focus {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .editor-area > .table-of-contents {
    grid-row: 2;
    position: static;
    height: auto;
    max-height: none;
  }

  .editor-area > .editor-map-panel {
    grid-column: 1;
    grid-row: 3;
    position: sticky;
    top: var(--sticky-top);
    z-index: 20;
    max-height: calc(100vh - var(--sticky-top) - var(--space-3));
    overflow: auto;
    box-shadow: 0 8px 24px rgba(16, 49, 59, 0.14);
  }

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

  body.landing-page .feature-cards {
    grid-template-columns: 1fr;
  }

  body.landing-page .mobile-only {
    display: block;
  }
}

@media (max-width: 700px) {
  main {
    padding: var(--space-4);
  }

  .editor-tabs-content,
  .editor-area,
  .editor,
  .editor-area > .table-of-contents {
    min-width: 0;
    max-width: 100%;
  }

  .editor-area > .table-of-contents {
    box-sizing: border-box;
    width: 100%;
  }

  .election-choices,
  .election-choices label {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
  }

  .set-candidate-picker {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
  }

  .candidate-selection-guidance {
    grid-row: 1;
    min-height: 0;
    place-items: start;
    padding: 0 0 var(--space-2);
    border-left: 0;
    border-bottom: 1px solid rgba(16, 49, 59, 0.12);
    font-size: 0.9rem;
    text-align: left;
  }

  .set-candidate-list {
    grid-row: 2;
  }

  .district-focus-navigation {
    grid-template-columns: minmax(0, 1.2fr) minmax(5.25rem, 0.8fr) minmax(0, 1.2fr);
    gap: var(--space-2);
    padding: var(--space-2);
  }

  .district-focus-arrow {
    min-height: 2.75rem;
    padding: 0.35rem 0.45rem;
  }

  .district-focus-destination small {
    display: none;
  }

  .district-focus-destination strong {
    font-size: 0.72rem;
  }

  .district-focus-body {
    padding: var(--space-2);
  }

  .district-focus .election > .resource-header {
    align-items: stretch;
    flex-direction: column;
  }

  .contest-picker-trigger {
    width: 100%;
    min-width: 0;
    justify-content: space-between;
    text-align: left;
  }

  .editor-map-panel {
    --map-panel-padding: var(--space-3);
    padding: var(--space-3);
  }

  header.app-header.has-center {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "logo"
      "actions"
      "tabs";
    padding-inline: var(--space-2);
  }

  header.app-header.has-center .logo {
    justify-self: center;
  }

  header.app-header.has-center .header-actions {
    width: 100%;
    min-width: 0;
    margin-left: 0;
    justify-content: center;
    flex-wrap: wrap;
  }

  .editor-header-page-tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.25rem;
  }

  .editor-header-page-tab {
    min-width: 0;
    padding-inline: 0.55rem;
  }

  .editor-header-title-tab {
    width: 100%;
    min-width: 0;
    padding-inline: 0.45rem;
  }

  .editor-help-button {
    min-width: 0;
    padding-inline: 0.6rem;
  }
}
