.timeline-shell {
  width: 100%;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.timeline-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-6);
  margin-bottom: var(--space-5);
}

.timeline-range-tabs {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  flex: 0 0 auto;
}

.timeline-range-tab {
  position: relative;
  padding: var(--space-2) 0;
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 700;
  transition: color 160ms ease;
}

.timeline-range-tab::after {
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 0;
  height: 2px;
  border-radius: 999px;
  background: var(--color-primary);
  content: "";
  opacity: 0;
  transform: scaleX(0.65);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.timeline-range-tab:hover,
.timeline-range-tab:focus,
.timeline-range-tab.is-active {
  color: var(--color-text);
  outline: none;
}

.timeline-range-tab.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.timeline-range-nav {
  display: grid;
  grid-template-columns: 36px minmax(190px, auto) 36px;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
}

.timeline-nav-button,
.timeline-today-button,
.timeline-refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.timeline-nav-button {
  width: 36px;
}

.timeline-today-button {
  padding: 0 var(--space-3);
}

.timeline-refresh-button {
  width: 36px;
  padding: 0;
  font-size: var(--font-size-lg);
  line-height: 1;
}

.timeline-nav-button:hover,
.timeline-nav-button:focus,
.timeline-today-button:hover,
.timeline-today-button:focus,
.timeline-refresh-button:hover,
.timeline-refresh-button:focus {
  border-color: var(--color-primary);
  color: var(--color-primary);
  outline: none;
}

.timeline-range-label {
  color: var(--color-text);
  font-size: var(--font-size-lg);
  font-weight: 600;
  text-align: center;
}

.timeline-quick-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
}

.timeline-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.timeline-type-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  box-sizing: border-box;
  min-height: 34px;
  margin: 0;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.timeline-type-filter label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 100%;
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.timeline-type-filter input {
  margin: 0;
}

.timeline-filter-field {
  display: inline-flex;
  align-items: center;
}

.timeline-filter-field .input {
  min-width: 132px;
  min-height: 34px;
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: 700;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.timeline-day {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
}

.timeline-today-marker {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.timeline-today-marker::before,
.timeline-today-marker::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--color-border);
}

.timeline-today-marker-label {
  white-space: nowrap;
}

.timeline-day-title {
  margin-bottom: var(--space-3);
  font-size: var(--font-size-lg);
  line-height: var(--line-height-tight);
}

.timeline-day-axis {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-summary-axis {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-summary-slot {
  position: relative;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: var(--space-3);
  min-height: 46px;
  border-bottom: 1px solid var(--color-border);
}

.timeline-summary-slot::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: calc(84px + var(--space-3));
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: rgba(20, 132, 116, 0.82);
  content: "";
  pointer-events: none;
  transform: scaleX(var(--timeline-slot-density, 0));
  transform-origin: left center;
}

.timeline-summary-slot:first-child {
  border-top: 1px solid var(--color-border);
}

.timeline-summary-slot.is-current {
  border-left: 2px solid var(--color-primary);
}

.timeline-summary-slot.is-week-summary {
  min-height: 126px;
}

.timeline-summary-slot.is-year-summary {
  min-height: 100px;
}

.timeline-summary-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: var(--space-3) var(--space-2) 0;
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
}

.timeline-summary-label-main {
  color: var(--color-text-muted);
  font-weight: 700;
}

.timeline-summary-label-sub {
  font-size: var(--font-size-xs);
}

.timeline-summary-body {
  position: relative;
  min-width: 0;
  padding: var(--space-2) 0;
}

.timeline-summary-empty {
  position: relative;
  margin: 0;
  padding: var(--space-1) 0;
  color: #a4adb6;
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.timeline-summary-event-list {
  position: relative;
  display: grid;
  gap: 1px;
}

.timeline-summary-event-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
  min-width: 0;
}

.timeline-summary-event-row .timeline-summary-event {
  flex: 0 1 auto;
}

.timeline-summary-event {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-1);
  max-width: 100%;
  min-width: 0;
  width: auto;
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  text-align: left;
}

.timeline-summary-event:hover,
.timeline-summary-event:focus {
  color: var(--color-primary);
  outline: none;
}

.timeline-summary-event.is-past {
  color: var(--color-text-muted);
}

.timeline-summary-event-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-summary-event-meta {
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
  white-space: nowrap;
}

.timeline-summary-event.is-completed .timeline-summary-event-title {
  color: var(--color-text-muted);
  font-style: italic;
}

.timeline-summary-event.is-canceled .timeline-summary-event-title {
  color: var(--color-text-muted);
  text-decoration: line-through;
}

.timeline-summary-more-button {
  position: relative;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: 700;
  white-space: nowrap;
}

.timeline-summary-more-button:hover,
.timeline-summary-more-button:focus {
  color: var(--color-primary-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
  outline: none;
}

.timeline-summary-more-button:disabled {
  color: var(--color-text-light);
  cursor: default;
  text-decoration: none;
}

.timeline-day-floating {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.timeline-day-slot-title {
  margin: 0 0 var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 700;
}

.timeline-day-slot-empty {
  margin: 0;
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
}

.timeline-hour-slot {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: var(--space-3);
  min-height: 42px;
  border-bottom: 1px solid var(--color-border);
}

.timeline-hour-label {
  padding-top: var(--space-3);
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
}

.timeline-hour-events {
  position: relative;
  min-width: 0;
  padding: var(--space-1) 0;
}

.timeline-hour-events:empty::before {
  content: "";
  display: block;
  min-height: 34px;
}

.timeline-current-time-marker {
  position: absolute;
  left: 0;
  right: 0;
  top: calc((var(--timeline-current-minute, 0) / 60) * 100%);
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-primary);
  pointer-events: none;
}

.timeline-current-time-marker::before {
  content: "";
  flex: 0 0 48px;
  border-top: 1px solid var(--color-primary);
}

.timeline-current-time-marker::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--color-primary);
}

.timeline-current-time-label {
  padding: 1px var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-primary);
  font-size: var(--font-size-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timeline-event-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.timeline-event {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) 0;
  border: 0;
  background: transparent;
  color: var(--color-text);
  text-align: left;
}

.timeline-event:hover {
  color: var(--color-primary);
}

.timeline-event.is-highlighted {
  background: #fff7d6;
  outline: 1px solid #d6a700;
  outline-offset: 2px;
  animation: timeline-event-flash 1.1s ease-out 2;
}

@keyframes timeline-event-flash {
  0% {
    background: #fff0a8;
    box-shadow: 0 0 0 0 rgba(214, 167, 0, 0.35);
  }

  55% {
    background: #fff7d6;
    box-shadow: 0 0 0 6px rgba(214, 167, 0, 0);
  }

  100% {
    background: transparent;
    box-shadow: none;
  }
}

.timeline-event.is-past {
  color: var(--color-text-muted);
}

.timeline-event.is-past .timeline-event-time,
.timeline-event.is-past .timeline-event-memo {
  color: var(--color-text-light);
}

.timeline-event-time {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
}

.timeline-event-body {
  min-width: 0;
}

.timeline-event-line {
  display: block;
  overflow-wrap: anywhere;
}

.timeline-event-memo {
  display: block;
  margin-top: var(--space-1);
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
}

.timeline-event.is-completed .timeline-event-line {
  color: var(--color-text-muted);
  font-style: italic;
}

.timeline-event.is-canceled .timeline-event-line {
  color: var(--color-text-muted);
  text-decoration: line-through;
}

.timeline-empty {
  padding: var(--space-8) 0;
  color: var(--color-text-muted);
}

.timeline-empty-title {
  margin: 0;
  color: var(--color-text);
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.timeline-empty-hint {
  margin: var(--space-2) 0 0;
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
}

@media (max-width: 640px) {
  .timeline-shell {
    padding: var(--space-3);
  }

  .timeline-controls {
    gap: var(--space-3);
  }

  .timeline-range-tabs,
  .timeline-range-nav,
  .timeline-quick-actions,
  .timeline-filters {
    width: 100%;
  }

  .timeline-range-nav {
    grid-template-columns: 34px minmax(0, 1fr) 34px;
  }

  .timeline-quick-actions {
    justify-content: flex-start;
  }

  .timeline-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-filter-field,
  .timeline-filter-field .input {
    width: 100%;
    min-width: 0;
  }

  .timeline-range-label {
    font-size: var(--font-size-md);
  }

  .timeline-hour-slot {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: var(--space-2);
  }

  .timeline-summary-slot {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: var(--space-2);
  }

  .timeline-summary-slot::after {
    left: calc(64px + var(--space-2));
  }

  .timeline-summary-label {
    padding-right: var(--space-1);
    padding-left: var(--space-1);
  }

  .timeline-summary-event {
    grid-template-columns: minmax(0, 1fr);
    gap: 1px;
  }

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