:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-muted: #edf1f2;
  --line: #d7dde1;
  --line-strong: #8b969e;
  --text: #15191d;
  --muted: #66717b;
  --accent: #2f80ed;
  --accent-strong: #1f66c4;
  --danger: #d84848;
  --shadow: 0 18px 40px rgba(22, 30, 38, 0.14);
  --card-width: 292px;
  --card-height: 166px;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

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

button {
  color: inherit;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.tool-button .icon,
.icon-button .icon {
  pointer-events: none;
}

.app-shell {
  height: 100%;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 178px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #111;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 17px;
  line-height: 1;
}

.brand-copy span {
  max-width: 120px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-box {
  height: 44px;
  width: min(310px, 24vw);
  min-width: 190px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
}

.search-box:focus-within {
  border-color: #9db9dc;
  background: #fff;
}

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.tool-button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.tool-button {
  padding: 0 14px;
  font-weight: 650;
}

.tool-button.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
}

.tool-button:hover,
.icon-button:hover,
.segmented-control button:hover {
  border-color: #aeb8bf;
  background: #f9faf9;
}

.primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-action:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.danger-action {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.danger-action:hover {
  border-color: #b93636;
  background: #b93636;
}

.ghost {
  border-color: transparent;
  background: transparent;
}

.timeline-item .icon-button.ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(174, 184, 191, 0);
  transition: background-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
}

.timeline-item .icon-button.ghost:hover {
  border-color: transparent;
  background: #f9faf9;
  box-shadow: inset 0 0 0 1px #aeb8bf;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.topbar-spacer {
  flex: 1 1 auto;
  min-width: 12px;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  height: 42px;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.segmented-control button {
  min-width: 72px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-weight: 650;
}

.segmented-control button.active {
  background: #fff;
  box-shadow: 0 1px 5px rgba(19, 28, 34, 0.12);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
}

.sidebar {
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #fbfcfc;
}

.project-section {
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.section-head h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

.field-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-label.compact {
  margin-bottom: 7px;
}

.field-hint {
  margin: -9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.field-hint code {
  color: #38434d;
  font-family: inherit;
  font-weight: 750;
}

.text-input,
.color-input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: 0;
}

.text-input:focus,
.color-input:focus {
  border-color: #9db9dc;
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.13);
}

.color-input {
  height: 44px;
  padding: 5px;
}

.load-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
  margin: 12px 0 18px;
}

.timeline-list {
  display: grid;
  gap: 8px;
}

.timeline-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) 40px 40px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px 6px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.timeline-swatch {
  width: 12px;
  height: 26px;
  border-radius: 999px;
}

.timeline-name {
  min-width: 0;
}

.timeline-name strong,
.timeline-name span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-name strong {
  font-size: 14px;
}

.timeline-name span {
  color: var(--muted);
  font-size: 12px;
}

.timeline-item.is-muted {
  opacity: 0.55;
}

.stats-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.stat-card {
  min-height: 58px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-card strong {
  font-size: 24px;
  line-height: 1;
}

.stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) 44px;
  background: var(--bg);
}

.filter-panel {
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  z-index: 10;
}

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

.filter-panel label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.filter-panel select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 28px 0 10px;
}

.stage-status {
  grid-row: 2;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  z-index: 8;
}

.stage-status > div:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.stage-status strong,
.stage-status span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-status strong {
  font-size: 14px;
}

.stage-status span {
  color: var(--muted);
  font-size: 12px;
}

.zoom-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-viewport {
  grid-row: 3;
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(#0000 0, #0000 139px, rgba(118, 130, 140, 0.1) 140px),
    #f7f9f9;
  background-size: 100% 140px, auto;
  cursor: grab;
  touch-action: none;
}

.timeline-viewport.is-dragging {
  cursor: grabbing;
}

.timeline-viewport.is-pinching {
  cursor: zoom-in;
}

.timeline-viewport.is-selecting-range {
  cursor: crosshair;
}

.mobile-stage-chrome,
.mobile-menu {
  display: none;
}

.grid-layer,
.duration-layer,
.axis-layer,
.event-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(118, 130, 140, 0.22);
}

.grid-line.major {
  background: rgba(79, 91, 101, 0.28);
}

.grid-line.is-horizontal {
  left: 0;
  right: 0;
  top: auto;
  bottom: auto;
  width: auto;
  height: 1px;
}

.axis-main {
  position: absolute;
  left: 0;
  right: 24px;
  height: 5px;
  border-radius: 99px;
  background: #59616a;
}

.axis-main::after {
  content: "";
  position: absolute;
  right: -20px;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 22px solid #59616a;
  transform: translateY(-50%);
}

.axis-main.is-vertical {
  top: 24px;
  bottom: 0;
  right: auto;
  width: 5px;
  height: auto;
}

.axis-main.is-vertical::after {
  right: auto;
  left: 50%;
  top: -20px;
  border-top: 0;
  border-right: 12px solid transparent;
  border-left: 12px solid transparent;
  border-bottom: 22px solid #59616a;
  transform: translateX(-50%);
}

.axis-tick {
  position: absolute;
  width: 3px;
  border-radius: 99px;
  background: #59616a;
  transform: translateX(-50%);
}

.axis-tick.minor {
  width: 2px;
  opacity: 0.72;
}

.axis-tick.is-vertical {
  height: 3px;
  transform: translateY(-50%);
}

.axis-tick.is-vertical.minor {
  height: 2px;
}

.axis-label {
  position: absolute;
  transform: translateX(-50%);
  color: #111820;
  font-weight: 750;
  font-size: 25px;
  line-height: 1;
  white-space: nowrap;
}

.axis-label.small {
  font-size: 18px;
  color: #39424b;
}

.axis-label.is-vertical {
  transform: translateY(-50%);
  font-size: 21px;
}

.axis-label.is-vertical.small {
  font-size: 15px;
}

.duration-segment {
  position: absolute;
  height: 14px;
  min-width: 10px;
  border-radius: 99px;
  opacity: 0.34;
  pointer-events: auto;
  cursor: context-menu;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.65) inset;
}

.duration-segment.is-selected {
  opacity: 0.9;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.8) inset,
    0 0 0 4px color-mix(in srgb, currentColor 12%, transparent),
    0 8px 18px color-mix(in srgb, currentColor 24%, transparent);
}

.duration-segment::before,
.duration-segment::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: inherit;
  transform: translateY(-50%);
}

.duration-segment::before {
  left: -4px;
}

.duration-segment::after {
  right: -4px;
}

.duration-segment.is-vertical {
  width: 14px;
  min-width: 0;
}

.duration-segment.is-vertical::before,
.duration-segment.is-vertical::after {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.duration-segment.is-vertical::before {
  top: -4px;
}

.duration-segment.is-vertical::after {
  top: auto;
  bottom: -4px;
}

.event-card {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  border: 1px solid color-mix(in srgb, var(--event-color) 78%, #ffffff);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
  pointer-events: auto;
  overflow: hidden;
  outline: 1px solid transparent;
  outline-offset: -1px;
  transition: background-color 0.12s ease, box-shadow 0.12s ease, outline-color 0.12s ease;
}

.event-card.is-selected {
  z-index: 15;
  background: #fff;
  border-color: var(--event-color);
  outline-color: color-mix(in srgb, var(--event-color) 70%, #ffffff);
  box-shadow:
    0 22px 48px rgba(22, 30, 38, 0.22),
    0 0 0 4px color-mix(in srgb, var(--event-color) 18%, transparent);
}

.event-card.is-above-axis {
  border-bottom: 7px solid var(--event-color);
}

.event-card.is-below-axis {
  border-top: 7px solid var(--event-color);
}

.event-card.is-right-of-axis {
  border-left: 7px solid var(--event-color);
}

.event-card:hover {
  background: #fff;
  outline-color: color-mix(in srgb, var(--event-color) 40%, #ffffff);
  box-shadow:
    0 16px 34px rgba(22, 30, 38, 0.16),
    0 0 0 3px color-mix(in srgb, var(--event-color) 12%, transparent);
}

.event-card-inner {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 6px;
  height: 100%;
  padding: 8px 10px 9px;
}

.event-image {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-muted);
}

.event-placeholder {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--event-color) 20%, #ffffff);
  color: var(--event-color);
  font-weight: 800;
}

.event-content {
  position: relative;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 1px;
  z-index: 3;
}

.event-title-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.event-title {
  margin: 0 0 -3px;
  padding-bottom: 3px;
  color: #101418;
  font-size: 16px;
  line-height: 1.16;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.event-title a {
  display: block;
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: text-decoration-color 0.12s ease;
}

.event-title a:hover {
  text-decoration-color: currentColor;
}

.delete-event-button {
  width: 26px;
  height: 26px;
  min-height: 26px;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--event-color) 60%, #252b31);
}

.delete-event-button .icon {
  width: 17px;
  height: 17px;
}

.event-date {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.05;
}

.event-extract {
  grid-column: 1 / -1;
  margin: 0;
  color: #283039;
  font-size: 13px;
  line-height: 1.24;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.event-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 48px;
  padding: 20px 10px 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.9) 42%,
    rgba(255, 255, 255, 0.98) 68%,
    #fff 100%
  );
  z-index: 2;
}

.event-badges {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.event-kind-icon {
  position: relative;
  width: 22px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: color-mix(in srgb, var(--event-color) 10%, #ffffff);
  color: color-mix(in srgb, var(--event-color) 76%, #1a1f24);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--event-color) 26%, #ffffff);
}

.event-kind-icon::before,
.event-kind-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  background: currentColor;
  transform: translateY(-50%);
}

.event-kind-icon.is-point::before {
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.event-kind-icon.is-range::before {
  left: 5px;
  right: 5px;
  height: 3px;
  border-radius: 999px;
}

.event-kind-icon.is-range::after {
  left: 4px;
  width: 14px;
  height: 8px;
  border-radius: 999px;
  background:
    radial-gradient(circle at left center, currentColor 0 3px, transparent 3.4px),
    radial-gradient(circle at right center, currentColor 0 3px, transparent 3.4px);
}

.priority-pill {
  flex: 0 0 auto;
  min-width: 28px;
  height: 20px;
  padding: 0 7px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--event-color) 16%, #ffffff);
  color: color-mix(in srgb, var(--event-color) 78%, #1a1f24);
  font-size: 12px;
  font-weight: 800;
}

.timeline-chip {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.connector-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.event-connector {
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0.92;
}

.event-connector.is-selected {
  stroke-width: 5;
  opacity: 1;
  filter: drop-shadow(0 0 5px color-mix(in srgb, currentColor 42%, transparent));
}

.event-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 4px solid var(--event-color);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.78);
}

.event-dot.is-selected {
  z-index: 14;
  box-shadow:
    0 0 0 5px rgba(255, 255, 255, 0.9),
    0 0 0 10px color-mix(in srgb, var(--event-color) 20%, transparent),
    0 10px 18px color-mix(in srgb, var(--event-color) 28%, transparent);
}

.event-dot.filled {
  background: var(--event-color);
}

.event-context-menu {
  position: fixed;
  min-width: 210px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow:
    0 18px 42px rgba(22, 30, 38, 0.18),
    0 1px 0 rgba(255, 255, 255, 0.9) inset;
  z-index: 80;
}

.event-context-menu[hidden] {
  display: none;
}

.event-context-menu button {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.event-context-menu button:hover,
.event-context-menu button:focus-visible {
  outline: 0;
  background: var(--surface-muted);
}

.view-mode-menu {
  min-width: 250px;
}

.view-mode-menu button {
  min-height: 46px;
  display: grid;
  justify-items: start;
  gap: 2px;
}

.view-mode-menu button.is-active {
  background: color-mix(in srgb, var(--accent) 11%, #ffffff);
  color: var(--accent-strong);
}

.view-mode-menu small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.confirm-modal .modal-panel {
  gap: 18px;
}

.confirm-modal .modal-head p {
  max-width: 34rem;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.range-context-menu {
  min-width: 280px;
}

.range-context-heading {
  padding: 8px 10px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.range-context-option {
  min-height: 44px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.range-context-option:hover,
.range-context-option:focus-within {
  background: var(--surface-muted);
}

.range-context-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.range-context-option span,
.range-context-option strong,
.range-context-option small {
  min-width: 0;
}

.range-context-option span {
  display: grid;
  gap: 2px;
}

.range-context-option strong,
.range-context-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.range-context-option strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.1;
}

.range-context-option small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.range-context-zoom {
  margin-top: 4px;
  border-top: 1px solid var(--line) !important;
  border-radius: 0 0 6px 6px !important;
}

.range-selection-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  background: rgba(47, 128, 237, 0.12);
  box-shadow: 0 0 0 1px rgba(47, 128, 237, 0.18) inset;
  pointer-events: none;
  z-index: 18;
}

.range-selection-overlay[hidden] {
  display: none;
}

.range-selection-overlay.is-vertical {
  left: 0;
  right: 0;
  bottom: auto;
  width: auto;
  border-left: 0;
  border-right: 0;
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
}

.empty-state {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 18px;
  transform: translate(-50%, -50%);
  color: var(--muted);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.timeline-tabs {
  grid-row: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  overflow-x: auto;
}

.timeline-tab {
  min-width: 140px;
  max-width: 220px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

.timeline-tab span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-tab,
.timeline-item {
  cursor: context-menu;
}

.tab-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 999px;
}

.presentation-exit-button {
  display: none;
}

.presentation-mode {
  background: #f7f9f9;
}

.presentation-mode .app-shell {
  grid-template-rows: minmax(0, 1fr);
}

.presentation-mode .topbar,
.presentation-mode .sidebar,
.presentation-mode .filter-panel,
.presentation-mode .timeline-tabs {
  display: none;
}

.presentation-mode .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.presentation-mode .stage {
  position: relative;
  grid-template-rows: minmax(0, 1fr);
}

.presentation-mode .timeline-viewport {
  grid-row: 1;
}

.presentation-mode .stage-status {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 16px;
  min-height: 48px;
  border: 1px solid rgba(139, 150, 158, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 28px rgba(22, 30, 38, 0.1);
  backdrop-filter: blur(16px);
}

.presentation-mode .presentation-exit-button {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 35;
  display: inline-flex;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 28px rgba(22, 30, 38, 0.12);
}

.modal {
  width: min(620px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
}

.modal::backdrop {
  background: rgba(17, 22, 27, 0.38);
}

.modal-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
}

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

.help-modal {
  width: min(760px, calc(100vw - 32px));
}

.help-panel {
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
}

.ai-helper-modal {
  width: min(780px, calc(100vw - 32px));
}

.ai-helper-panel {
  max-height: min(820px, calc(100vh - 48px));
  overflow: auto;
}

.wizard-progress {
  min-height: 32px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.ai-helper-step {
  display: grid;
  gap: 14px;
}

.ai-helper-step[hidden] {
  display: none;
}

.ai-helper-textarea,
.ai-helper-prompt {
  min-height: 112px;
  padding: 10px 12px;
  line-height: 1.4;
  resize: vertical;
}

.ai-helper-prompt {
  min-height: 270px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.ai-helper-inline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.ai-helper-actions {
  align-items: center;
}

.help-content {
  display: grid;
  gap: 0;
}

.help-section {
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.help-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.help-section h3,
.help-section p {
  margin: 0;
}

.help-section h3 {
  font-size: 15px;
  line-height: 1.2;
}

.help-section p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.help-section code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.92em;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-head h2,
.modal-head p {
  margin: 0;
}

.modal-head h2 {
  font-size: 22px;
  line-height: 1.1;
}

.modal-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #161b20;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1350px) {
  .topbar {
    gap: 9px;
    padding-inline: 12px;
  }

  .brand {
    min-width: 138px;
  }

  .brand-copy span {
    display: none;
  }

  .search-box {
    width: min(245px, 22vw);
    min-width: 160px;
  }

  .tool-button {
    padding-inline: 11px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .segmented-control button {
    min-width: 62px;
  }
}

@media (max-width: 980px) {
  .topbar {
    gap: 8px;
  }

  .brand {
    min-width: 54px;
  }

  .brand-copy {
    display: none;
  }

  .search-box {
    width: auto;
    flex: 1 1 180px;
  }

  .workspace {
    grid-template-columns: 232px minmax(0, 1fr);
  }

  :root {
    --card-width: 260px;
    --card-height: 160px;
  }

  .axis-label {
    font-size: 22px;
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100%;
    height: auto;
    grid-template-rows: auto minmax(640px, 1fr);
  }

  .topbar {
    flex-wrap: wrap;
  }

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

  .sidebar {
    max-height: 280px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    min-height: 640px;
  }

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

  .tool-button span {
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.timeline-viewport.is-vertical-timeline {
  background:
    linear-gradient(90deg, #0000 0, #0000 118px, rgba(118, 130, 140, 0.1) 119px),
    #f7f9f9;
  background-size: 118px 100%, auto;
}

body.viewport-desktop-portrait .workspace,
body.viewport-tablet-portrait .workspace {
  grid-template-columns: minmax(0, 1fr);
}

body.viewport-desktop-portrait .sidebar,
body.viewport-tablet-portrait .sidebar {
  display: none;
}

body.viewport-tablet-landscape .stage {
  grid-template-rows: auto minmax(0, 1fr);
}

body.viewport-tablet-landscape .stage-status,
body.viewport-tablet-landscape .timeline-tabs {
  display: none;
}

body.viewport-tablet-landscape .timeline-viewport {
  grid-row: 2;
}

body.viewport-mobile-landscape,
body.viewport-mobile-portrait {
  --card-width: 248px;
  --card-height: 150px;
  overflow: hidden;
}

body.viewport-mobile-landscape .app-shell,
body.viewport-mobile-portrait .app-shell {
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
}

body.viewport-mobile-landscape .topbar,
body.viewport-mobile-landscape .sidebar,
body.viewport-mobile-landscape .filter-panel,
body.viewport-mobile-landscape .stage-status,
body.viewport-mobile-landscape .timeline-tabs,
body.viewport-mobile-portrait .topbar,
body.viewport-mobile-portrait .sidebar,
body.viewport-mobile-portrait .filter-panel,
body.viewport-mobile-portrait .stage-status,
body.viewport-mobile-portrait .timeline-tabs {
  display: none !important;
}

body.viewport-mobile-landscape .workspace,
body.viewport-mobile-portrait .workspace {
  grid-row: 1;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
}

body.viewport-mobile-landscape .stage,
body.viewport-mobile-portrait .stage {
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
}

body.viewport-mobile-landscape .timeline-viewport,
body.viewport-mobile-portrait .timeline-viewport {
  grid-row: 1;
}

body.viewport-mobile-landscape .mobile-stage-chrome,
body.viewport-mobile-portrait .mobile-stage-chrome {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.mobile-stage-brand {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  border: 1px solid rgba(139, 150, 158, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 28px rgba(22, 30, 38, 0.12);
  backdrop-filter: blur(16px);
  pointer-events: auto;
}

.mobile-stage-brand span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #111;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.mobile-stage-brand strong {
  font-size: 13px;
  line-height: 1;
}

.mobile-menu-button {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 28px rgba(22, 30, 38, 0.12);
  backdrop-filter: blur(16px);
  pointer-events: auto;
}

body.viewport-mobile-landscape .mobile-menu,
body.viewport-mobile-portrait .mobile-menu {
  position: absolute;
  top: 54px;
  right: 10px;
  z-index: 70;
  width: min(260px, calc(100vw - 20px));
  max-height: calc(100vh - 64px);
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid rgba(139, 150, 158, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(22, 30, 38, 0.18);
  backdrop-filter: blur(18px);
  overflow: auto;
}

body.viewport-mobile-landscape .mobile-menu[hidden],
body.viewport-mobile-portrait .mobile-menu[hidden] {
  display: none;
}

.mobile-menu button {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
}

.mobile-menu button:hover,
.mobile-menu button:focus-visible {
  outline: 0;
  background: var(--surface-muted);
}

body.viewport-mobile-landscape .event-title,
body.viewport-mobile-portrait .event-title {
  font-size: 14px;
}

body.viewport-mobile-landscape .event-extract,
body.viewport-mobile-portrait .event-extract {
  -webkit-line-clamp: 4;
  font-size: 12px;
}

body.viewport-mobile-landscape .axis-label,
body.viewport-mobile-portrait .axis-label {
  font-size: 18px;
}

body.viewport-mobile-landscape .axis-label.small,
body.viewport-mobile-portrait .axis-label.small {
  font-size: 14px;
}

@media (max-width: 380px) {
  body.viewport-mobile-landscape,
  body.viewport-mobile-portrait {
    --card-width: 226px;
    --card-height: 146px;
  }
}
