/* Narrative Chronicle — an extensible time-river workspace. */

.workspace-lenses {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}

.workspace-lenses::-webkit-scrollbar {
  display: none;
}

.timeline-workspace {
  position: relative;
  background:
    radial-gradient(circle at 12% 8%, var(--accent-soft), transparent 28%),
    linear-gradient(180deg, var(--surface-base), var(--surface-panel));
}

.timeline-workspace::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--border-subtle) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
  background-size: 34px 34px;
  content: "";
  opacity: 0.18;
  mask-image: linear-gradient(to bottom, black, transparent 42%);
}

.timeline-module-header,
.timeline-metrics,
.timeline-toolbar,
.timeline-river-shell {
  position: relative;
  z-index: 1;
}

.timeline-primary-action svg,
.timeline-icon-button svg,
.timeline-input-shell svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.timeline-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 1240px;
  margin: 0 auto 14px;
  padding: 0;
  gap: 10px;
}

.timeline-metric {
  position: relative;
  min-width: 0;
  min-height: 116px;
  padding: 18px 20px;
  overflow: hidden;
  color: var(--fg-secondary);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: 15px;
  box-shadow: 0 10px 26px var(--shadow-color);
}

.timeline-metric::after {
  position: absolute;
  right: -26px;
  bottom: -44px;
  width: 112px;
  height: 112px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-strong);
  border-radius: 50%;
  content: "";
}

.timeline-metric dt {
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.timeline-metric dd {
  position: relative;
  z-index: 1;
  margin: 4px 0 0;
  color: var(--fg-primary);
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.timeline-metric small {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 8px;
  color: var(--fg-muted);
  font-size: 11px;
}

.timeline-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(140px, 190px) minmax(140px, 190px) auto auto;
  align-items: end;
  max-width: 1240px;
  min-height: 78px;
  margin: 0 auto 18px;
  padding: 10px;
  color: var(--fg-secondary);
  background: var(--surface-shell);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  gap: 8px;
}

.timeline-filter {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.timeline-filter > span:first-child {
  padding-inline: 3px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.timeline-filter input,
.timeline-filter select {
  width: 100%;
  min-width: 0;
  height: 44px;
  color: var(--fg-primary);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: 9px;
}

.timeline-input-shell {
  position: relative;
  display: block;
}

.timeline-input-shell svg {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 13px;
  color: var(--fg-muted);
  pointer-events: none;
  transform: translateY(-50%);
}

.timeline-input-shell input {
  padding-left: 40px;
}

.timeline-input-shell:focus-within svg {
  color: var(--accent-text);
}

.timeline-primary-button,
.timeline-secondary-button,
.timeline-danger-button,
.timeline-icon-button,
.timeline-order-button,
.timeline-delete-card,
.timeline-person-chip {
  min-height: 44px;
  color: var(--fg-secondary);
  background: var(--surface-control);
  border: 1px solid var(--border-default);
  border-radius: 9px;
  transition:
    color 150ms var(--ease-workspace),
    background-color 150ms var(--ease-workspace),
    border-color 150ms var(--ease-workspace),
    box-shadow 150ms var(--ease-workspace),
    transform 90ms var(--ease-workspace),
    opacity 150ms var(--ease-workspace);
}

.timeline-primary-button,
.timeline-primary-action {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--button-shadow);
}

.timeline-primary-button {
  padding: 0 18px;
  font-weight: 800;
}

.timeline-primary-button:hover:not(:disabled),
.timeline-primary-action:hover:not(:disabled) {
  color: var(--on-accent);
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.timeline-secondary-button {
  padding: 0 14px;
  font-weight: 700;
}

.timeline-secondary-button:hover:not(:disabled),
.timeline-order-button:hover:not(:disabled),
.timeline-icon-button:hover:not(:disabled),
.timeline-person-chip:hover:not(:disabled) {
  color: var(--fg-primary);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.timeline-danger-button,
.timeline-delete-card {
  padding: 0 14px;
  color: var(--danger);
  font-weight: 700;
}

.timeline-danger-button:hover:not(:disabled),
.timeline-delete-card:hover:not(:disabled) {
  color: var(--danger-hover);
  background: var(--danger-soft);
  border-color: var(--danger);
}

.timeline-danger-button.is-confirming,
.timeline-delete-card.is-confirming {
  color: var(--on-accent);
  background: var(--danger);
  border-color: var(--danger);
}

.timeline-primary-button:active:not(:disabled),
.timeline-secondary-button:active:not(:disabled),
.timeline-danger-button:active:not(:disabled),
.timeline-icon-button:active:not(:disabled),
.timeline-order-button:active:not(:disabled),
.timeline-delete-card:active:not(:disabled),
.timeline-person-chip:active:not(:disabled),
.timeline-primary-action:active:not(:disabled) {
  transform: scale(0.96);
}

.timeline-icon-button {
  display: inline-grid;
  width: 44px;
  min-width: 44px;
  padding: 0;
  place-items: center;
}

.timeline-result-count {
  align-self: center;
  padding: 0 8px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  white-space: nowrap;
}

.timeline-river-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 0 80px;
}

.timeline-river {
  position: relative;
  min-height: 280px;
  padding: 18px 0 42px;
}

.timeline-river::before {
  position: absolute;
  z-index: 0;
  top: 0;
  bottom: 12px;
  left: 50%;
  width: 12px;
  background:
    linear-gradient(90deg, transparent, var(--accent-soft-strong) 28%, var(--accent) 50%, var(--accent-soft-strong) 72%, transparent),
    var(--surface-panel);
  border-inline: 1px solid var(--border-subtle);
  border-radius: 999px;
  box-shadow: 0 0 28px var(--accent-soft);
  content: "";
  transform: translateX(-50%);
}

.timeline-sequence {
  position: relative;
  z-index: 1;
  margin: 0 0 26px;
}

.timeline-sequence-header {
  position: relative;
  z-index: 2;
  display: grid;
  width: max-content;
  min-width: 154px;
  min-height: 66px;
  margin: 0 auto 16px;
  padding: 10px 24px;
  place-items: center;
  color: var(--fg-secondary);
  background: var(--surface-shell);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: 0 9px 24px var(--shadow-color);
}

.timeline-sequence-header h3 {
  margin: 0;
  color: var(--fg-primary);
  font-family: var(--font-display);
  font-size: 15px;
}

.timeline-sequence-header > span:last-child {
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.timeline-sequence-knot {
  position: absolute;
  top: 50%;
  left: -7px;
  width: 13px;
  height: 13px;
  background: var(--accent);
  border: 3px solid var(--surface-shell);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--accent);
  transform: translateY(-50%);
}

.timeline-sequence-events {
  display: grid;
  gap: 18px;
}

.timeline-flow-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
}

.timeline-event-card {
  position: relative;
  min-width: 0;
  padding: 18px;
  color: var(--fg-secondary);
  background:
    linear-gradient(145deg, var(--surface-raised), var(--surface-panel));
  border: 1px solid var(--border-default);
  border-radius: 16px;
  box-shadow: 0 14px 34px var(--shadow-color);
  transition:
    border-color 170ms var(--ease-workspace),
    box-shadow 170ms var(--ease-workspace),
    transform 170ms var(--ease-workspace);
}

.timeline-event-card:hover,
.timeline-event-card:focus-visible {
  border-color: var(--border-strong);
  box-shadow: 0 18px 42px var(--shadow-color), 0 0 0 1px var(--accent-soft);
  transform: translateY(-2px);
}

.timeline-bank-left .timeline-event-card {
  grid-column: 1;
}

.timeline-bank-right .timeline-event-card {
  grid-column: 3;
}

.timeline-flow-marker {
  position: relative;
  grid-column: 2;
  grid-row: 1;
  display: grid;
  width: 100%;
  height: 44px;
  place-items: center;
}

.timeline-flow-marker::before {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 1px;
  background: var(--accent-soft-strong);
  content: "";
}

.timeline-flow-marker i {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  background: var(--surface-shell);
  border: 4px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 6px var(--accent-soft);
}

.timeline-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  min-width: 0;
  gap: 12px;
}

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

.timeline-card-index {
  display: block;
  margin-bottom: 5px;
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.timeline-card-header h3 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--fg-primary);
  font-family: var(--font-display);
  font-size: clamp(18px, 1.7vw, 23px);
  line-height: 1.25;
}

.timeline-edit-button {
  flex: 0 0 44px;
}

.timeline-card-meta,
.timeline-card-tags,
.timeline-card-participants,
.timeline-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.timeline-card-meta {
  margin-top: 13px;
}

.timeline-time-chip,
.timeline-stage-chip,
.timeline-card-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  overflow-wrap: anywhere;
  color: var(--fg-secondary);
  background: var(--surface-control);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 10px;
}

.timeline-stage-chip {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-soft-strong);
}

.timeline-card-summary {
  margin: 14px 0;
  overflow-wrap: anywhere;
  color: var(--fg-secondary);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.timeline-card-muted {
  color: var(--fg-muted);
  font-style: italic;
}

.timeline-card-tags {
  margin: 0 0 13px;
}

.timeline-card-tags span {
  min-height: 25px;
  color: var(--fg-muted);
  background: transparent;
}

.timeline-card-participants {
  min-height: 38px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.timeline-person-chip {
  display: inline-flex;
  min-height: 36px;
  padding: 3px 10px 3px 4px;
  align-items: center;
  font-size: 11px;
  gap: 7px;
}

.timeline-person-chip > span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 7px;
  font-family: var(--font-display);
  font-weight: 800;
}

.timeline-card-actions {
  margin: 14px -4px -4px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.timeline-order-button,
.timeline-delete-card {
  min-height: 38px;
  padding: 0 10px;
  font-size: 10px;
  font-weight: 700;
}

.timeline-delete-card {
  margin-left: auto;
}

.timeline-empty-state {
  position: relative;
  z-index: 2;
  display: grid;
  max-width: 560px;
  min-height: 310px;
  margin: 12px auto;
  padding: 40px;
  place-items: center;
  align-content: center;
  text-align: center;
  color: var(--fg-secondary);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: 22px;
  box-shadow: var(--shadow-md);
}

.timeline-empty-state.compact {
  min-height: 250px;
}

.timeline-empty-symbol {
  display: grid;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  place-items: center;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-strong);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 800;
}

.timeline-empty-state h3 {
  margin: 0;
  color: var(--fg-primary);
  font-family: var(--font-display);
  font-size: 24px;
}

.timeline-empty-state p {
  max-width: 430px;
  margin: 9px 0 20px;
  color: var(--fg-muted);
  line-height: 1.7;
}

/* Event editor */

.timeline-modal-backdrop {
  position: fixed;
  z-index: 1100;
  inset: 0;
  display: grid;
  padding: 22px;
  overflow: auto;
  place-items: center;
  background: var(--backdrop);
  overscroll-behavior: contain;
}

.timeline-modal {
  width: min(900px, 100%);
  max-height: calc(100dvh - 44px);
  overflow: hidden;
  color: var(--fg-primary);
  background: var(--surface-shell);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: var(--panel-shadow);
}

.timeline-modal form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100dvh - 46px);
}

.timeline-modal-header,
.timeline-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.timeline-modal-header {
  min-height: 96px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
}

.timeline-modal-header h2 {
  margin: 4px 0 3px;
  font-family: var(--font-display);
  font-size: 25px;
}

.timeline-modal-header p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 12px;
}

.timeline-modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(240px, 0.65fr);
  min-height: 0;
  padding: 22px;
  overflow: auto;
  scrollbar-color: var(--surface-hover) transparent;
  scrollbar-width: thin;
  gap: 20px;
}

.timeline-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  min-width: 0;
  gap: 15px 12px;
}

.timeline-field {
  display: grid;
  align-content: start;
  min-width: 0;
  gap: 6px;
}

.timeline-field-wide {
  grid-column: 1 / -1;
}

.timeline-field > span,
.timeline-participant-fieldset legend {
  color: var(--fg-secondary);
  font-size: 11px;
  font-weight: 800;
}

.timeline-field em {
  margin-left: 4px;
  color: var(--danger);
  font-size: 9px;
  font-style: normal;
}

.timeline-field input,
.timeline-field textarea {
  width: 100%;
  min-width: 0;
  color: var(--fg-primary);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: 9px;
}

.timeline-field input {
  height: 44px;
}

.timeline-field textarea {
  min-height: 128px;
  padding: 11px 12px;
  resize: vertical;
}

.timeline-field small,
.timeline-participant-fieldset > p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 10px;
  line-height: 1.45;
}

.timeline-field-error {
  display: block;
  min-height: 15px;
  margin: -2px 0 0;
  color: var(--danger) !important;
  font-weight: 700;
}

.timeline-field input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.timeline-participant-fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px;
  background: var(--surface-panel);
  border: 1px solid var(--border-default);
  border-radius: 14px;
}

.timeline-participant-fieldset legend {
  padding: 0 5px;
  color: var(--fg-primary);
  font-family: var(--font-display);
  font-size: 15px;
}

.timeline-participant-fieldset legend span {
  margin-left: 5px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.timeline-participant-list {
  display: grid;
  max-height: 360px;
  margin-top: 11px;
  overflow: auto;
  scrollbar-color: var(--surface-hover) transparent;
  scrollbar-width: thin;
  gap: 6px;
}

.timeline-participant-option {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 22px;
  align-items: center;
  min-height: 52px;
  padding: 6px 8px;
  color: var(--fg-secondary);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  cursor: pointer;
  gap: 8px;
  transition:
    color 150ms var(--ease-workspace),
    background-color 150ms var(--ease-workspace),
    border-color 150ms var(--ease-workspace),
    box-shadow 150ms var(--ease-workspace),
    transform 90ms var(--ease-workspace);
}

.timeline-participant-option:hover {
  color: var(--fg-primary);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.timeline-participant-option:active {
  transform: scale(0.985);
}

.timeline-participant-option:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.timeline-participant-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.timeline-participant-option:has(input:checked) {
  color: var(--fg-primary);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.timeline-participant-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 9px;
  font-family: var(--font-display);
  font-weight: 800;
}

.timeline-participant-option strong,
.timeline-participant-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-participant-option strong {
  color: inherit;
  font-size: 12px;
}

.timeline-participant-option small {
  margin-top: 2px;
  color: var(--fg-muted);
  font-size: 9px;
}

.timeline-participant-option i {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}

.timeline-participant-option input:checked ~ i {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.timeline-participant-option input:checked ~ i::before {
  content: "✓";
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.timeline-no-participants {
  margin: 0;
  padding: 18px;
  color: var(--fg-muted);
  text-align: center;
  line-height: 1.6;
}

.timeline-modal-footer {
  min-height: 76px;
  padding: 14px 22px;
  background: var(--surface-panel);
  border-top: 1px solid var(--border-subtle);
}

.timeline-modal-spacer {
  flex: 1 1 auto;
}

.timeline-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;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* All eight skins inherit semantic color tokens; these details change material. */

:root[data-theme="midnight"] .timeline-event-card,
:root[data-theme="umber"] .timeline-event-card,
:root[data-theme="moss"] .timeline-event-card {
  box-shadow: 0 16px 38px var(--shadow-color), inset 0 1px 0 var(--border-subtle);
}

:root[data-theme="paper"] .timeline-event-card,
:root[data-theme="paper"] .timeline-metric {
  background: var(--surface-raised);
  box-shadow: 0 8px 0 var(--border-subtle);
}

:root[data-theme="ink"] .timeline-river::before {
  width: 8px;
  background: linear-gradient(180deg, var(--fg-primary), var(--accent), var(--fg-primary));
  opacity: 0.72;
}

:root[data-theme="ink"] .timeline-event-card {
  border-width: 1px 1px 2px 4px;
  border-radius: 4px 14px 5px 12px;
  box-shadow: 5px 8px 0 var(--border-subtle);
}

:root[data-theme="ink"] .timeline-sequence-header {
  border-radius: 3px;
}

:root[data-theme="vermilion"] .timeline-event-card,
:root[data-theme="vermilion"] .timeline-metric,
:root[data-theme="vermilion"] .timeline-toolbar,
:root[data-theme="vermilion"] .timeline-modal,
:root[data-theme="vermilion"] .timeline-participant-fieldset {
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px var(--accent-soft), 4px 5px 0 var(--shadow-color);
}

:root[data-theme="vermilion"] .timeline-flow-marker i,
:root[data-theme="vermilion"] .timeline-sequence-knot {
  border-radius: 2px;
  transform: rotate(45deg);
}

:root[data-theme="celadon"] .timeline-event-card,
:root[data-theme="celadon"] .timeline-metric,
:root[data-theme="celadon"] .timeline-toolbar,
:root[data-theme="celadon"] .timeline-modal {
  border-radius: 24px;
  box-shadow: inset 0 0 0 1px var(--surface-raised), 0 14px 34px var(--shadow-color);
}

:root[data-theme="celadon"] .timeline-river::before {
  width: 18px;
  background: linear-gradient(90deg, var(--accent-soft), var(--surface-control), var(--accent-soft));
}

:root[data-theme="dunhuang"] .timeline-event-card,
:root[data-theme="dunhuang"] .timeline-metric,
:root[data-theme="dunhuang"] .timeline-toolbar,
:root[data-theme="dunhuang"] .timeline-modal {
  border-width: 2px;
  border-radius: 13px 3px 13px 3px;
  box-shadow: inset 0 0 0 2px var(--accent-soft), 5px 6px 0 var(--shadow-color);
}

:root[data-theme="dunhuang"] .timeline-sequence-header {
  border-radius: 10px 2px 10px 2px;
}

@media (max-width: 1180px) {
  .timeline-toolbar {
    grid-template-columns: minmax(220px, 1fr) minmax(130px, 170px) minmax(130px, 170px) auto;
  }

  .timeline-result-count {
    grid-column: 1 / -1;
    padding-block: 2px;
  }
}

@media (max-width: 900px) {
  .timeline-flow-row {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .timeline-river::before {
    left: 27px;
    transform: none;
  }

  .timeline-bank-left .timeline-event-card,
  .timeline-bank-right .timeline-event-card {
    grid-column: 2;
  }

  .timeline-flow-marker {
    grid-column: 1;
  }

  .timeline-sequence-header {
    margin-left: 0;
  }

  .timeline-sequence-knot {
    right: -7px;
    left: auto;
  }

  .timeline-modal-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline-participant-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 250px;
  }
}

@media (max-width: 720px) {
  .workspace-lenses {
    justify-content: flex-start;
  }

  .workspace-lens {
    flex: 0 0 84px;
    min-width: 84px;
  }

  .timeline-metrics {
    gap: 6px;
  }

  .timeline-metric {
    min-height: 96px;
    padding: 13px;
  }

  .timeline-metric dd {
    font-size: 28px;
  }

  .timeline-metric small {
    font-size: 9px;
  }

  .timeline-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(118px, 0.45fr);
  }

  .timeline-filter-search {
    grid-column: 1 / -1;
  }

  .timeline-toolbar > .timeline-secondary-button {
    grid-column: 1 / -1;
  }

  .timeline-result-count {
    grid-column: 1 / -1;
  }

  .timeline-river-shell {
    padding-bottom: 36px;
  }

  .timeline-event-card {
    padding: 14px;
  }

  .timeline-modal-backdrop {
    padding: 8px;
  }

  .timeline-modal,
  .timeline-modal form {
    max-height: calc(100dvh - 16px);
  }

  .timeline-modal-header,
  .timeline-modal-body,
  .timeline-modal-footer {
    padding-inline: 14px;
  }

  .timeline-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline-field-wide {
    grid-column: 1;
  }

  .timeline-participant-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 460px) {
  .workspace-lens {
    flex-basis: 76px;
    min-width: 76px;
    padding-inline: 7px;
  }

  .timeline-module-header .module-header-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .timeline-metric {
    min-height: 88px;
    padding: 10px 8px;
    border-radius: 10px;
  }

  .timeline-metric dt {
    font-size: 8px;
    letter-spacing: 0.03em;
  }

  .timeline-metric dd {
    font-size: 24px;
  }

  .timeline-metric small,
  .timeline-metric::after {
    display: none;
  }

  .timeline-toolbar {
    grid-template-columns: minmax(0, 1fr);
    padding: 8px;
  }

  .timeline-filter-search,
  .timeline-toolbar > .timeline-secondary-button,
  .timeline-result-count {
    grid-column: 1;
  }

  .timeline-flow-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .timeline-river::before {
    left: 19px;
    width: 8px;
  }

  .timeline-sequence-header {
    min-width: 132px;
    min-height: 58px;
    padding: 8px 16px;
  }

  .timeline-flow-marker {
    width: 38px;
  }

  .timeline-card-header h3 {
    font-size: 18px;
  }

  .timeline-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .timeline-delete-card {
    grid-column: 1 / -1;
    margin-left: 0;
  }

  .timeline-empty-state {
    min-height: 260px;
    padding: 24px 17px;
  }

  .timeline-modal-header {
    min-height: 86px;
  }

  .timeline-modal-header p {
    display: none;
  }

  .timeline-modal-body {
    padding-block: 14px;
  }

  .timeline-modal-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 72px;
    gap: 8px;
  }

  .timeline-modal-spacer {
    display: none;
  }

  .timeline-danger-button:not(.hidden) {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-height: 620px) {
  .timeline-modal-backdrop {
    align-items: start;
    padding-block: 7px;
  }

  .timeline-modal,
  .timeline-modal form {
    max-height: calc(100dvh - 14px);
  }

  .timeline-modal-header {
    min-height: 70px;
    padding-block: 10px;
  }

  .timeline-modal-header p,
  .timeline-modal-header .section-kicker {
    display: none;
  }

  .timeline-modal-footer {
    min-height: 62px;
    padding-block: 8px;
  }
}

@media (pointer: coarse) {
  .timeline-primary-button,
  .timeline-secondary-button,
  .timeline-danger-button,
  .timeline-icon-button,
  .timeline-order-button,
  .timeline-delete-card,
  .timeline-person-chip,
  .timeline-participant-option,
  .timeline-filter input,
  .timeline-filter select {
    min-height: 44px;
  }

  .timeline-icon-button {
    width: 44px;
    min-width: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .timeline-event-card,
  .timeline-primary-button,
  .timeline-secondary-button,
  .timeline-danger-button,
  .timeline-icon-button,
  .timeline-order-button,
  .timeline-delete-card,
  .timeline-person-chip,
  .timeline-participant-option {
    transition-duration: 0.01ms;
  }

  .timeline-event-card:hover,
  .timeline-event-card:focus-visible {
    transform: none;
  }
}
