@font-face {
  font-family: 'Frutiger';
  src: url('../../assets/Frutiger.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Frutiger';
  src: url('../../assets/Frutiger_bold.ttf') format('truetype');
  font-weight: 600 900;
  font-display: swap;
}

:root {
  --bg: #f3f1e9;
  --surface: #f8f6ef;
  --paper: #fffef9;
  --text: #283b32;
  --muted: #747d74;
  --border: #cdd2c7;
  --green: #35634b;
  --focus: #bb7542;
  --shadow: none;

  --header-height: 80px;
  --column-header-height: 106px;
  --world-column-header-height:
    calc(var(--column-header-height) / 0.42);
  --minimum-decade-height: 180px;
  --column-width: 340px;
  --visible-column-width: 20%;
  --axis-width: 138px;
  --axis-label-font-size: 34px;
  --axis-label-padding: 17px;
  --timeline-text-scale: 1;
  --timeline-zoom: 0.42;
  --canvas-scale: 0.42;
  --card-min-width: 168px;

  --timeline-line: #d8dad4;
  --header-fill: #f3f1e9;
  --axis-fill: #ebe9e2;

  --melbourne-strong: #35634b;
  --australia-strong: #9b6240;
  --world-strong: #4e6c75;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Frutiger', Arial, Helvetica, sans-serif;
}

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

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(55, 104, 180, 0.28);
  outline-offset: 2px;
}

/* Top navigation */

.site-header {
  position: relative;
  z-index: 60;
  height: var(--header-height);
  display: grid;
  grid-template-columns:
    minmax(220px, 1fr)
    minmax(360px, 560px)
    auto;
  gap: 16px;
  align-items: center;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.title-block h1,
.title-block p,
.column-header h2,
.column-header p,
.timeline-card h3,
.timeline-card p,
.dialog-header h2,
.dialog-header p {
  margin: 0;
}

.title-block h1 {
  font-size: 1rem;
  line-height: 1.2;
}

.title-block p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
}

.header-tools {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.filter-dropdown {
  position: relative;
}

.filter-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.filter-hamburger {
  font-size: 1rem;
  line-height: 1;
}

.filter-button.has-active-filters {
  border-color: #314c79;
  background: #eef3fa;
  color: #20375e;
}

.filter-menu {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  z-index: 90;
  width: min(280px, calc(100vw - 36px));
  max-height: 360px;
  padding: 8px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.filter-options {
  display: grid;
  gap: 2px;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 5px;
  color: #34445e;
  font-size: 0.78rem;
  cursor: pointer;
}

.filter-option:hover {
  background: #f4f6f9;
}

.filter-option input {
  margin: 0;
}

.filter-empty {
  margin: 6px 8px;
  color: var(--muted);
  font-size: 0.76rem;
}

.filter-clear {
  width: 100%;
  margin-top: 7px;
  padding: 8px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: #46546c;
  font-size: 0.75rem;
  text-align: left;
  cursor: pointer;
}

.search-wrap {
  position: relative;
  display: block;
}

.search-wrap input {
  width: 100%;
  height: 38px;
  padding: 0 38px 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
}

.search-wrap span {
  position: absolute;
  top: 50%;
  right: 15px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.header-actions,
.dialog-actions,
.dialog-actions-right,
.linked-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button,
.icon-button {
  border-radius: 8px;
}

.button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  font-size: 0.8rem;
  font-weight: 650;
}

.button-primary {
  background: #15233d;
  color: #fff;
}

.button-secondary {
  border-color: var(--border);
  background: #fff;
  color: var(--text);
}

.button-danger {
  background: #b42318;
  color: #fff;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.7rem;
  line-height: 1;
}

/* Timeline shell */

.app-shell {
  height: calc(100vh - var(--header-height));
  display: grid;
  grid-template-columns:
    var(--axis-width)
    minmax(0, 1fr);
  overflow: hidden;
  background: var(--bg);
}

.timeline-axis {
  position: relative;
  z-index: 50;
  min-width: 0;
  overflow: hidden;
  background: var(--axis-fill);
  border-right: 2px solid #bbb8b1;
  user-select: none;
}

.axis-spacer {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 50;
  height: var(--column-header-height);
  background: var(--axis-fill);
  border-bottom: 1px solid #b8b5ae;
}

.axis-window {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.decade-labels {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% / var(--canvas-scale));
  transform-origin: 0 0;
  will-change: transform;
}

.axis-world-spacer {
  height: var(--world-column-header-height);
  background: var(--header-fill);
  border-bottom: 1px solid #c4c1ba;
}

.decade-label {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  min-height: var(--minimum-decade-height);
  padding: var(--axis-label-padding);
  color: #1f2b3d;
  font-size: var(--axis-label-font-size);
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.02em;
  border-top: 1px solid var(--timeline-line);
  user-select: none;
}

.decade-label:first-of-type {
  border-top: 0;
}

.decade-label:last-child {
  border-bottom: 1px solid var(--timeline-line);
}

.decade-label > span {
  max-width: 100%;
  white-space: nowrap;
}

.timeline-viewport,
.timeline-scroller {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.timeline-scroller {
  width: 100%;
  height: 100%;
  overscroll-behavior: none;
  touch-action: none;
  cursor: grab;
  scrollbar-width: none;
  user-select: none;
  -webkit-user-select: none;
}

.timeline-scroller::-webkit-scrollbar {
  display: none;
}

.timeline-scroller.is-space-pan-ready,
.timeline-scroller.is-canvas-panning {
  cursor: grabbing;
}

.timeline-scroller.is-canvas-pan-pending,
.timeline-scroller.is-canvas-panning,
.timeline-scroller.is-canvas-pan-pending *,
.timeline-scroller.is-canvas-panning * {
  user-select: none !important;
  -webkit-user-select: none !important;
}

.timeline-scroller.is-canvas-panning
  .timeline-card {
  pointer-events: none;
}

.timeline-track {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  width: max-content;
  min-height: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.timeline-column {
  width: var(--column-width);
  flex: 0 0 var(--column-width);
  min-width: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
}

/* Fixed column headers */

.column-header-viewport {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 55;
  height: var(--column-header-height);
  overflow: hidden;
  pointer-events: none;
  background: var(--header-fill);
  border-bottom: 1px solid #b8b5ae;
  user-select: none;
}

.column-header-track {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  width: max-content;
  height: var(--column-header-height);
  transform-origin: 0 0;
  will-change: transform;
}

.pinned-column-header-shell {
  width: var(--visible-column-width);
  flex: 0 0 var(--visible-column-width);
  min-width: 0;
  height: var(--column-header-height);
  color: #263143;
  background: var(--header-fill);
  border-right: 1px solid #c4c1ba;
}

.pinned-column-header-shell[
  data-column-key='melbourne'
] {
  color: var(--melbourne-strong);
}

.pinned-column-header-shell[
  data-column-key='australia'
] {
  color: var(--australia-strong);
}

.pinned-column-header-shell[
  data-column-key='world'
] {
  color: var(--world-strong);
}

.pinned-column-header-shell[
  data-column-key='__unused_evaluation'
] {
  color: var(--evaluation-strong);
}

.pinned-column-header-shell[
  data-column-key='__unused_news'
] {
  color: var(--news-strong);
}

.column-header {
  position: relative;
  width: 100%;
  height: var(--column-header-height);
  min-height: var(--column-header-height);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  padding: 13px 12px 10px;
  overflow: hidden;
  background: var(--header-fill);
  border-bottom: 1px solid #c4c1ba;
}

.column-header > div {
  min-width: 0;
}

.column-header h2 {
  overflow-wrap: anywhere;
  color: currentColor;
  font-size: 0.86rem;
  font-weight: 820;
  line-height: 1.18;
}

.column-header p {
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: #586173;
  font-size: 0.65rem;
  line-height: 1.25;
}

.pinned-column-header {
  pointer-events: none;
  user-select: none;
}

.column-header-spacer {
  height: var(--world-column-header-height);
  min-height: var(--world-column-header-height);
  visibility: hidden;
  pointer-events: none;
}

/* Timeline rows and cards */

.column-grid {
  display: flex;
  flex-direction: column;
  min-height:
    calc(28 * var(--minimum-decade-height));
}

.decade-cell {
  container-type: inline-size;
  display: grid;
  grid-template-columns:
    repeat(
      auto-fill,
      minmax(
        min(
          100%,
          max(
            var(--card-min-width),
            168px
          )
        ),
        1fr
      )
    );
  align-content: start;
  align-items: start;
  gap: 10px;
  min-height: var(--minimum-decade-height);
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  border-top: 1px solid var(--timeline-line);
}

.decade-cell:first-child {
  border-top: 0;
}

.decade-cell:last-child {
  border-bottom: 1px solid var(--timeline-line);
}

.timeline-card {
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  min-inline-size: 0;
  justify-self: stretch;
  padding: 13px 13px 46px;
  overflow: hidden;
  border:
    1px solid
    rgba(108, 119, 139, 0.22);
  border-left:
    4px solid
    var(--entry-accent, currentColor);
  border-radius: 10px;
  background: color-mix(in srgb, var(--entry-accent, #ffffff) 5%, #ffffff);
  color: var(--text);
  box-shadow:
    0 4px 13px
    rgba(18, 31, 53, 0.07);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition:
    opacity 120ms ease,
    filter 120ms ease,
    box-shadow 120ms ease,
    border-color 120ms ease;
}

.timeline-card,
.timeline-card * {
  min-width: 0;
  min-inline-size: 0;
}

.timeline-card:hover,
.timeline-card:focus-within,
.timeline-card.is-primary,
.timeline-card.is-related {
  z-index: 10;
}

.timeline-card:hover {
  box-shadow: var(--shadow);
}

.timeline-column[
  data-column-key='melbourne'
] .timeline-card {
  --entry-accent: var(--melbourne-strong);
}

.timeline-column[
  data-column-key='australia'
] .timeline-card {
  --entry-accent: var(--australia-strong);
}

.timeline-column[
  data-column-key='world'
] .timeline-card {
  --entry-accent: var(--world-strong);
}

.timeline-column[
  data-column-key='__unused_evaluation'
] .timeline-card {
  --entry-accent: var(--evaluation-strong);
}

.timeline-column[
  data-column-key='__unused_news'
] .timeline-card {
  --entry-accent: var(--news-strong);
}

.card-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.timeline-card h3,
.card-year,
.card-authority,
.card-author,
.card-description,
.tag-pill,
.linked-pill,
.source-link {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}

.timeline-card h3 {
  flex: 1 1 auto;
  font-size:
    calc(
      0.98rem *
      var(--timeline-text-scale)
    );
  line-height: 1.3;
}

.card-profile-image {
  display: block;
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  object-fit: cover;
  object-position: center;
  border: 1px solid rgba(66, 81, 106, 0.18);
  border-radius: 8px;
  background: #e8edf4;
}

.edit-entry-button {
  position: absolute;
  right: 11px;
  bottom: 10px;
  z-index: 2;
  flex: 0 0 auto;
  width: 29px;
  height: 29px;
  padding: 0;
  border: 1px solid #d3dae5;
  border-radius: 7px;
  background: #fff;
  color: #536178;
  font-size:
    calc(
      0.88rem *
      var(--timeline-text-scale)
    );
  line-height: 1;
  cursor: pointer;
}

.edit-entry-button:hover {
  border-color: #aab5c5;
  background: #f4f6f9;
  color: #243854;
}

.card-year {
  display: block;
  margin-top: 5px;
  color: #46546c;
  font-size:
    calc(
      0.73rem *
      var(--timeline-text-scale)
    );
  font-weight: 800;
  letter-spacing: 0.04em;
}

.card-meta {
  margin-top: 8px;
}

.card-authority,
.card-author {
  font-size:
    calc(
      0.73rem *
      var(--timeline-text-scale)
    );
  line-height: 1.38;
}

.card-authority {
  color: #35435b;
  font-weight: 750;
}

.card-author {
  margin-top: 2px;
  color: var(--muted);
}

.card-description {
  margin-top: 10px;
  padding: 9px 10px;
  border:
    1px solid
    rgba(126, 139, 158, 0.16);
  border-radius: 7px;
  background:
    rgba(237, 241, 246, 0.72);
  color: #445166;
  font-size:
    calc(
      0.76rem *
      var(--timeline-text-scale)
    );
  line-height: 1.48;
}

.card-tags,
.card-linked,
.linked-editor-pills,
.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-tags,
.card-linked-section {
  margin-top: 10px;
}

.card-tags {
  align-items: center;
}

.tag-pill,
.linked-pill,
.filter-tag,
.linked-editor-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size:
    calc(
      0.67rem *
      var(--timeline-text-scale)
    );
  line-height: 1.25;
}

.tag-pill {
  background: #edf1f6;
  color: #42516a;
}

.tag-divider {
  flex: 0 0 11px;
  width: 11px;
  height: 1px;
  margin: 0 1px;
  background: rgba(66, 81, 106, 0.42);
}

.topic-list {
  color: #5a6678;
  font-size:
    calc(
      0.59rem *
      var(--timeline-text-scale)
    );
  line-height: 1.3;
}

.card-linked-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size:
    calc(
      0.67rem *
      var(--timeline-text-scale)
    );
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.linked-pill,
.linked-editor-pill {
  border: 1px solid #c8d3e2;
  background: #f7f9fc;
  color: #34445e;
}

.card-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 11px;
}

.source-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 31px;
  padding: 0 12px;
  border: 1px solid #c6d0dd;
  border-radius: 7px;
  background: #fff;
  color: #213b68;
  font-size:
    calc(
      0.72rem *
      var(--timeline-text-scale)
    );
  font-weight: 750;
  cursor: pointer;
}

.source-link:hover {
  border-color: #98a9bf;
  background: #f5f7fa;
}

/* Focus and relationship highlighting */

.timeline-track.has-focused-entry
  .timeline-card.is-dimmed {
  opacity: 0.2;
  filter:
    brightness(0.34)
    saturate(0.35)
    contrast(1.08);
  box-shadow: none;
}

.timeline-track.has-focused-entry
  .timeline-card.is-primary,
.timeline-track.has-focused-entry
  .timeline-card.is-related {
  position: relative;
  z-index: 10;
  opacity: 1;
  filter: none;
  border:
    2px solid
    var(--entry-accent, currentColor);
  border-left-width: 4px;
  box-shadow:
    0 7px 18px
    rgba(20, 30, 46, 0.15);
}

.timeline-track.has-focused-entry
  .timeline-card.is-primary {
  z-index: 11;
  box-shadow:
    0 9px 22px
    rgba(20, 30, 46, 0.2);
}

.timeline-card.is-primary,
.timeline-card.is-primary * {
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}

.timeline-card.is-primary
  .edit-entry-button,
.timeline-card.is-primary
  .source-link {
  cursor: pointer;
}

/*
 * At lower zoom levels descriptions are hidden by default.
 * Only the hovered, keyboard-focused or selected card displays its
 * description inside the normal card layout.
 */

html[
  data-timeline-descriptions='collapsed'
] .card-description {
  display: none;
}

html[
  data-timeline-descriptions='collapsed'
] .timeline-card:hover,
html[
  data-timeline-descriptions='collapsed'
] .timeline-card:focus-within,
html[
  data-timeline-descriptions='collapsed'
] .timeline-card.is-primary {
  height: auto;
  overflow: hidden;
}

html[
  data-timeline-descriptions='collapsed'
] .timeline-card:hover
  .card-description,
html[
  data-timeline-descriptions='collapsed'
] .timeline-card:focus-within
  .card-description,
html[
  data-timeline-descriptions='collapsed'
] .timeline-card.is-primary
  .card-description {
  position: static;
  display: block;
  width: auto;
  max-width: none;
  margin-top: 10px;
  border:
    1px solid
    rgba(126, 139, 158, 0.16);
  background:
    rgba(237, 241, 246, 0.72);
  box-shadow: none;
}

html[
  data-timeline-descriptions='collapsed'
] .timeline-track.has-focused-entry
  .timeline-card.is-dimmed
  .card-description {
  display: none;
}

/* Relationship overlay */

.relationship-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 100ms ease;
}

.relationship-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

/*
 * Explicit linked_to relationships:
 * coloured wavy arrows at 30% opacity,
 * meaning 70% transparent.
 */

.relationship-link-line {
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-opacity: 0.3;
  vector-effect: non-scaling-stroke;
  filter:
    drop-shadow(
      0 0 1px
      rgba(255, 255, 255, 0.9)
    );
}

.relationship-arrow-head {
  opacity: 0.3;
  vector-effect: non-scaling-stroke;
  filter:
    drop-shadow(
      0 0 1px
      rgba(255, 255, 255, 0.9)
    );
}

/*
 * Same-authority network:
 * the main vertical trunk follows a column boundary,
 * horizontal rails follow decade-row boundaries,
 * and each source receives one straight branch.
 */

.authority-bus-line,
.authority-bus-rail,
.authority-bus-branch {
  fill: none;
  stroke: #111;
  stroke-opacity: 0.56;
  stroke-linecap: square;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
  shape-rendering: geometricPrecision;
  filter:
    drop-shadow(
      0 0 1px
      rgba(255, 255, 255, 0.95)
    );
}

.authority-bus-line {
  stroke-width: 2.4;
}

.authority-bus-rail {
  stroke-width: 2.2;
}

.authority-bus-branch {
  stroke-width: 1.9;
}

/* Dialogs and forms */

.entry-dialog,
.filter-dialog {
  width:
    min(
      720px,
      calc(100vw - 28px)
    );
  max-height:
    calc(100vh - 34px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  box-shadow:
    0 24px 70px
    rgba(13, 24, 43, 0.25);
}

.entry-dialog::backdrop,
.filter-dialog::backdrop {
  background:
    rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(2px);
}

.entry-dialog form,
.filter-dialog {
  padding: 22px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.dialog-header h2 {
  font-size: 1.12rem;
}

.dialog-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.8rem;
}

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

.form-grid label,
.form-field,
.linked-editor {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.form-grid label > span,
.field-label {
  color: #344054;
  font-size: 0.79rem;
  font-weight: 750;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.linked-picker-row select {
  width: 100%;
  border: 1px solid #ccd4df;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.form-grid input,
.form-grid select,
.linked-picker-row select {
  min-height: 42px;
  padding: 0 11px;
}

.form-grid textarea {
  min-height: 112px;
  padding: 10px 11px;
  resize: vertical;
}

.form-grid small,
.linked-editor small {
  color: var(--muted);
  font-size: 0.7rem;
}

.form-full {
  grid-column: 1 / -1;
}

.combobox {
  position: relative;
  width: 100%;
  min-width: 0;
}

.combobox input {
  padding-right: 42px;
}

.combobox-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 39px;
  height: 40px;
  padding: 0;
  border: 0;
  border-left: 1px solid #d6dde6;
  border-radius: 0 7px 7px 0;
  background: #f8fafc;
  color: #526076;
  font-size: 1rem;
}

.combobox-menu {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  z-index: 80;
  max-height: 220px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid #c9d2df;
  border-radius: 8px;
  background: #fff;
  box-shadow:
    0 12px 28px
    rgba(20, 35, 61, 0.16);
}

.combobox-option,
.combobox-empty {
  width: 100%;
  padding: 8px 9px;
  overflow-wrap: anywhere;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #344054;
  text-align: left;
  font-size: 0.78rem;
}

.combobox-option:hover,
.combobox-option:focus-visible {
  background: #eef2f7;
}

.combobox-empty {
  display: block;
  color: var(--muted);
  cursor: default;
}

.linked-editor-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 11px;
  border: 1px solid #ccd4df;
  border-radius: 8px;
  background: #fbfcfe;
}

.linked-picker-row {
  min-width: 0;
}

.linked-picker-row select {
  flex: 1 1 auto;
  min-width: 0;
}

.linked-editor-pills {
  min-height: 26px;
}

.linked-editor-pills:empty::before {
  content: 'No linked entries selected.';
  color: var(--muted);
  font-size: 0.75rem;
}

.linked-editor-pill {
  gap: 7px;
  padding-right: 5px;
}

.linked-editor-pill button {
  width: 19px;
  height: 19px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #e3e8ef;
  color: #4a5568;
  font-size: 0.76rem;
  line-height: 1;
}

.dialog-actions {
  justify-content: space-between;
  margin-top: 23px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.filter-tags {
  min-height: 60px;
}

.filter-tag {
  border: 1px solid #d1d8e2;
  background: #fff;
  color: #3d4b61;
}

.filter-tag.active {
  border-color: #314c79;
  background: #e9eff8;
  color: #20375e;
}

.status-message {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width:
    min(
      420px,
      calc(100vw - 40px)
    );
  padding: 11px 14px;
  border-radius: 9px;
  background: #17233a;
  color: #fff;
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.status-message.visible {
  opacity: 1;
  transform: translateY(0);
}

.status-message.error {
  background: #9f261d;
}

.hidden {
  display: none !important;
}

/* Compact card fallbacks */

@container (max-width: 180px) {
  .timeline-card {
    padding: 9px;
  }

  .timeline-card h3 {
    font-size: 0.9rem;
    line-height: 1.18;
  }

  .card-description,
  .card-tags,
  .card-linked-section,
  .card-actions {
    display: none;
  }

  html[
    data-timeline-descriptions='collapsed'
  ] .timeline-card:hover
    .card-description,
  html[
    data-timeline-descriptions='collapsed'
  ] .timeline-card:focus-within
    .card-description,
  html[
    data-timeline-descriptions='collapsed'
  ] .timeline-card.is-primary
    .card-description {
    display: block;
  }
}

@container (max-width: 135px) {
  .card-meta {
    display: none;
  }

  .timeline-card h3 {
    font-size: 0.84rem;
    line-height: 1.15;
  }

  .edit-entry-button {
    width: 22px;
    height: 22px;
  }
}

/* Responsive layout */

@media (max-width: 900px) {
  :root {
    --header-height: 116px;
    --column-header-height: 98px;
    --axis-width: 90px;
  }

  .site-header {
    grid-template-columns:
      minmax(0, 1fr)
      auto;
    grid-template-rows:
      auto
      auto;
    gap: 8px 12px;
    padding: 9px 12px;
  }

  .search-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .header-actions {
    justify-self: end;
  }

  .search-wrap input {
    height: 36px;
  }

  .header-actions .button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.72rem;
  }

  .column-header {
    padding: 11px 9px 8px;
  }

  .column-header h2 {
    font-size: 0.78rem;
  }

  .column-header p {
    font-size: 0.62rem;
    line-height: 1.2;
  }

  .decade-cell {
    padding: 8px;
  }

  .timeline-card {
    padding: 10px;
    border-left-width: 3px;
  }
}

@media (max-width: 620px) {
  :root {
    --header-height: 112px;
    --column-header-height: 94px;
    --axis-width: 72px;
  }

  .site-header {
    padding: 8px 10px;
  }

  .title-block p {
    display: none;
  }

  .title-block h1 {
    font-size: 0.88rem;
  }

  .header-actions {
    gap: 5px;
  }

  .header-actions .button {
    min-height: 32px;
    padding: 0 6px;
    font-size: 0.63rem;
  }

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

  .form-full {
    grid-column: auto;
  }

  .linked-picker-row {
    align-items: stretch;
    flex-direction: column;
  }
}
/* Requested linked-to box shape */
.linked-pill,
.linked-editor-pill {
  border-radius: 0;
}

@supports not (background: color-mix(in srgb, red 5%, white)) {
  .timeline-card {
    background: rgba(255, 255, 255, 0.96);
  }
}

/* People timeline additions */
.field-pill { font-weight: 700; }


/* Planning Authors fixes */
.required-marker {
  color: #b42318;
  font-weight: 800;
}

.required-note {
  color: #8a231a;
  font-weight: 700;
}

.optional-label {
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.72em;
  font-weight: 500;
}

.decade-label {
  overflow: hidden;
}

.decade-label > span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.timeline-scroller::after {
  content: 'Drag to move · Ctrl/Cmd + wheel to zoom';
  position: fixed;
  right: 14px;
  bottom: 12px;
  z-index: 40;
  padding: 6px 9px;
  border: 1px solid rgba(23, 34, 56, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 0.68rem;
  pointer-events: none;
  backdrop-filter: blur(5px);
}

/* Mobile / iOS entry editor fixes */
.entry-dialog {
  max-height: calc(100dvh - 24px);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.entry-dialog form,
.entry-dialog input,
.entry-dialog select,
.entry-dialog textarea,
.entry-dialog button {
  touch-action: manipulation;
}

.entry-dialog form {
  min-height: 0;
}

@media (max-width: 620px) {
  .entry-dialog {
    width: calc(100vw - 16px);
    max-width: none;
    max-height: calc(100dvh - 16px);
    margin: auto;
  }

  .entry-dialog form {
    padding: 16px;
  }

  .dialog-actions {
    position: sticky;
    bottom: -16px;
    z-index: 5;
    margin: 18px -16px -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(8px);
  }

  .dialog-actions-right {
    margin-left: auto;
  }

  .dialog-actions .button {
    min-height: 44px;
  }

  .entry-dialog input,
  .entry-dialog select,
  .entry-dialog textarea {
    min-height: 44px;
    font-size: 16px;
  }
}

/* Field creatable multi-select */
.field-editor-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 11px;
  border: 1px solid #ccd4df;
  border-radius: 8px;
  background: #fbfcfe;
}

.field-editor-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 28px;
}

.field-editor-pills:empty::before {
  content: 'No fields selected.';
  align-self: center;
  color: var(--muted);
  font-size: 0.75rem;
}

.field-editor-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 5px 5px 5px 9px;
  border: 1px solid #c8d3e2;
  border-radius: 999px;
  background: #edf1f6;
  color: #34445e;
  font-size: 0.76rem;
  font-weight: 700;
}

.field-editor-pill > span {
  overflow-wrap: anywhere;
}

.field-editor-pill button {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #dce3ec;
  color: #4a5568;
  line-height: 1;
}

.combobox-create-option {
  font-weight: 750;
}

.entry-dialog-status {
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px solid #b8c6d8;
  border-radius: 8px;
  background: #f3f7fc;
  color: #243b5a;
  font-size: 0.78rem;
  font-weight: 650;
}

.entry-dialog-status.is-error {
  border-color: #e2aaa5;
  background: #fff3f2;
  color: #8a231a;
}

#saveEntryButton:disabled {
  cursor: wait;
  opacity: 0.65;
}

@media (max-width: 620px) {
  .field-editor-box {
    padding: 9px;
  }

  .combobox-menu {
    max-height: min(220px, 36dvh);
    -webkit-overflow-scrolling: touch;
  }

  .combobox-option,
  .combobox-empty {
    min-height: 44px;
    padding: 11px 10px;
  }

  .combobox-toggle {
    width: 43px;
    height: 42px;
  }

  .entry-dialog-status {
    position: sticky;
    bottom: 57px;
    z-index: 6;
  }
}



/* People entry editor */
.entry-dialog {
  width: min(960px, calc(100vw - 28px));
}

.entry-dialog form {
  padding: 24px;
}

.entry-section-label,
.person-primary-section label > span,
.person-detail-panel label > span,
.person-description-field > span {
  color: #344054;
  font-size: 0.79rem;
  font-weight: 750;
}

.person-primary-section {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.profile-photo-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-photo-dropzone {
  position: relative;
  aspect-ratio: 4 / 5;
  width: 100%;
  overflow: hidden;
  border: 1.5px dashed #b8c3d2;
  border-radius: 12px;
  background: #f7f9fc;
  cursor: pointer;
  outline: none;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

.profile-photo-dropzone:hover,
.profile-photo-dropzone:focus-visible,
.profile-photo-dropzone.is-dragover {
  border-color: #5c7090;
  background: #eef3f8;
  box-shadow: 0 0 0 3px rgba(49, 76, 121, 0.08);
}

.profile-photo-dropzone.is-uploading {
  cursor: wait;
  opacity: 0.72;
}

.profile-photo-dropzone > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-photo-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.profile-photo-placeholder[hidden] {
  display: none;
}

.profile-photo-head,
.profile-photo-body {
  position: absolute;
  display: block;
  background: #c8d1dd;
}

.profile-photo-head {
  top: 24%;
  width: 29%;
  aspect-ratio: 1;
  border-radius: 50%;
}

.profile-photo-body {
  bottom: 17%;
  width: 54%;
  height: 38%;
  border-radius: 50% 50% 18% 18%;
}

.profile-photo-overlay {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #344054;
  text-align: center;
  backdrop-filter: blur(5px);
}

.profile-photo-overlay strong {
  font-size: 0.74rem;
}

.profile-photo-overlay span {
  color: var(--muted);
  font-size: 0.65rem;
}

.profile-photo-dropzone.has-image .profile-photo-overlay {
  opacity: 0;
  transition: opacity 140ms ease;
}

.profile-photo-dropzone.has-image:hover .profile-photo-overlay,
.profile-photo-dropzone.has-image:focus-visible .profile-photo-overlay {
  opacity: 1;
}

.profile-photo-status {
  min-height: 17px;
  color: var(--muted);
  font-size: 0.7rem;
}

.person-core-fields,
.person-detail-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.entry-two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.person-primary-section label,
.person-detail-panel label,
.person-description-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.person-primary-section input,
.person-detail-panel input,
.person-detail-panel select,
.person-description-field textarea {
  width: 100%;
  border: 1px solid #ccd4df;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.person-primary-section input,
.person-detail-panel input,
.person-detail-panel select {
  min-height: 42px;
  padding: 0 11px;
}

.person-detail-panel small {
  color: var(--muted);
  font-size: 0.7rem;
}

.scope-editor {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 2px;
}

.scope-range {
  --scope-position: 0%;
  width: 100%;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: #314c79;
}

.scope-range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background:
    linear-gradient(
      to right,
      #314c79 0,
      #314c79 var(--scope-position),
      #d8dee7 var(--scope-position),
      #d8dee7 100%
    );
}

.scope-range::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -6.5px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #314c79;
  box-shadow: 0 0 0 1px #314c79;
  -webkit-appearance: none;
}

.scope-range::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: #d8dee7;
}

.scope-range::-moz-range-progress {
  height: 5px;
  border-radius: 999px;
  background: #314c79;
}

.scope-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #314c79;
  box-shadow: 0 0 0 1px #314c79;
}

.scope-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.scope-options button {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid #d3dae4;
  border-radius: 7px;
  background: #fff;
  color: #68758a;
  font-size: 0.72rem;
  font-weight: 700;
}

.scope-options button:hover,
.scope-options button.is-active {
  border-color: #8191aa;
  background: #edf2f8;
  color: #243b60;
}

.person-detail-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: visible;
}

.person-detail-panel {
  min-width: 0;
  padding: 20px;
}

.person-detail-panel + .person-detail-panel {
  border-left: 1px solid var(--border);
}

.person-detail-panel h3 {
  margin: 0 0 2px;
  color: #26354c;
  font-size: 0.88rem;
}

.person-detail-panel .field-editor,
.person-detail-panel .linked-editor {
  gap: 7px;
}

.person-detail-panel .field-editor-box,
.person-detail-panel .linked-editor-box {
  padding: 9px;
}

.linked-picker-row {
  display: flex;
  gap: 8px;
}

.person-description-field {
  margin-top: 20px;
}

.person-description-field textarea {
  min-height: 126px;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.45;
}

@media (max-width: 760px) {
  .person-primary-section {
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 16px;
  }

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

  .person-detail-panel + .person-detail-panel {
    border-top: 1px solid var(--border);
    border-left: 0;
  }
}

@media (max-width: 620px) {
  .person-primary-section {
    grid-template-columns: 1fr;
  }

  .profile-photo-field {
    align-items: center;
  }

  .profile-photo-field > .entry-section-label,
  .profile-photo-field > .profile-photo-status {
    width: min(220px, 100%);
  }

  .profile-photo-dropzone {
    width: min(220px, 100%);
  }

  .entry-two-column {
    grid-template-columns: 1fr;
  }

  .person-detail-panel {
    padding: 16px;
  }

  .scope-options button {
    min-height: 42px;
  }
}

/* Shared portal finish */
.site-header {
  background: var(--surface);
  backdrop-filter: none;
}

.filter-button.has-active-filters,
.filter-tag.active {
  border-color: #2e5639;
  background: #e4ebe2;
  color: #24472f;
}

.button-primary,
.status-message {
  background: #2e5639;
}

.button,
.icon-button,
.search-wrap input,
.filter-menu,
.timeline-card,
.entry-dialog,
.filter-dialog,
.form-grid input,
.form-grid select,
.form-grid textarea,
.linked-picker-row select,
.combobox-menu,
.linked-editor-box,
.profile-photo-dropzone,
.person-detail-panel {
  border-radius: 4px;
}

.filter-menu,
.timeline-card,
.timeline-card:hover,
.combobox-menu {
  box-shadow: none;
}

.entry-dialog,
.filter-dialog {
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(20, 30, 20, .16);
}

.entry-dialog::backdrop,
.filter-dialog::backdrop,
.timeline-scroller::after {
  backdrop-filter: none;
}

/* Zones-build visual treatment */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
}

.title-block h1 {
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
}

.title-block p {
  color: var(--muted);
  font-size: 11px;
}

.timeline-axis {
  border-right: 1px solid #aeb7aa;
}

.axis-spacer,
.column-header-viewport {
  border-bottom-color: var(--border);
}

.decade-label,
.pinned-column-header-shell {
  color: var(--text);
}

.column-header p {
  color: #58665d;
}

.timeline-card {
  border: 1px solid #aeb7aa;
  border-left: 4px solid var(--entry-accent, currentColor);
  border-radius: 5px;
  background: color-mix(in srgb, var(--entry-accent, #fffef9) 4%, var(--paper));
  box-shadow: none;
}

.timeline-card:hover {
  border-color: var(--focus);
  border-left-color: var(--entry-accent, currentColor);
  background: #fff9f2;
  box-shadow: none;
}

.card-profile-image {
  border-color: var(--border);
  border-radius: 4px;
  background: #ebe9e2;
}

.edit-entry-button {
  border-color: var(--border);
  border-radius: 5px;
  background: var(--paper);
  color: #4f5e54;
}

.edit-entry-button:hover {
  border-color: var(--green);
  background: #edf3e9;
  color: #28513b;
}

.card-year {
  color: var(--green);
}

.card-authority {
  color: #35483d;
}

.card-description {
  border-color: #dde0d8;
  border-radius: 4px;
  background: #f4f3ee;
  color: #45544a;
}

.tag-pill,
.field-pill {
  background: #e8eee7;
  color: #365644;
}

.topic-list {
  color: #657168;
}

.linked-pill,
.linked-editor-pill,
.field-editor-pill {
  border-color: var(--border);
  background: #f4f3ee;
  color: #45544a;
}

.source-link {
  border-color: var(--border);
  border-radius: 5px;
  background: var(--paper);
  color: var(--green);
}

.source-link:hover {
  border-color: var(--green);
  background: #edf3e9;
}

.entry-dialog,
.filter-dialog {
  border-radius: 6px;
  background: var(--surface);
}

.form-grid label > span,
.field-label,
.entry-section-label,
.person-primary-section label > span,
.person-detail-panel label > span,
.person-description-field > span {
  color: #35483d;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.linked-picker-row select,
.person-primary-section input,
.person-detail-panel input,
.person-detail-panel select,
.person-description-field textarea {
  border-color: var(--border);
  border-radius: 5px;
  background: var(--paper);
}

.combobox-toggle {
  border-left-color: var(--border);
  border-radius: 0 4px 4px 0;
  background: #f7f6f0;
  color: #4f5e54;
}

.combobox-toggle:hover {
  background: #edf3e9;
  color: #28513b;
}

.combobox-menu,
.linked-editor-box,
.field-editor-box {
  border-color: var(--border);
  border-radius: 5px;
  background: var(--paper);
}

.combobox-option:hover,
.combobox-option:focus-visible {
  background: #edf3e9;
}

.profile-photo-dropzone {
  border-color: #aeb7aa;
  border-radius: 5px;
  background: #f4f3ee;
}

.profile-photo-dropzone:hover,
.profile-photo-dropzone:focus-visible,
.profile-photo-dropzone.is-dragover {
  border-color: var(--green);
  background: #edf3e9;
  box-shadow: none;
}

.profile-photo-overlay {
  border-radius: 4px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  color: #35483d;
}

.scope-range {
  accent-color: var(--green);
}

.scope-options button {
  border-color: var(--border);
  border-radius: 5px;
  background: var(--paper);
  color: #58665d;
  font-size: 11px;
  font-weight: 600;
}

.scope-options button:hover,
.scope-options button.is-active {
  border-color: #78917d;
  background: #e8eee7;
  color: #264a37;
}

.person-detail-split {
  border-radius: 5px;
}

.person-detail-panel h3 {
  color: #35483d;
}

.timeline-scroller::after {
  border-color: var(--border);
  border-radius: 5px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
}

/* Header controls aligned with the zones build. */
.site-header .portal-back {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.site-header .portal-back:hover {
  border: 0;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-header .button {
  min-height: 31px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--paper);
  box-shadow: none;
  color: var(--text);
  font-size: 11px;
  font-weight: 400;
}

.site-header .button:hover {
  border-color: var(--green);
  background: var(--paper);
}

.site-header .button-primary {
  border-color: var(--border);
  background: var(--paper);
  color: var(--text);
}

.site-header .filter-button.has-active-filters {
  border-color: #78917d;
  background: #e8eee7;
  color: #264a37;
}

.site-header .filter-hamburger {
  color: #4f5e54;
  font-size: 13px;
}

.site-header .search-wrap input {
  height: 31px;
  padding: 5px 32px 5px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--paper);
  color: var(--text);
  font-size: 11px;
}

.site-header .search-wrap input:hover,
.site-header .search-wrap input:focus {
  border-color: var(--green);
}

.site-header .search-wrap span {
  right: 10px;
  color: #657168;
  font-size: 13px;
}

@media (max-width: 900px) {
  .site-header .search-wrap input,
  .site-header .header-actions .button {
    height: 31px;
    min-height: 31px;
    font-size: 11px;
  }
}
