@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: 25%;
  --news-panel-width:
    calc((100vw - var(--axis-width)) / 5);
  --axis-width: 104px;
  --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;

  --policy-strong: #35634b;
  --expression-strong: #9b6240;
  --application-strong: #4e6c75;
  --evaluation-strong: #66765f;
  --news-strong: #704b50;
  --news-background: #dfddd5;
  --news-header-fill: #d2d0c7;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    'Frutiger',
    Arial,
    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: 2px solid var(--focus);
  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 {
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}

.title-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.title-copy {
  min-width: 0;
}

.back-button {
  flex: 0 0 auto;
  min-height: 31px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--paper);
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}

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

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

.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: #78917d;
  background: #e8eee7;
  color: #264a37;
}

.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: 6px;
  background: var(--paper);
  box-shadow: 0 10px 28px #26382c1f;
}

.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: #edf3e9;
}

.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: 31px;
  padding: 0 38px 0 14px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--paper);
  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: 5px;
}

.button {
  min-height: 31px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
}

.button-primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

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

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

.button-primary:hover {
  border-color: #294f3c;
  background: #294f3c;
}

.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 {
  position: relative;
  height: calc(100vh - var(--header-height));
  display: grid;
  grid-template-columns:
    var(--axis-width)
    minmax(0, 1fr)
    var(--news-panel-width);
  overflow: hidden;
  background: var(--bg);
}

.timeline-axis {
  position: relative;
  z-index: 50;
  min-width: 0;
  overflow: hidden;
  background: var(--axis-fill);
  border-right: 1px solid #aeb7aa;
  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 var(--border);
}

.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: var(--text);
  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);
}

/* News and Events remains fixed on the right while the other columns pan. */

.news-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  background: var(--news-background);
  border-left: 3px solid #68786d;
  box-shadow: -8px 0 0 #ebe9e2;
}

.news-viewport {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  overscroll-behavior: none;
  background: var(--news-background);
}

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

.news-track .timeline-column {
  background: var(--news-background);
  border-right: 0;
}

.news-track .decade-cell {
  background: var(--news-background);
}

.news-panel-header {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 55;
  background: var(--news-header-fill);
  color: var(--news-strong);
  border-bottom-color: #aaa99f;
  user-select: none;
}

/* 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 var(--border);
  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: var(--text);
  background: var(--header-fill);
  border-right: 1px solid #c4c1ba;
}

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

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

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

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

.pinned-column-header-shell[
  data-column-key='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: #58665d;
  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(14 * 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;
  overflow: hidden;
  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));
  color: var(--text);
  box-shadow: none;
  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 {
  border-color: var(--focus);
  background: #fff9f2;
  box-shadow: none;
}

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

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

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

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

.timeline-column[
  data-column-key='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;
  padding-right: 36px;
}

.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 {
  font-size:
    calc(
      0.98rem *
      var(--timeline-text-scale)
    );
  line-height: 1.3;
}

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

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

.card-year {
  display: block;
  margin-top: 5px;
  color: var(--green);
  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: #35483d;
  font-weight: 750;
}

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

.card-description {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid #dde0d8;
  border-radius: 4px;
  background: #f4f3ee;
  color: #45544a;
  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;
}

.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: #e8eee7;
  color: #365644;
}

.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 var(--border);
  background: #f4f3ee;
  color: #45544a;
}

.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 var(--border);
  border-radius: 5px;
  background: var(--paper);
  color: var(--green);
  font-size:
    calc(
      0.72rem *
      var(--timeline-text-scale)
    );
  font-weight: 750;
  cursor: pointer;
}

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

/* Focus and relationship highlighting */

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

:is(.timeline-track, .news-track).has-focused-entry
  .timeline-card.is-primary,
:is(.timeline-track, .news-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);
}

:is(.timeline-track, .news-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, opening beside the card without changing its height.
 */

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 {
  overflow: visible;
}

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: absolute;
  top: 0;
  left: calc(100% + 20px);
  z-index: 30;
  display: block;
  width: calc(var(--column-width) * 0.9);
  max-width: none;
  margin: 0;
  padding: 12px;
  border:
    1px solid
    rgba(126, 139, 158, 0.3);
  border-radius: 8px;
  background: #fff;
  box-shadow:
    0 10px 28px
    rgba(18, 31, 53, 0.16);
}

html[
  data-timeline-descriptions='collapsed'
] :is(
  .timeline-column[data-column-key='evaluation'],
  .timeline-column[data-column-key='news']
) .timeline-card:hover
  .card-description,
html[
  data-timeline-descriptions='collapsed'
] :is(
  .timeline-column[data-column-key='evaluation'],
  .timeline-column[data-column-key='news']
) .timeline-card:focus-within
  .card-description,
html[
  data-timeline-descriptions='collapsed'
] :is(
  .timeline-column[data-column-key='evaluation'],
  .timeline-column[data-column-key='news']
) .timeline-card.is-primary
  .card-description {
  right: calc(100% + 20px);
  left: auto;
}

html[
  data-timeline-descriptions='collapsed'
] :is(.timeline-track, .news-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;
}

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

.linked-bus-line,
.linked-bus-rail,
.linked-bus-branch {
  fill: none;
  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)
    );
}

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

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

.linked-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: 6px;
  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: #35483d;
  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 var(--border);
  border-radius: 5px;
  background: var(--paper);
  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);
  }
}

/* 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 {
  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 {
  backdrop-filter: none;
}

/* 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;
  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;
  }
}
