:root,
[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-2: #1f2430;
  --border: #2a3142;
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  --card-shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.35);
  --card-shadow-selected: 0 0 0 3px rgba(255, 255, 255, 0.25), 0 6px 20px rgba(0, 0, 0, 0.35);
  --step-selected-ring: 0 0 0 3px rgba(255, 255, 255, 0.35);
  --track-fill-opacity: 0.65;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --tooltip-bg: rgba(18, 20, 28, 0.94);
  --tooltip-border: rgba(255, 255, 255, 0.1);
  --tooltip-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --track-hover: rgba(99, 102, 241, 0.04);
  --modal-backdrop: rgba(0, 0, 0, 0.55);
  --accent-soft: rgba(99, 102, 241, 0.18);
  --share-active-text: #a5b4fc;
  --share-active-border: rgba(129, 140, 248, 0.65);
  --share-active-bg: rgba(99, 102, 241, 0.18);
  --date-pill-bg: rgba(99, 102, 241, 0.15);
  --date-pill-text: #a5b4fc;
  --in-progress-text: #111;
  --track-bg: #1f2430;
}

[data-theme="light"] {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --border: #d5dbe8;
  --text: #1a2030;
  --text-muted: #5c667a;
  --primary: #4f46e5;
  --primary-hover: #6366f1;
  --success: #059669;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.1);
  --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.05);
  --card-shadow-hover: 0 2px 6px rgba(15, 23, 42, 0.08), 0 8px 18px rgba(15, 23, 42, 0.07);
  --card-shadow-selected: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent), 0 4px 14px rgba(15, 23, 42, 0.08);
  --step-selected-ring: 0 0 0 3px color-mix(in srgb, var(--road-color, var(--primary)) 28%, transparent);
  --track-fill-opacity: 0.88;
  --tooltip-bg: rgba(255, 255, 255, 0.97);
  --tooltip-border: rgba(15, 23, 42, 0.1);
  --tooltip-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
  --track-hover: rgba(79, 70, 229, 0.06);
  --modal-backdrop: rgba(15, 23, 42, 0.35);
  --accent-soft: rgba(79, 70, 229, 0.1);
  --share-active-text: #4338ca;
  --share-active-border: rgba(79, 70, 229, 0.45);
  --share-active-bg: rgba(79, 70, 229, 0.1);
  --date-pill-bg: rgba(79, 70, 229, 0.1);
  --date-pill-text: #4338ca;
  --in-progress-text: #1a2030;
  --track-bg: #b4becf;
}

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

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

[data-theme="light"] .header-brand {
  color: var(--text);
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon {
  width: 2.35rem;
  height: 2.35rem;
  display: block;
}

.brand-separator {
  width: 2px;
  height: 2.1rem;
  background: currentColor;
  opacity: 0.9;
  flex-shrink: 0;
  border-radius: 1px;
}

.brand-name {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1;
  text-transform: lowercase;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.lang-select-wrap {
  display: inline-flex;
  align-items: center;
}

.lang-select {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  height: 2.25rem;
  line-height: 1;
  padding: 0 1.75rem 0 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b95a8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 0.55rem center;
  color: var(--text);
  cursor: pointer;
  appearance: none;
}

.lang-select:hover {
  border-color: var(--text-muted);
}

.lang-select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

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

/* Buttons */
.btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

#btn-share.btn-share--active,
.btn-share.btn-share--active {
  color: var(--share-active-text);
  border-color: var(--share-active-border);
  background: var(--share-active-bg);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 25%, transparent), 0 0 12px var(--accent-soft);
}

#btn-share.btn-share--active:hover,
.btn-share.btn-share--active:hover {
  color: var(--primary-hover);
  border-color: var(--primary-hover);
  background: color-mix(in srgb, var(--primary) 20%, transparent);
}

#btn-share.btn-share--copied,
.btn-share.btn-share--copied {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.55);
  background: rgba(34, 197, 94, 0.12);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
}

/* Main layout */
.main {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.markup-panel {
  --markup-panel-width: min(360px, 38vw);
  width: var(--markup-panel-width);
  max-width: 50vw;
  min-width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.main.markup-panel--collapsed .markup-panel {
  display: none;
}

.markup-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.45rem 0.55rem 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.markup-panel__collapse,
.markup-panel-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.markup-panel__collapse:hover,
.markup-panel-toggle:hover {
  border-color: var(--primary);
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface-2));
}

.markup-panel__collapse:focus-visible,
.markup-panel-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.markup-panel__panes {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.markup-panel__pane {
  min-height: 80px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.markup-panel__pane--friendly {
  flex: 1 1 auto;
}

.markup-panel__title {
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex: 1;
  min-width: 0;
}

.markup-panel__notation {
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.markup-panel__notation:hover {
  text-decoration: underline;
}

.markup-panel__notation:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.markup-panel__error {
  flex-shrink: 0;
  margin: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #991b1b;
  background: color-mix(in srgb, #ef4444 18%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, #ef4444 35%, var(--border));
}

[data-theme="dark"] .markup-panel__error {
  color: #fecaca;
}

.markup-panel__error.hidden {
  display: none;
}

.markup-panel__error-message {
  font-weight: 500;
}

.markup-panel__error-hints {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  color: color-mix(in srgb, currentColor 88%, var(--text-muted));
}

.markup-panel__error-hints li + li {
  margin-top: 0.2rem;
}

.markup-panel__width-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
  background: transparent;
  transition: background 0.15s ease;
}

.markup-panel__width-resizer:hover,
.markup-panel__width-resizer.is-dragging {
  background: color-mix(in srgb, var(--primary) 35%, transparent);
}

.markup-panel__editor-host {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.markup-editor {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
  background: var(--bg);
}

.markup-editor__gutter {
  flex-shrink: 0;
  width: 2.65rem;
  overflow: hidden;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--surface-2) 88%, var(--bg));
  border-right: 1px solid var(--border);
  user-select: none;
}

.markup-editor__gutter-inner {
  position: relative;
  padding-top: 0.65rem;
  will-change: transform;
}

.markup-editor__gutter-line {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  box-sizing: border-box;
  text-align: right;
  padding: 0 0.45rem 0 0.25rem;
  color: color-mix(in srgb, var(--text-muted) 88%, transparent);
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

.markup-editor__gutter-line.is-active {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface-2));
  color: var(--text);
}

.markup-editor__gutter-line.is-error::before {
  content: '';
  position: absolute;
  left: 0.2rem;
  top: 0.45em;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--danger, #dc2626);
}

.markup-editor__gutter-line.is-error {
  position: relative;
  background: color-mix(in srgb, var(--danger, #dc2626) 12%, var(--surface-2));
  color: var(--text);
}

.markup-editor__main {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.markup-editor__backdrop {
  position: absolute;
  inset: 0;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
  box-sizing: border-box;
  z-index: 0;
  background: transparent;
  border: none;
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  tab-size: 2;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.markup-editor__backdrop code {
  display: block;
  padding: 0.65rem 0.75rem;
  box-sizing: border-box;
  font: inherit;
  white-space: inherit;
  word-break: inherit;
  overflow-wrap: inherit;
  will-change: transform;
}

.markup-editor__row {
  position: relative;
  display: block;
  overflow: hidden;
  box-sizing: border-box;
  background: transparent;
}

.markup-editor__row-mirror {
  visibility: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font: inherit;
}

.markup-editor__row-highlight {
  position: absolute;
  inset: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  pointer-events: none;
  font: inherit;
}

.markup-editor__row.is-active {
  background: color-mix(in srgb, var(--primary) 10%, var(--bg));
}

.markup-editor__row.is-active .markup-editor__row-highlight {
  background: color-mix(in srgb, var(--primary) 10%, var(--bg));
}

.markup-editor__row.is-error {
  background: color-mix(in srgb, var(--danger, #dc2626) 10%, var(--bg));
}

.markup-editor__row.is-error .markup-editor__row-highlight {
  background: color-mix(in srgb, var(--danger, #dc2626) 10%, var(--bg));
}

.markup-editor__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: none;
  resize: none;
  z-index: 1;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 0.65rem 0.75rem;
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow: auto;
  tab-size: 2;
  -webkit-font-smoothing: antialiased;
}

.markup-editor__input::selection {
  background: color-mix(in srgb, var(--primary) 35%, transparent);
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.markup-editor__input:focus {
  outline: none;
}

.markup-editor__input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
  -webkit-text-fill-color: var(--text-muted);
}

.markup-editor .mk-kw {
  color: #2563eb;
  font-weight: inherit;
}

.markup-editor .mk-color {
  color: #7c3aed;
}

.markup-editor .mk-pipe {
  color: #16a34a;
}

[data-theme="dark"] .markup-editor .mk-kw {
  color: #60a5fa;
}

[data-theme="dark"] .markup-editor .mk-pipe {
  color: #4ade80;
}

[data-theme="dark"] .markup-editor .mk-color {
  color: #c4b5fd;
}

.markup-panel-toggle--expand[hidden] {
  display: none !important;
}

.markup-panel-toggle--expand {
  position: static;
  transform: none;
  width: 1.65rem;
  height: 1.65rem;
  flex-shrink: 0;
}

.markup-panel-toggle__icon {
  width: 1rem;
  height: 1rem;
}

/* Canvas */
.canvas-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 2.5rem;
  padding: 0 0.75rem 0 0.5rem;
  box-sizing: border-box;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: relative;
  z-index: 20;
}

.canvas-toolbar__actions {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  z-index: 2;
}

.canvas-toolbar .btn-sm {
  padding: 0.28rem 0.55rem;
  font-size: 0.72rem;
  min-height: 1.65rem;
}

.toolbar-dropdown {
  position: relative;
}

.toolbar-dropdown__toggle::after {
  content: '▾';
  margin-left: 0.25rem;
  font-size: 0.65rem;
  opacity: 0.75;
}

.toolbar-dropdown__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  min-width: 7.5rem;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toolbar-dropdown.open .toolbar-dropdown__menu {
  display: block;
}

.toolbar-dropdown__item {
  display: block;
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.75rem;
  text-align: left;
  cursor: pointer;
}

.toolbar-dropdown__item:hover {
  background: var(--surface-2);
  color: var(--primary);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.canvas-preferences,
.header-preferences {
  position: relative;
}

.preferences-toggle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.preferences-toggle:hover,
.canvas-preferences.open .preferences-toggle {
  border-color: var(--primary);
  background: var(--surface-2);
  color: var(--primary);
}

.preferences-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.preferences-icon {
  display: block;
}

.preferences-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  z-index: 40;
  display: none;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 17rem;
  padding: 0.75rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.canvas-preferences.open .preferences-panel,
.header-preferences.open .preferences-panel {
  display: flex;
}

.display-settings {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

.display-settings .toggle-label {
  font-size: 0.74rem;
}

.preferences-panel .timeline-settings {
  flex-wrap: wrap;
}

.preferences-panel .timeline-controls {
  flex-basis: 100%;
}

.preferences-panel .timeline-settings:has(#timeline-enabled:checked) .timeline-controls {
  max-width: 100%;
  opacity: 1;
  pointer-events: auto;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.78rem;
  user-select: none;
  white-space: nowrap;
}

.timeline-settings {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.12s ease, max-width 0.2s ease;
}

.timeline-settings:has(#timeline-enabled:checked) .timeline-controls {
  max-width: 42rem;
  opacity: 1;
  pointer-events: auto;
}

.toolbar-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
}

.toolbar-field input[type="date"],
.toolbar-field input[type="number"] {
  font: inherit;
  padding: 0.2rem 0.35rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.toolbar-field-range input[type="range"] {
  width: 72px;
  accent-color: var(--primary);
}

.toolbar-field-short input[type="number"] {
  width: 52px;
}

.canvas-hint {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  display: block;
  padding: 0 0.75rem;
  box-sizing: border-box;
  pointer-events: none;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--primary);
  opacity: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.canvas-hint:empty {
  visibility: hidden;
}

.canvas {
  flex: 1;
  overflow: auto;
  position: relative;
  --canvas-pad: 1.5rem;
  padding: var(--canvas-pad);
}

.date-grid-layer {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.date-grid-header {
  position: sticky;
  top: 0;
  height: 28px;
  background: linear-gradient(var(--bg) 60%, transparent);
  z-index: 1;
}

.date-grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(139, 149, 168, 0.18);
}

.date-grid-line.major {
  background: rgba(139, 149, 168, 0.32);
}

.date-grid-line.today-line {
  width: 2px;
  background: var(--warning);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
  z-index: 2;
}

.date-grid-label {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  font-size: 0.62rem;
  color: var(--text-muted);
  white-space: nowrap;
  background: var(--bg);
  padding: 0 0.2rem;
}

.date-grid-label.major {
  color: var(--text);
  font-weight: 600;
}

.date-grid-label.today-label {
  color: var(--warning);
  font-weight: 700;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 4px;
  padding: 0 0.35rem;
}

.links-layer {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 100%;
  pointer-events: none;
  z-index: 1;
  clip-path: inset(var(--canvas-pad));
}

.connect-preview-layer {
  z-index: 3;
  pointer-events: none;
  clip-path: inset(var(--canvas-pad));
}

.connect-preview-layer.hidden {
  display: none;
}

body.connect-mode {
  cursor: crosshair;
}

body.connect-mode .step-marker,
body.connect-mode .goal-marker.stream-goal {
  cursor: pointer;
}

body.connect-mode .step-marker.connect-target-hover .step-dot,
body.connect-mode .goal-marker.stream-goal.connect-target-hover {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--road-color, var(--primary)) 45%, transparent);
}

.canvas-hint--connect {
  color: var(--primary);
  font-weight: 700;
}

.link-path--preview {
  opacity: 0.9;
  stroke-width: 2.5;
  stroke-dasharray: 8 5;
  animation: link-preview-dash 0.5s linear infinite;
}

@keyframes link-preview-dash {
  to { stroke-dashoffset: -13; }
}

.roads-layer {
  position: relative;
  z-index: 2;
  min-width: 960px;
}

.roads-add-bar {
  margin-top: 0.5rem;
  padding: 0.25rem 0.5rem 1rem;
}

.btn-add-road-large {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.63rem 1.17rem;
  border-radius: 9px;
  min-width: 7.33rem;
  box-shadow: 0 3px 12px color-mix(in srgb, var(--primary) 28%, transparent);
}

.btn-add-road-large:hover {
  box-shadow: 0 4px 15px color-mix(in srgb, var(--primary) 36%, transparent);
}

.roads-layer.timeline-mode {
  min-width: calc(var(--track-width) + 156px + 0.5rem);
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 3;
}

.empty-state {
  text-align: center;
  max-width: 360px;
  padding: 2rem;
}

.empty-state h2 {
  margin: 0 0 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.empty-state__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.7rem;
}

.btn-fill-demo {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.58rem 1rem;
  border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--primary) 50%, var(--border));
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--primary);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent),
    0 0 20px color-mix(in srgb, var(--primary) 38%, transparent);
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.btn-fill-demo:hover {
  background: color-mix(in srgb, var(--primary) 20%, var(--surface));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--primary) 40%, transparent),
    0 0 28px color-mix(in srgb, var(--primary) 52%, transparent);
  transform: translateY(-1px);
}

.btn-fill-demo:active {
  transform: translateY(0);
}

[data-theme="light"] .btn-fill-demo {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent),
    0 0 16px color-mix(in srgb, var(--primary) 28%, transparent);
}

.hidden {
  display: none !important;
}

/* Stream groups — parallel lanes sharing one goal */
.stream-group {
  margin-bottom: 2.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 156px;
  grid-template-areas:
    "stream-header stream-goal"
    "stream-lanes stream-goal";
  column-gap: 0.5rem;
  row-gap: 0.65rem;
  align-items: stretch;
}

.timeline-mode .stream-group {
  grid-template-columns: var(--track-width) 156px;
}

.stream-header {
  grid-area: stream-header;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0;
  min-width: 0;
}

.stream-header-actions {
  display: inline-flex;
  gap: 0.15rem;
  flex-shrink: 0;
  margin-left: 0.15rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.stream-header-actions.road-actions {
  margin-left: 0.35rem;
}

.stream-header:hover .stream-header-actions,
.stream-header:focus-within .stream-header-actions {
  opacity: 1;
  pointer-events: auto;
}

.stream-header-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.stream-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.stream-goal-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stream-tag {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
}

.stream-body {
  grid-area: stream-lanes;
  min-width: 0;
}

.stream-lanes {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.timeline-mode .stream-lanes {
  width: 100%;
  max-width: 100%;
}

.stream-lane {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-radius: 8px;
  padding: 0.15rem 0.25rem;
  margin: -0.15rem -0.25rem;
  transition: background 0.15s;
}

.stream-lane:hover {
  background: rgba(99, 102, 241, 0.04);
}

.lane-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 0;
  position: relative;
}

.lane-header {
  position: absolute;
  top: 6px;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  padding-left: 0.15rem;
  min-width: 0;
  max-width: 100%;
  pointer-events: none;
}

.lane-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lane-track-wrap--labeled {
  position: relative;
}

.lane-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 0.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 6;
  padding-right: 0.15rem;
}

.stream-lane:hover .lane-actions {
  opacity: 1;
  pointer-events: auto;
}

.lane-actions button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 5px;
  font-size: 0.78rem;
}

.lane-actions button:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--text-muted);
}

.lane-row .lane-track-wrap {
  min-width: 0;
}

.stream-goal-col {
  grid-area: stream-goal;
  width: 156px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.25rem 0;
  min-height: 0;
}

.timeline-mode .stream-goal-col {
  padding-left: 0.35rem;
  border-left: 1px solid var(--border);
  background: var(--bg);
}

.stream-goal-col--span .stream-goal.goal-marker {
  min-height: 100%;
}

.stream-goal.goal-marker {
  position: relative;
  right: auto;
  top: auto;
  transform: none;
  width: 100%;
  min-height: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.stream-goal.goal-marker .goal-marker-artifacts {
  margin-top: auto;
}

.stream-body .lane-track-wrap {
  height: 88px;
  margin: 0;
  padding-right: 0;
}

.stream-body .road-track {
  right: 0;
  transition: right 0.15s ease, width 0.15s ease;
}

.stream-lane:hover .stream-body .road-track {
  right: 64px;
}

.timeline-mode .stream-body .road-track {
  right: auto;
  width: var(--track-width);
}

.timeline-mode .stream-lane:hover .stream-body .road-track {
  width: calc(var(--track-width) - 64px);
}

.road-actions button[data-action="add-lane"] {
  font-size: 0.72rem;
  color: var(--primary-hover);
}

.road-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.road-color-bar {
  width: 4px;
  height: 1.1rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.road-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.road-goal {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.road-actions {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
}

.road-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.road-actions button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.road-track-wrap {
  position: relative;
  height: 110px;
  margin: 0 0.5rem;
  padding-right: 168px;
}

.road-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 168px;
  height: 10px;
  transform: translateY(-50%);
  border-radius: 5px;
  background: var(--track-bg);
  overflow: visible;
  cursor: crosshair;
}

.step-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: auto;
}

.timeline-mode .road-track {
  right: auto;
  width: var(--track-width);
}

.road-track-hit {
  position: absolute;
  inset: -18px 0;
  z-index: 3;
  cursor: crosshair;
}

.road-track:hover .road-track-hit {
  background: var(--track-hover);
  border-radius: 8px;
}

.road-track-fill {
  height: 100%;
  border-radius: 5px;
  opacity: var(--track-fill-opacity);
  transition: width 0.3s ease;
  overflow: hidden;
  pointer-events: none;
}

.road-start,
.road-end {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.road-start { left: -0.25rem; }

/* Goal destination card */
.goal-marker {
  position: absolute;
  right: 36px;
  top: 50%;
  transform: translateY(-50%);
  width: 148px;
  min-height: 76px;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  border: 2px solid var(--road-color, var(--primary));
  background: var(--surface);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: box-shadow 0.15s, transform 0.15s;
}

[data-theme="light"] .goal-marker {
  background: color-mix(in srgb, var(--road-color, var(--primary)) 5%, var(--surface));
}

.goal-marker:hover {
  transform: translateY(-50%) scale(1.02);
  box-shadow: var(--card-shadow-hover);
}

.goal-marker.selected {
  box-shadow: var(--card-shadow-selected);
}

.stream-goal.goal-marker:hover {
  transform: scale(1.02);
}

.goal-marker-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding-right: 1.5rem;
}

.goal-marker-edit {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.goal-marker:hover .goal-marker-edit,
.goal-marker-edit:focus-visible {
  opacity: 1;
}

.goal-marker-edit:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--surface);
}

.goal-marker-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.goal-marker-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.goal-marker-title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.goal-marker-artifacts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: auto;
}

.goal-artifact-pill {
  font-size: 0.62rem;
  padding: 0.12rem 0.4rem;
  border-radius: 99px;
  background: color-mix(in srgb, var(--road-color, var(--primary)) 18%, transparent);
  color: var(--text);
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.goal-artifact-pill:hover {
  background: color-mix(in srgb, var(--road-color, var(--primary)) 30%, transparent);
}

.goal-artifact-empty {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Steps on road */
.step-marker:active {
  cursor: grabbing;
}

.step-marker.selected .step-dot {
  box-shadow: var(--step-selected-ring);
}

.step-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--road-color, var(--primary));
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  transition: transform 0.15s, box-shadow 0.15s;
}

.step-marker:hover .step-dot {
  transform: scale(1.15);
}

.step-marker.milestone .step-dot {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  transform: rotate(45deg);
}

.step-marker.milestone .step-dot-inner {
  transform: rotate(-45deg);
  font-size: 0.55rem;
}

.step-marker.done .step-dot {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

[data-theme="light"] .step-marker.pending .step-dot {
  background: #fff;
  border-color: var(--road-color, var(--primary));
  color: color-mix(in srgb, var(--road-color, var(--primary)) 75%, #1a2030);
}

[data-theme="light"] .step-marker.milestone.pending .step-dot {
  background: color-mix(in srgb, var(--road-color, var(--primary)) 14%, #fff);
}

[data-theme="light"] .step-marker.done .step-dot {
  box-shadow: 0 1px 3px rgba(5, 150, 105, 0.28);
}

[data-theme="light"] .step-marker.in_progress .step-dot {
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
}

[data-theme="light"] .step-label {
  color: var(--text);
}

[data-theme="light"] .step-date {
  color: color-mix(in srgb, var(--text) 82%, var(--text-muted));
}

.step-marker.in_progress .step-dot {
  background: var(--warning);
  border-color: var(--warning);
  color: var(--in-progress-text);
}

.step-date {
  font-size: 0.58rem;
  color: var(--primary-hover);
  pointer-events: none;
  white-space: nowrap;
}

.step-label {
  font-size: 0.68rem;
  max-width: 90px;
  text-align: center;
  line-height: 1.2;
  color: var(--text-muted);
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Step hover tooltip */
.step-tooltip {
  position: fixed;
  z-index: 1000;
  width: min(300px, calc(100vw - 20px));
  border-radius: 14px;
  background: var(--tooltip-bg);
  border: 1px solid var(--tooltip-border);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--primary) 12%, transparent),
    var(--tooltip-shadow),
    0 0 24px color-mix(in srgb, var(--road-color, var(--primary)) 18%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 0.06s ease, transform 0.06s ease;
  overflow: hidden;
}

.step-tooltip.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px) scale(0.97);
  visibility: hidden;
}

.step-tooltip:not(.hidden) {
  visibility: visible;
}

.step-tooltip-accent {
  height: 3px;
  width: 100%;
}

.step-tooltip-body {
  padding: 0.85rem 0.9rem 0.75rem;
}

.step-tooltip-connect-btn {
  padding: 0.35rem 0.55rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--connect-color, var(--primary)) 88%, #fff),
    var(--connect-color, var(--primary))
  );
  color: #fff;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  box-shadow:
    0 2px 10px color-mix(in srgb, var(--connect-color, var(--primary)) 38%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.step-tooltip-connect-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow:
    0 4px 14px color-mix(in srgb, var(--connect-color, var(--primary)) 45%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.step-tooltip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.step-tooltip-type {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.step-tooltip-type.milestone {
  color: #c4b5fd;
}

.step-tooltip-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  margin-bottom: 0.5rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.step-tooltip-date {
  padding: 0.1rem 0.45rem;
  border-radius: 99px;
  background: var(--date-pill-bg);
  color: var(--date-pill-text);
  font-size: 0.7rem;
  font-weight: 500;
}

.step-tooltip-notes {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.step-tooltip-section {
  margin-bottom: 0.65rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
}

.step-tooltip-section-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.step-tooltip-contrib {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.step-tooltip-contrib .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.35rem;
}

.step-tooltip-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

.step-tooltip-buttons {
  display: flex;
  gap: 0.35rem;
}

.step-tooltip-arrow {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--tooltip-bg);
  border-right: 1px solid var(--tooltip-border);
  border-bottom: 1px solid var(--tooltip-border);
  transform: translateX(-50%) rotate(45deg);
}

.step-tooltip--below .step-tooltip-arrow {
  bottom: auto;
  top: -6px;
  transform: translateX(-50%) rotate(-135deg);
}

.step-link-badges {
  position: absolute;
  top: -7px;
  right: -7px;
  display: flex;
  gap: 1px;
  pointer-events: none;
}

.step-link-badge {
  font-size: 0.55rem;
  color: #fff;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .step-link-badge {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .link-path {
  opacity: 0.82;
}

.step-dot {
  position: relative;
}

.add-step-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px dashed var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, border-color 0.15s, color 0.15s;
}

.stream-lane:hover .add-step-btn {
  opacity: 1;
  pointer-events: auto;
}

.stream-lane .add-step-btn {
  right: 68px;
}

.add-step-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* SVG links */
.link-path {
  fill: none;
  stroke-width: 2;
  stroke-dasharray: 6 4;
  opacity: 0.7;
}

.link-path:hover {
  opacity: 1;
  stroke-width: 2.5;
}

.link-note {
  pointer-events: none;
}

.link-note-bg {
  fill: var(--surface);
  stroke: color-mix(in srgb, var(--link-note-color, var(--primary)) 40%, var(--border));
  stroke-width: 1;
}

.link-note-text {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  fill: var(--text);
}

[data-theme="light"] .link-note-bg {
  fill: color-mix(in srgb, var(--surface) 92%, var(--link-note-color, var(--primary)) 8%);
}

.header-help {
  position: relative;
}

.header-help__menu {
  right: 0;
  left: auto;
  min-width: 11rem;
}

.help-toggle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.help-toggle:hover,
.header-help.open .help-toggle {
  border-color: var(--primary);
  background: var(--surface-2);
  color: var(--primary);
}

.help-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Info modals (About, Instructions) */
.info-modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
  color: var(--text);
  max-width: min(760px, calc(100vw - 2rem));
  width: 100%;
  max-height: calc(100vh - 2.5rem);
  overflow: visible;
}

.info-modal--notation {
  max-width: min(880px, calc(100vw - 2rem));
}

.info-modal::backdrop {
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

[data-theme="light"] .info-modal::backdrop {
  background: rgba(15, 23, 42, 0.28);
}

.info-modal__shell {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2.5rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.info-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.info-modal__header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.info-modal__close {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.info-modal__close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.info-modal__body {
  padding: 1.1rem 1.15rem 1.35rem;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.55;
}

.info-modal__body h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.info-modal__body p {
  margin: 0 0 0.75rem;
  color: var(--text);
}

.info-modal__body a {
  color: var(--primary);
}

.info-section + .info-section {
  margin-top: 1.35rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
}

.info-faq {
  margin: 0.75rem 0 0;
}

.info-faq dt {
  font-weight: 600;
  font-size: 0.88rem;
  margin-top: 0.85rem;
}

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

.info-faq dd {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.help-figure {
  margin: 0.85rem 0 0;
}

.help-figure figcaption {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

/* Instructions — live UI previews inside the modal */
.help-preview {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.help-preview .roads-layer {
  position: relative;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.help-preview .stream-group {
  margin-bottom: 0;
}

.help-preview .stream-header-actions {
  display: none !important;
}

.help-preview .stream-lane:hover {
  background: transparent;
}

.help-preview .stream-lane:hover .stream-body .road-track {
  right: 0;
}

.help-preview .stream-body .lane-track-wrap {
  height: 72px;
}

.help-preview .road-track-wrap {
  padding-right: 0;
  margin: 0;
}

.help-preview .stream-body .road-track {
  right: 0;
}

.help-preview .step-marker.selected .step-dot {
  box-shadow: var(--step-selected-ring);
}

.help-preview--structure {
  padding: 0.35rem 0.5rem 0.5rem;
}

.help-preview--structure .stream-group {
  padding: 0.15rem 0.25rem 0;
}

.help-preview--canvas .help-preview__scene {
  position: relative;
  padding: 4.5rem 0.75rem 0.65rem;
  min-height: 8.5rem;
}

.help-preview--canvas .help-preview__compact-road {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "stream-lanes";
  padding: 0 0.25rem;
}

.help-preview--canvas .help-preview__compact-road .stream-header {
  display: none;
}

.help-preview__tooltip.step-tooltip {
  position: absolute;
}

.help-preview--connect .help-preview__connect-road:first-child {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "stream-header"
    "stream-lanes";
}

.help-preview--connect .help-preview__connect-road:first-child .stream-goal-col {
  display: none;
}

.help-preview__tooltip {
  left: 50%;
  top: 0.35rem;
  width: min(260px, calc(100% - 1rem));
  transform: translateX(-50%);
  z-index: 10;
}

.help-preview__tooltip .status-badge-select {
  pointer-events: none;
}

.help-preview.help-preview--markup {
  overflow: visible;
}

.help-preview--markup .markup-editor__gutter {
  overflow: visible;
}

.help-preview--markup .markup-editor__backdrop {
  overflow: visible;
}

.help-preview--markup .markup-editor__backdrop code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.help-preview__markup-panel {
  position: relative;
  width: 100%;
  max-width: none;
  min-width: 0;
  height: auto;
  border: none;
  box-shadow: none;
  background: transparent;
}

.help-preview--markup .markup-panel__header {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.help-preview--markup .markup-panel__panes {
  overflow: visible;
}

.help-preview--markup .markup-editor {
  min-height: auto;
  max-height: none;
  height: auto;
  overflow: visible;
}

.help-preview--markup-full .markup-editor {
  min-height: auto;
  max-height: none;
}

.help-preview--markup .markup-editor__main {
  overflow: visible;
}

.help-preview--markup-full .markup-editor__backdrop code {
  display: block;
  padding-bottom: 0.75rem;
}

.info-markup-lead {
  margin: 0.85rem 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.info-markup-lead code {
  font-size: 0.8rem;
}

.help-preview--markup .markup-editor__gutter-line {
  height: 1.17rem;
}

.help-preview--timeline {
  padding: 0;
  min-height: 10rem;
}

.help-preview__timeline-scene {
  position: relative;
  min-height: 10rem;
  overflow: hidden;
}

.help-preview--timeline .date-grid-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.help-preview__timeline-roads {
  position: relative;
  z-index: 1;
  padding: 1.75rem 0.5rem 0.5rem;
}

.help-preview--timeline .help-preview__compact-road {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "stream-lanes";
  margin-bottom: 0;
}

.help-preview--timeline .help-preview__compact-road .stream-header {
  display: none;
}

.help-preview--timeline .stream-body .road-track {
  right: auto;
  width: 100%;
}

.help-preview--timeline .stream-body .lane-track-wrap {
  height: 68px;
}

.info-markup-ref {
  margin: 0.85rem 0 0;
}

.info-markup-ref dt {
  font-weight: 600;
  font-size: 0.84rem;
  margin-top: 0.75rem;
}

.info-markup-ref dt:first-child {
  margin-top: 0;
}

.info-markup-ref dt code {
  font-size: 0.82rem;
}

.info-markup-ref dd {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.info-markup-ref dd code {
  font-size: 0.78rem;
}

.info-notation-open {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  color: var(--primary);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.info-notation-open:hover {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  border-color: var(--primary);
}

.info-notation-open:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.notation-doc__lead {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

.notation-doc__section {
  margin-top: 1.35rem;
}

.notation-doc__section:first-child {
  margin-top: 0;
}

.notation-doc__section h3 {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.notation-doc__pre {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre;
}

.notation-doc__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  line-height: 1.4;
}

.notation-doc__table th,
.notation-doc__table td {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.notation-doc__table th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 0.78rem;
}

.notation-doc__table td code.notation-doc__line {
  font-size: 0.76rem;
  white-space: nowrap;
}

.notation-doc__list {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text);
}

.notation-doc__list li + li {
  margin-top: 0.35rem;
}

.notation-doc__note {
  margin: 0.65rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.notation-doc__footer {
  margin: 0.75rem 0 0;
  font-size: 0.84rem;
}

.notation-doc__section .help-figure {
  margin: 0.5rem 0 0;
}

.notation-doc__section .help-figure figcaption {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.help-preview.help-preview--connect {
  overflow: hidden;
  padding: 0.45rem 0.75rem 0.55rem 0.65rem;
}

.help-preview__connect-scene {
  position: relative;
  min-height: 11.75rem;
  width: 100%;
  overflow: hidden;
}

.help-preview__connect-target-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.15rem;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.help-preview__connect-target-row > .stream-group {
  flex: 1 1 0;
  min-width: 0;
  margin-bottom: 0;
}

.help-preview--connect .stream-goal.goal-marker.help-preview__connect-target {
  position: relative;
  right: auto;
  top: auto;
  transform: none;
  flex: 0 0 88px;
  width: 88px;
  min-width: 88px;
  max-width: 88px;
  min-height: 54px;
  margin: 0.15rem 0;
  padding: 0.38rem 0.4rem;
  box-sizing: border-box;
}

.help-preview--connect .help-preview__connect-target .goal-marker-title {
  font-size: 0.64rem;
  line-height: 1.2;
}

.help-preview--connect .help-preview__connect-road--target {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "stream-header"
    "stream-lanes";
}

.help-preview__connect-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  overflow: visible;
}

.help-preview--connect .roads-layer {
  position: relative;
  z-index: 2;
}

.help-preview--connect .road-track {
  left: 0.35rem;
  right: 0.35rem;
}

.help-preview--connect .step-marker.has-links .step-link-badges {
  z-index: 6;
}

.help-preview--connect .stream-group {
  padding: 0.1rem 0.2rem 0;
}

.help-preview--connect .help-preview__connect-road + .help-preview__connect-target-row {
  margin-top: 0.15rem;
}

.help-preview--connect .stream-body .lane-track-wrap {
  height: 56px;
}

.help-preview--toolbar {
  border: none;
  background: transparent;
  overflow: visible;
}

.help-preview--toolbar .canvas-toolbar {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

/* Modals */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  max-width: 440px;
  width: calc(100% - 2rem);
  overflow-x: hidden;
}

.modal::backdrop {
  background: var(--modal-backdrop);
}

.modal form {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  overflow-x: hidden;
}

.modal h2 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.modal--compact {
  max-width: 360px;
}

.modal label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.modal input[type="text"],
.modal input[type="url"],
.modal input[type="number"],
.modal textarea,
.modal select {
  font: inherit;
  width: 100%;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  box-sizing: border-box;
}

.modal input[type="color"] {
  width: 48px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.contribution-row label,
.artifact-row label {
  font-size: 0.75rem;
  min-width: 0;
}

#contributions-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.contributions-fieldset,
.artifacts-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.contributions-fieldset legend,
.artifacts-fieldset legend {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
  padding: 0 0.25rem;
}

.contribution-row {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.65rem 2rem 0.65rem 0.65rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
}

.contribution-remove {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.contribution-remove:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.contribution-row select,
.contribution-row input[type="text"] {
  background: var(--surface);
}

.artifact-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.4rem;
  align-items: end;
  margin-bottom: 0.4rem;
}

.artifact-link-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.artifact-link-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 0.82rem;
}

.artifact-link-item a {
  color: var(--primary-hover);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.artifact-link-item a:hover {
  text-decoration: underline;
}


.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 0.28rem 0.65rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  text-transform: capitalize;
}

.status-badge-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.status-badge-wrap.pending { color: var(--text-muted); }
.status-badge-wrap.in_progress { color: var(--warning); }
.status-badge-wrap.done { color: var(--success); }

.status-badge-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0.32rem 1.85rem 0.32rem 0.7rem;
  min-height: 1.85rem;
  transition: filter 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.status-badge-chevron {
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 14%, transparent);
  color: inherit;
  pointer-events: none;
}

.status-badge-select:hover {
  filter: brightness(1.08);
  border-color: color-mix(in srgb, currentColor 28%, transparent);
}

.status-badge-wrap:hover .status-badge-chevron {
  background: color-mix(in srgb, currentColor 22%, transparent);
}

.status-badge-select:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--road-color, var(--primary)) 50%, transparent);
  outline-offset: 1px;
}

.status-badge.pending { background-color: var(--surface-2); color: var(--text-muted); }
.status-badge.in_progress { background-color: rgba(245, 158, 11, 0.2); color: var(--warning); }
.status-badge.done { background-color: rgba(34, 197, 94, 0.2); color: var(--success); }

/* Theme toggle */
.theme-toggle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--primary);
  background: var(--surface-2);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Toast notifications */
.toast-stack {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.65rem 0.65rem 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast__message {
  flex: 1;
  min-width: 0;
  padding-top: 0.1rem;
}

.toast__close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin: -0.1rem -0.05rem 0 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.toast__close:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.toast__close:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.toast--hide {
  opacity: 0;
  transform: translateY(6px);
}

.toast--error {
  border-color: color-mix(in srgb, var(--danger, #ef4444) 40%, var(--border));
  background: color-mix(in srgb, var(--danger, #ef4444) 8%, var(--surface));
}

.toast--success {
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
  background: color-mix(in srgb, var(--success) 8%, var(--surface));
}

.toast--info {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}

.file-protocol-warning {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
  color: var(--text);
}

.file-protocol-warning[hidden] {
  display: none !important;
}

.file-protocol-warning__card {
  max-width: 28rem;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.file-protocol-warning__card h1 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.file-protocol-warning__card p {
  margin: 0 0 0.65rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.file-protocol-warning__card pre {
  margin: 0 0 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: var(--surface-2);
  overflow-x: auto;
}

.file-protocol-warning__card code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.9rem;
}

/* View-only shared map mode */
.view-only-mode .markup-panel,
.view-only-mode .markup-panel-toggle--expand,
.view-only-mode #share-dropdown,
.view-only-mode .timeline-settings,
.view-only-mode .canvas-empty .empty-state__actions {
  display: none !important;
}

.view-only-mode .main {
  /* Canvas uses full width when markup panel is hidden */
}

.view-only-mode .step-marker {
  cursor: default;
}
